Commit Graph
70 Commits
Author SHA1 Message Date
Noah StrideandMarco Dinis 0586278cde Migrate GetClusterName to gRPC (#53164)
* Adjust GetClusterName method signature to include context.Context

* Start hacking on gRPC GetClusterName impl

* Fix test mocks to match signature

* Fix integration tests

* Fix integrations tests

* Missing ctx

* New GetClusterName RPC implementatin

* Add fallback cluster name

* Correct godoc comment

* Remove unused method

* Remove unused import

* Fix E2E test

* Fix tests

* Fix deferred context cancel in test conflicting with parallel subtests

* Fix import

* Fix imports

* Update lib/auth/auth_with_roles.go

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>

---------

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>
2025-03-20 10:07:02 +00:00
Dan Upton fd2edb678c Machine ID: Per-ouput credential_ttl and renewal_interval (#51956)
* Move `CertificateTTL` and `RenewalInterval` into a `CertificateLifetime` struct

These values are always required together, and moving them into a struct will
make it more straightforward to override them per-service/output.

* Support custom `certificate_ttl` and `renewal_interval` on identity output

* Support custom `certificate_ttl` and `renewal_interval` on application output

* Support custom `certificate_ttl` and `renewal_interval` on application tunnel

* Support custom `certificate_ttl` and `renewal_interval` on Kubernetes output

* Support custom `certificate_ttl` and `renewal_interval` on Kubernetes V2 output

* Support custom `certificate_ttl` and `renewal_interval` on database tunnel

* Support custom `certificate_ttl` and `renewal_interval` on SSH host output

* Support custom `certificate_ttl` and `renewal_interval` on SSH multiplexer

* Support custom `certificate_ttl` and `renewal_interval` on SPIFFE SVID output

* Support custom `certificate_ttl` and `renewal_interval` on database output

* Support custom `certificate_ttl` and `renewal_interval` on workload API

* Support custom `certificate_ttl` and `renewal_interval` on workload identity output

* Add `GetCertificateLifetime` to service config interface

* Update the docs

* Add more examples to the standard config

* Rename `CertificateLifetime` to `CredentialLifetime`

So it can be used for non-certificate credentials like JWTs

* Deprecate `certificate_ttl` option and replace it with `credential_ttl`

* Return TTL warnings as errors and let the caller decide what to do with them

* Add `CredentialLifetime` to the "full" service config tests

* Support `credential_ttl` and `renewal_interval` in workload-identity-jwt service

* Silence sloglint

* Replace duplicated helper with `cmp.Or`
2025-02-14 14:42:17 +00:00
Alan Parra 108d736eec chore: Bump github.com/jonboulle/clockwork to v0.5.0 (#51434)
* Update e/ reference

* chore: Bump github.com/jonboulle/clockwork to v0.5.0

* Rewrite clockwork.FakeClock to *clockwork.FakeClock

* Fix lib/srv/app/gcp/handler_test.go

* Add a linter exception for FakeClock.BlockUntil

* Change AppTestOptions.Clock to clockwork.Clock
2025-01-24 15:22:13 +00:00
rosstimothy ef859498bc Vendor gravitational/trace/trail in api (#51032)
* Vendor gravitational/trace/trail in api

Pulling in the trail package directly in api will allow the trace
module to shed the grpc-go dependency. This needs to land prior
to https://github.com/gravitational/trace/pull/112 being included
in a new version of trace.

There should be no noticable change in the api depdency tree since
it already depends on grpc-go. Some additional items from the
trace/internal package were also vendored within trail as needed.
Additionally, some of the public api of trail that was not being
consumed has been made private.

* fix: appease linters
2025-01-14 21:04:01 +00:00
Hugo Shakaandrosstimothy 4883a184cd Remove direct zap dependecy in operator and kube-agent-updater (#50960)
* Remove direct zap dependecy

* fixup! Remove direct zap dependecy

* Apply suggestions from code review

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2025-01-14 15:38:38 +00:00
rosstimothy cca83feb66 Convert integrations to use slog (#50921) 2025-01-10 16:08:42 +00:00
rosstimothy 2aed5bf6da Remove logrus (#50829)
* Remove all direct logrus usage from teleport module

The only remaining use of logrus is from integrations, which is
unfortunately imported by teleport.e, and prevents logrus from
being moved to an indirect dependency. The logrus formatter and
initialization of the logrus logger will remain in place until
integrations is using slog. To prevent any accidental inclusions
of logrus within the teleport module the depguard rules have been
updated to prohibit importing logrus. The rules also include
prohibit a few common log packages that tools like gopls might
automatically import.

* Refactor logger initialization

Consolidates configuring of global loggers to a single function.
This is mainly to facilitate configuring the logger for
teleport scp, but will also allow us to remove the copy of logger
initialization that currently exists in integrations/lib/logger.

* fix: document ValidateFields

* fix: remove copied yaml tags

* fix: update file path comment
2025-01-09 16:41:28 +00:00
rosstimothy 2c764e14b5 Reduce reliance on servicecfg.Config logrus logger (#50817)
Converts most items to use servicecfg.Config.Logger instead of
servicecfg.Config.Log. The deprecated logrus logger unfortunately
cannot be removed yet as it's still used in e. Additionally all
logging within the config package was converted to use slog.
2025-01-07 20:09:30 +00:00
Hugo Shaka 3eb6bd0c32 Rename lib/kubernetestoken to lib/kube/token (#49554)
* Rename lib/kubernetestoken to lib/kube/token

* Lint
2024-12-04 22:39:55 +00:00
Edoardo Spadolini bcbfa8192e Get rid of math/rand in favor of math/rand/v2 (#49294)
* Get rid of math/rand in favor of math/rand/v2

* Update retryutils to use rand.N

* Update e ref
2024-11-21 12:57:32 +00:00
Zac Bergquist c7765fa7f1 Fix incorrect usages of "it's" (#48252) 2024-10-31 23:35:30 +00:00
Nic Klaassen 0a0d4137db eliminate rsa.GenerateKey and lib/auth/native (#47768) 2024-10-21 20:55:22 +00:00
Zac Bergquist 2b778a988a Fix plugin builds (#47172)
Plugins build without CGo, so they can't import (directly or indirectly)
any packages that require CGo.

In #47045 we added a lib/config import to pull in a constant, which
added a large dependency tree that included CGo dependencies.

Fix the builds by duplicating the constant and avoiding the import.
2024-10-03 22:34:57 +00:00
Hugo Shaka fd7030ac1a Migrate access/msteams to slog + add debug logs (#47045)
* Migrate access/msteams to slog + add debug logs

* fixup! Migrate access/msteams to slog + add debug logs

* Apply suggestions from code review

* Address timr's feedback

* fixup! Address timr's feedback

* tidy go mod
2024-10-03 19:23:55 +00:00
Zac Bergquist c17fb38ea3 Simplify integrations/lib/backoff (#47099)
- move test-only code to a _test.go file
- consolidate code to fewer files
2024-10-02 20:33:57 +00:00
Zac Bergquist a22d000c0e integrations: remove dead code (#47101) 2024-10-02 17:35:51 +00:00
Zac Bergquist ec3e48bec4 all: use package filepath for file paths (#47061)
Some day Teleport will run on systems that don't use / as a path
separator.
2024-10-01 21:49:43 +00:00
Nic KlaassenandBernard Kim eff0a707d7 split SSH and TLS keys in tsh login (#45995)
* key split wip

* fix piv tests

* fix terraform tests

* spelling fixes

* fix kube benchmark

* fix identity files in integrations tests

* self review

* fix typo in comment

Co-authored-by: Bernard Kim <bernard@goteleport.com>

* speed up device login tests

* use EC keys in TestProxyAppWithIdentity

* faster tsh tests

* fix race on error value

* fix lint

* write out EC SSH keys in OpenSSH format

* fix lint

* fix keyring comparisons

* PrecomputeTestKeys in lib/client

* parallelize TestNoRelogin subtests

* use ecdsa for self-signed TLS certs

* remove redundant GetTrustedCerts

* improve latency of precomputeTestKeys

Instead of waiting for all 25 test keys before returning a single one,
tests can now make use of the first precomputed test key as soon as it's
ready.
In local testing with this change, the first key is ready after ~75ms vs
>350ms on master.

* fix test and lint

---------

Co-authored-by: Bernard Kim <bernard@goteleport.com>
2024-09-12 19:36:32 +00:00
Bernard Kim 233ee5216a Slack plugin now lists logins permitted by requested role (#45392)
* Include logins

* Add unit tests

* Handle access denied gracefully

* Update documentation with required permissions

* Reduce doc

* Address feedback

* Imported twice

* Improve loggin; Replace none -> -
2024-08-19 16:49:47 +00:00
rosstimothy 514c4cfede Add ability to capture pprof profiles to the event-handler (#44738)
SIGUSR1 can now be used to trigger capturing various pprof profiles
from any integrations that opt in to providing the support. At the
moment only the event-handler implements handling the signal. It
stores all profiles under `<storage_dir>/profiles`.
2024-07-29 17:04:58 +00:00
Hugo Shaka 4003f79726 Add Terraform Provider native MachineID support (#44306)
* Add Terraform Provider native MachineID support

* Reject 'token' join method

* lint: fix imports

* re-render TF docs

* fix tests + add license

* lint
2024-07-26 14:52:14 +00:00
Edward DowlingandMarco Dinis 66994d88ac Prevent AMRs being watched if access monitoring is not enabled (#43714)
* Prevent AMRs being watched if access monitoring is not enabled

* Log and ignore AMRs if cache initialisation fails

* Update integrations/access/accessrequest/app.go

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>

* Use allowPartialSuccess when watching over changing watch kinds

* Add ability to get confirmed watch kinds from watch job

* Add test coverage for newJobWithConfirmedWatchKinds

* Swap watcher accepted kinds logic to use callback instead of channel

* Update test for watcherjob

* Add check for unset init callback to watcherjob

* Remove unneeded retry utility

* Remove unused import

* Remove retry logic from watcherjob tests

* Fix linting

* Add clarifying comments and better error message

* Remove unused import

---------

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>
2024-07-19 16:42:24 +00:00
Hugo Shaka 26f9b77948 Support detecting a credential expiry (#43886)
* Support detecting a credential expiry

* Fix Expiry() and add tests

* protect identityFile cred with a lock

* add godoc

* Fix tests
2024-07-11 02:57:14 +00:00
Hugo ShakaandMarco Dinis a9b37a52fb Add fakejoin.KubernetesSigner test helper (#43857)
* Add fakejoin.KubernetesSigner test helper

* fixup! Add fakejoin.KubernetesSigner test helper

* rename file

* Update integrations/lib/testing/fakejoin/kubesigner.go

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>

* Lint

---------

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>
2024-07-05 15:19:13 +00:00
Noah Stride 5debbd1c03 Start migrating Kubernetes output to Kubernetes service (#43685) 2024-07-05 13:57:04 +00:00
Hugo Shaka c1becbe0b1 Move embedded tbot out of the operator for resue by other integrations (#43854) 2024-07-04 15:17:57 +00:00
rosstimothy e660877fcb Remove direct dependency on github.com/hashicorp/go-version (#43735)
Teleport had 3 dependencies to parse semantic versions:
- golang.org/x/mod/semver
- github.com/coreos/go-semver/semver
- github.com/hashicorp/go-version

The last of the three was only used in `integrations/lib.AssertServerVersion`
which was a clone of `lib/utils.CheckVersion`. By converting all
code in integrations to use `lib/utils.CheckVersion` the direct
dependency on github.com/hashicorp/go-version can be dropped. The
depguard rules have also been updated to prevent it from sneaking
back into the dependency tree. A follow up change will further
consolidate semver dependencies to a single package.
2024-07-02 13:09:13 +00:00
Tiago Silva bdb5d1a2a1 chore: chore: Bump golangci-lint to v1.59.1 (#42049)
Update to the latest release.

* https://github.com/golangci/golangci-lint/releases/tag/v1.59.1
* https://github.com/golangci/golangci-lint/releases/tag/v1.59.0
* https://github.com/golangci/golangci-lint/releases/tag/v1.58.2

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2024-06-10 14:13:18 +00:00
94332f34e9 Add initial condition parser for access monitoring rules (#40659)
* Add initial condition parser for access monitoring rules

* Update integrations/access/accessrequest/app.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

* Check previously unchecked error and minor refactor of AMR

* Simplify check for applicable access monitoring rules

* Refactor access monitoring rules plugin integration

* Fix formating and move lock aquisition

* Add methods for listing access monitoring rules with a filter

* Add contains_any predicate expression func

* Add in is_empty func to predicate expression

* Lock AMR cache in plugins while getting initial rules

* Add in check for access monitoring rule version

* Update integrations/access/accessrequest/app.go

Co-authored-by: Roman Tkachenko <roman@goteleport.com>

* Update integrations/access/accessrequest/app.go

Co-authored-by: Roman Tkachenko <roman@goteleport.com>

* Move lock so it doesnt persist over api calls

* Remove unused constant and add more context to logs

* Appease linter

* Update access monitoring rules tests to pass rule validation

* Add in missing access monitoring rules list with filter code

* Appease linter

* Add back validation code for AMRs

* Fix test plugin role and rename listaccessmonitoringrulewithfilter

* Fix local test for AMR crud operations

* Fix end range for listing rules

* Fix unwrapping of resource153 event for monitoring rules

* Refactor AMR cache init into helper function in plugin app

* Add seperate response type for listAccessMonitoringRulesWithfilter

* Add context to log for plugins failing to fetch recipients

* Grab access monitoring rules cache under lock all at once

* Add clarification for which fields are optional in listAMRfilter req

* Update integrations/access/accessrequest/app.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

* Update integrations/access/accessrequest/app.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

* Add forEach to common recipient set

* Move type check to after AMR event op switch

* Move turn some default parser spec methods to funcs

* Make some predicate func usable as methods as well

* Add len func to common recipient sets

* Add integration test for access monitoring rule and slack plugin

* Fix error types and messages when handling AMRs

* Use generic list resource with filter for AMR

* Add test for generic listResourceWithFilter

* Update listResourceWithFilter to use revision instead of id

* Update generic tests to use revision instead of id

* Fix linting

---------

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2024-05-24 18:45:13 +00:00
Hugo Shaka 90392ca700 Make access plugin tests work with mandatory 2fa (#41412)
* Make access plugin tests work with mandatory 2fa

* fix Access List reminder tests

* lint
2024-05-10 15:13:42 +00:00
Zac Bergquist 8cd1c429f5 Fix up some poor wording (#40832)
Closes #40294
Closes #39172
2024-04-23 22:01:41 +00:00
Hugo Shaka a24216e166 Prepare teleport access plugin enterprise test suite (#40479)
* Make AuthHelper support enterprise

* Split access OSS and Enterprise tets suites

* fix slack tests

* fix race in accesslist reminder tests

* fixup! fix race in accesslist reminder tests
2024-04-11 21:37:11 +00:00
Hugo Shaka b5270e12cd remove unused tests (#40429) 2024-04-10 18:15:43 +00:00
Hugo Shaka 7e9ff5acc2 Vendor teleport-event-handler (#40364)
* Vendor event-forwarder plugin

* fix tests + add Makefile + CI

* lint

* Fix broken test

* use a separate go.mod

* ignore event-handler in flaky tests + update go.mod

* go mod tidy
2024-04-10 15:46:14 +00:00
Hugo Shaka d83cfd154c Copy Terraform provider from teleport-plugins repo (#40224)
* copy terraform provider

* Make dependecy checker happy + use go 1.22

* Run terraform tests in the CI, add Makefile target

* go mod tidy
2024-04-10 05:11:58 +00:00
Hugo ShakaandMarco André Dinis 10a6cbb9d7 Ensure watcherjob always returns an error (#39581)
* Ensure watcherjob always returns an error

* Apply suggestions from code review

Co-authored-by: Marco André Dinis <marco.dinis@goteleport.com>

* make testlib tolerate 'context cancelled' errors

* fixup! make testlib tolerate 'context cancelled' errors

* fixup! fixup! make testlib tolerate 'context cancelled' errors

---------

Co-authored-by: Marco André Dinis <marco.dinis@goteleport.com>
2024-03-25 14:42:17 +00:00
rosstimothy e5d965e9c2 Fix integrations ssh service tests (#39543)
Similar to https://github.com/gravitational/teleport/pull/39315,
this updates the integrations test suite to use a regular
expression that will match output to know when the ssh_service is
ready now that Teleport is using slog instead of logrus.
2024-03-19 12:13:07 +00:00
rosstimothy df76ec95cd Bump github.com/gravitational/trace from 1.3.1 to 1.4.0 (#39292)
* Bump github.com/gravitational/trace from 1.3.1 to 1.4.0

## Changelog
- Bump google.golang.org/grpc from 1.43.0 to 1.53.0 by @dependabot in #94
- Bump golang.org/x/net from 0.8.0 to 0.17.0 by @dependabot in #100
- Bump google.golang.org/grpc from 1.53.0 to 1.56.3 by @dependabot in #101
- Bump golang.org/x/crypto from 0.14.0 to 0.17.0 by @dependabot in #105

## Breaking Changes
- Remove logrus dependency by @rosstimothy in #107
- Remove references to UDP logrus hook from README by @rosstimothy in #108

Full Changelog: https://github.com/gravitational/trace/compare/v1.3.1...v1.4.0

* remove final references to removed trace functionality

* fix: formatter error handling
2024-03-15 19:51:53 +00:00
rosstimothy 572b64480f Fix integrations tests (#39315)
The change to migrate the TeleportProcess to use slog in
https://github.com/gravitational/teleport/pull/38551 was preventing
the regular expressions used by the operator tests to determine
when auth and proxy were ready. This lead to the tests hanging indefinitely
until the go test framework timed out. To remediate, the regular
expressions have been updated to match the output when using slog.

For example, the test was expecting the output in the format of:

```
Auth service 15.0.0:v15.0.0-0-ge126e8cd is starting on 192.168.50.108:3025. pid:61933.1 service/service.go:2072
```

#38551 moved the listen address to a field instead of being formatted
in the message:

```
Auth service is starting. pid:54159.1 version:16.0.0-dev git_ref:api/v13.4.16-31-g2b9ae35e31 listen_address:127.0.0.1:63152 service/service.go:2107
```
2024-03-13 23:58:12 +00:00
Hugo Shaka 21eac0672d Migrate jira access plugin tests (#38406)
* Migrate jira access plugin tests

* grant the access_request.update permission

* lint

* license
2024-02-20 21:14:44 +00:00
Hugo Shaka e056d00a61 Plugin integration tests: add oss auth helper (#38237)
* Plugin integration tests: add oss auth helper

* address feedback

* lint
2024-02-15 19:15:08 +00:00
Hugo Shaka 262757af74 Introduce new plugin integration helpers (#38175)
* plugin testing framework

* godocs

* lint

* license

* fix oss tests

* revert timer change causing flaky tests

* fix oss tests pt.2
2024-02-14 18:27:54 +00:00
rosstimothy b7318b5c7e Enable errorlint via golangci-lint (#37669)
Adds the new linter and configures it to prevent direct error
comparisions and type assertions in favor of errors.Is and errors.As.
All current violations caught by the linter have been updated
accordingly.
2024-02-02 15:59:24 +00:00
fheinecke b178b8b732 Updated Teleport codebase to AGPL3 license (#35259)
Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>
2023-12-01 17:48:14 +00:00
Noah Stride 634de05c42 Remove Dialer(client.Config) from Credential interface (#34833)
* Remove `Dialer(client.Config)` from Credential interface

* Re-add support for address-less configuration

* Only use profile address if none are explicitly provided

* Try all methods with credential provided address

* Fall back to address from credential

* Remove log message

* Adjust log message

* Spell explicitly correctly

* Formalize CredentialsWithDefaultAddrs interface

* GetDefaultAddrs -> DefaultAddrs
2023-11-29 08:43:07 +00:00
Michael Wilson 30490419f7 Introduce scaffolding for access list Slack notification. (#33415)
* Introduce scaffolding for access list Slack notification.

The initial scaffolding for notification of the need for reviews for access
lists has been introduced. This is not expected to do anything just yet, but
will do so in a follow on PR.

This has additionally separated the plugin data from the dynamic access core,
as it no longer is tightly coupled to access requests. No effort was made to
refactor the existing plugin data backend logic.

* Ensure that the context is cancelled on process termination.

* Remove debug hour addition.

* Correct notification date calcs, add test for notifications.

* Expire the access list after two weeks, use a single map instead of multiple plugin data keys.

* Run GCI.

* Tune tests, retry period is now a duration.

* Get rid of gocron, use intervals, test using intervals.

* GCI.

* Renames, test tweaks.

* Refactor access plugins.

* GCI.

* Adjust tests, remove generics, plugin data uses JSON marshal instead of custom marshaling.

* Move recipient back to common.

* Missed a few recipients imports.

* Tweaks to logic, auto registration of apps, commenting and cleanup.
2023-11-09 17:14:20 +00:00
rosstimothy d5a796c056 Enable testify lint (#34222)
Updates our golangci-lint configuration to enable testifylint and
fixes all issues found.

Bump e ref to include gravitational/teleport.e#2567
2023-11-06 20:38:38 +00:00
Noah Stride 516e15db56 Access Plugins: Support dynamic credential reloading (#32974)
* Refactor client creation in access plugins

* Remove unnecessary client creation

* Remove unused constant

* Fix imports

* Add dynamic watcher mode

* Export NewIdentityFileWatcher

* Add godoc for exported func

* Americanize Speling

* Change username used by dynamic ssh credentials
2023-11-01 16:53:36 +00:00
Edward Dowling 439e5dcdca Add suggested reviewers as assingee to servicenow incidents (#33704)
* Add suggested reviewers as assingee to servicenow incidents

* Fix suggested reviewers encoding

* Update comment for serviceno assigned_to field
2023-10-23 16:37:52 +00:00
Andrew Burke c4b2861f70 Show resources in Slack notification for access requests (#32887)
This change updates Slack notifications for resource-based access
requests to include the resources being requested.
2023-10-10 21:01:32 +00:00