Commit Graph
756 Commits
Author SHA1 Message Date
rosstimothy e95f3d3ed5 Start using authclient.Client/ClientI/NewClient (#41539)
Consumes the new auth client created in #41460. The changes introduced
were performed with a series of gofmt rewrite rules.

```bash
$ find ./lib/auth -type f -name '*.go' -exec gofmt -w -l -r "ClientI -> authclient.ClientI" {} \;
$ find ./lib/auth -type f -name '*.go' -exec gofmt -w -l -r "Client -> authclient.Client" {} \;
$ find ./lib/auth -type f -name '*.go' -exec gofmt -w -l -r "NewClient -> authclient.NewClientI" {} \;
$ find . -type f -name '*.go' -exec gofmt -w -l -r "auth.ClientI -> authclient.ClientI" {} \;
$ find . -type f -name '*.go' -exec gofmt -w -l -r "auth.Client -> authclient.Client" {} \;
$ find . -type f -name '*.go' -exec gofmt -w -l -r "auth.NewClient -> authclient.NewClient" {} \;
```
2024-05-15 14:09:14 +00:00
Edoardo Spadolini 33e80cd8f2 Support dynamic SSH host signers (#41227)
* Add a host signers callback to sshutils.Server

* Lift host signers callback into regular.Server

* Lift host signers callback into reversetunnel.Server
2024-05-13 13:11:44 +00:00
39478f3570 Add backend handler for Web UI kube exec functionality. (#41144)
* Add backend handler for Web UI kube exec functionality.

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

* Log error on sending it to websockete connection.

* Remove duplicate user key creation.

* Use scoped context.

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

* Use local site cache.

* Simplify creating rest kube rest config.

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>

* Don't set stdErr on pod execution options, if it's interactive shell.

* Don't use public proxy addr when getting kubeconfig server address/name.

* Don't set stdErr on stream options if it's interactive shell.

* Provide local host CA to podHandler directly, instead of access point.

* Add integration test for kube exec handler.

* Use read deadline instead of closing reader.

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
2024-05-10 19:10:57 +00:00
Alex McGrath 65459e872e Remove support for disabling second factor authentication (#40956)
* dont allow disabling second factor

* update docs for 2fa change

* add environmental variable to work around disabled 2fa

* check if its cloud

* update todos

* add a test

* introduce insecure test mode

* fixes for tests
2024-05-10 11:57:34 +00:00
Brian Joerger 8c328a880b MFA for App Access - tsh proxy app and Teleport Connect (#40857)
* Add key.DBTLSCert and key.AppTLSCert helper methods.

* Add TSH_APP_LOCAL_PROXY user certs requester option.

* Break up app login into multiple methods.

* Generalize cert checker local proxy middleware and add an app cert implementation.

* Use AppCertChecker for tsh proxy app.

* Add test check for proxy mfa certs being kept off disk.

* Apply changes to Teleport Connect.

* Addressed bl-nero's comments.

* Address comments from ravicious.

* Add proxy app cert ttl test.

* Restore v15 fallback for tsh proxy app session creation; Minor naming refactors.

* Add cluster flag to app logout.

* Refactor teleterm test to cleanup session MFA requirement.

* Address comments.
2024-05-06 19:29:53 +00:00
Justinas Stankevičius 68886bb8ef Entra ID integration boilerplate (#40998)
* Add e imports for MS Graph SDK

* Add ability to sign Entra ID OIDC JWTs, rework KID handling

- Synthesize Key IDs for our JWT keys. For backwards compatibility, also
  include the same keys with an empty `kid` in JWKS.
- Sign AWS OIDC tokens with a `kid=""` header claim,
  rather than omitting the `kid` claim altogether.
  See comment for details.

* Add validation for Entra ID plugin

* Fix typo in assertion function name

* Update the OIDC JWKS test to expect the same key twice

* Add Entra ID plugin type constant

* go mod tidy

* Fix expected JWKS size in integration test

* Add basic tests for KeyID

* Move Azure auth settings from Plugin to Integration

* Address review comments

* Add a unit test to ensure KeyID compatibility

* Add license header to token_generator.go

* Rename validation function per new conventions
2024-05-02 13:44:32 +00:00
Brian Joerger ce242ae40d Support agentless connections with hardware key support (#39267) 2024-04-25 22:45:00 +00:00
Jakub Nyckowski 987995de4e Remove Assist command execution and chat feature (#40806)
* Remove Assist command execution and chat feature

The changes remove tests and related code for command execution in the assist package and web command handling.

* Remove Teleport Assist chat from CHANGELOG.md

The changes in this commit reflect the removal of the Teleport Assist chat from the CHANGELOG documentation of Teleport version 16. The Assist feature continues to be available in the SSH Web Terminal and Audit Monitoring.

* Remove assist chat from the test plan
2024-04-25 18:08:07 +00:00
Brian Joerger 12c7689df5 Refactor GenerateUserCerts to create App Sessions (#39970)
* Add CreateAppSessionFromReq.

* Deprecate passing route_to_app.session_id in cert requests.

* Automatically create app sessions for app cert requests.

* Deprecate client use of CreateAppSession for app cert requests.

* Fix affected tests.

* Use traits and roles from existing user certificate for app sessions.

* Fix app access integration tests.

* go mod tidy.

* Fix TestTCP.

* Fix TestALPNSNIProxyAppAccess.

* Revert "go mod tidy."

This reverts commit cc6caa2485.
2024-04-25 05:13:55 +00:00
Andrew LeFevre d4c706a471 fix kube ephemeral container test flakiness (#40871) 2024-04-25 03:55:42 +00:00
Zac Bergquist 8cd1c429f5 Fix up some poor wording (#40832)
Closes #40294
Closes #39172
2024-04-23 22:01:41 +00:00
rosstimothy d0b8f78c3f Remove client.ProxyClient (#40565)
Closes #38239
2024-04-23 18:30:09 +00:00
Andrew LeFevreandTiago Silva ebee592033 fix k8s moderated sessions bypass with ephemeral containers (#40792)
* rebase with master

* only retrieve logs on a specific error

* fix cache test again and a linter issue

* only look for ephemeral container name when waiting for the container to start

* address feedback

* add support for other merge strategies

* handle case

* reorganize gomod

* address feedback

* fix missing patchtype

* propagate errors

* Update lib/kube/proxy/sess.go

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>

* add hint of exec process into session tracker

* address feedback

* optionally filter listed waiting conts server-side

* add TODO to test against tsh kubectl

* Revert "optionally filter listed waiting conts server-side"

This reverts commit 9a33868363e427f52bba8d95ead2bfc0d939e6e7.

* fix failing integration test, undo accidental dep update

---------

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
2024-04-23 16:55:56 +00:00
rosstimothy 29430d699f Migrate Connect to use client.ClusterClient instead of client.ProxyClient (#40562)
Updates #38239.
2024-04-23 13:39:06 +00:00
Isaiah Becker-Mayer b878fd077d Cleanup regular.Server (#40723)
* remove unused default shell setting

* remove unused nodeWatcher

* remove unused caGetter

* cosmetic
2024-04-22 21:17:10 +00:00
Edoardo Spadolini d044e4a39c Disable resumption in TestIntegrations/Shutdown/cli_sessions (#40732) 2024-04-22 09:11:56 +00:00
Nic Klaassenandrosstimothy 680ac535ce fix: return OpaqueAccessDenied for NotFound remote cluster errors (#40571)
* fix: return OpaqueAccessDenied for NotFound errors

This commit modifies OpaqueAccessDenied to return an identical generic
NotFound error whether the input error is NotFound or AccessDenied.
The commit also updates all call sites of OpaqueAccessDenied to use it in
the paths where there is any error fetching the resource as well as when
access is denied.

It doesn't do much good to return AccessDenied errors as NotFound, if
they don't match the NotFound error you would get if the resource really
didn't exist.
It's trivial to tell the errors apart and discover the existence of a
resource you shouldn't be allowed to access.
The commit attempts to mitigate that issue and properly hide the
existence of resources the user should not be allowed to list.

* remove changes unrelated to remote clusters

* improve doc comment

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

* make sure gRPC errors match

* fix integration test

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2024-04-18 19:01:01 +00:00
Noah Stride 955f86ba3e Thread context.Context through auth.Register and add OTel Tracing (#40597)
* Wire context.Context into `auth/register.go`

* Thread `context.Context` through `auth.Register` and add tracing

* Unwrap error before recording it in the span
2024-04-17 17:19:07 +00:00
Brian JoergerandRafał Cieślak 1868f51186 MFA for App access (WebUI) (#40077)
* Implement web isMFARequired for App access.

Pass mfa challenge response in web createAppSession request.

* Update web/packages/teleport/src/services/apps/apps.ts

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
2024-04-15 17:40:20 +00:00
rosstimothy 5a64d1fb8d Convert tsh recursive listing to connect to Proxy via gRPC (#40268)
* Convert recursive listing to use Proxy gRPC API

Removes deprecated usage of ProxyClient in getClusterClients used
for tsh ls -R and tsh db ls -R.

* Remove unsued helper functions

* Replace removed test

* Remove unused db listing function

* convert tsh apps ls -R and tsh kube ls -R

* remove unused function and tweak IsExpired

* create common testcase for listing resources
2024-04-12 20:19:11 +00:00
Bartosz Leper 06fce3f449 Keep track of whether the user has a real password set (#39576)
* Keep track of whether the user has a real password set

* lint

* Some comments

* Fix TestCreateResources

* Fix e/ link

* Review

* Review

* Review

* Use early return on error in DeletePassword

* Fix the broken teleterm test
2024-04-10 10:28:05 +00:00
rosstimothy ad26913c71 Load appropriate TLS config for clusters (#40293)
Updates the proxy.Client to allow loading specific tls.Config for
individual clusters. This prevents issues when trying to access
leaf resources via the root cluster if WithAllCAs is not set.
2024-04-09 16:02:28 +00:00
Marco André Dinis 31e56026f0 AWS OIDC set up: S3 is optional (#39912)
* AWS OIDC set up: support set up that doesnt use S3 location

* be explicit about always having the public keys being served at the proxy
2024-04-03 10:55:49 +00:00
Rafał Cieślak 584fd5def7 Use dbcmd.WithPrintFormat only for preview of teleterm gateway command (#39906)
* Use dbcmd.WithPrintFormat only for preview of teleterm gateway command

* Update comments for GatewayCLICommand message

* Mark check funcs as helpers, verify args length first
2024-03-29 15:35:52 +00:00
Grzegorz ZdunekandRafał Cieślak 6b791738f4 Use Daemon.ResolveClusterURI instead of Storage.ResolveCluster to set a cluster in the cache (#39732)
* Use `Daemon.ResolveClusterURI` instead of `Storage.ResolveCluster` to set a cluster in the cache

* Fix tests in `daemon_test.go`

* Add regression test

This test fails on master but not on this branch. It's largely based
on existing MFA tests that we have in integration/proxy/teleterm_test.go.

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
2024-03-22 17:16:22 +00:00
Brian Joerger b88251a278 CreateAppSession with MFA (#39650)
* Replace types.CreateAppSessionRequest with proto.CreateAppSessionRequest.

* Add MFA response proto.CreateAppSessionRequest.

* Verify MFA response in CreateAppSession.
2024-03-21 17:18:08 +00:00
Andrew LeFevre 5eaae8b200 ignore SSH keepalive requests in SFTP moderated sessions integration test (#39436)
* ignore SSH keepalive requests in SFTP moderated sessions integration test

* fix misspelling
2024-03-16 00:19:03 +00:00
Andrew Burke cc013e69a4 Add -R flag to tsh ssh (#38829) 2024-03-15 23:23:10 +00:00
rosstimothy 9734fcbdbd Convert SetSessionRecordingConfig usages to new Create/Update/Upsert API (#39249)
Migrates callers off the deprecated API and onto the new API so
that SessionRecordingConfig can be protected via optimistic locking
when appropriate.
2024-03-15 19:55:57 +00:00
Rafał Cieślak c7682b0004 Disable client cache in teleterm local proxy integration tests (#39417)
* Cast logged URIs to strings

* Remove unnecessary client.Close()

addToCache is called only if c.clients[clusterURI] returns nil.
Get calls getFromCache and returns early if there's a client in the cache
already.

* Disable client cache in teleterm local proxy integration tests
2024-03-15 19:37:37 +00:00
Marco André Dinis a0068878de AWS OIDC: Accept custom issuers (#38785)
* AWS OIDC: Accept custom issuers

This PR adds a new field into the AWS OIDC fields:
- issuer

This is the issuer that was configured in AWS.
It is used by teleport to set the `issuer/iss` field when generating the
JWT.
This way we'll be able to set a custom issuer.
As an example, we could set this to be a public S3 bucket which doesn't
suffer from the thumbprint validation issuer.

* ensure issuer is a valid https url

* use s3 uri instead of any url for issuer

* typo and require s3 fields

* add missing s3 location when creating integration

* improve error messages
2024-03-15 18:08:35 +00:00
rosstimothy 20888bf130 Convert SetAuthPreferences usages to new Create/Update/Upsert API (#38895)
Migrates callers off the deprecated API and onto the new API so that
AuthPreferences can be protected via optimistic locking when appropriate.
2024-03-14 22:05:20 +00:00
Reed Loden 23c67d4c16 Re-enable AWS IMDSv1 fallback (#39363)
It was discovered that some customers' EKS clusters did not have their IMDSv2 hop limits
set correctly, causing requests for key functionality to attempt IMDSv1 fallback and failing.

For now, re-enable IMDSv1 fallback by way of removing the explicit disabling of
`EC2MetadataEnableFallback` until better documentation, error handling, and other work
can be done to inform customers that they need to correctly set their IMDSv2 hop limits.
2024-03-14 18:12:50 +00:00
Andrew LeFevre 30400231de ensure moderated file transfers only perform allowed operations (#39091)
* ensure moderated file transfers only preform allowed operations

* fix sess test

* wip integration test

* integration test working

* tweak some error messages and test cases

* allow setstat for uploads

* address nits from code review

* expand paths when necessary when creating file transfer request

* improve UX of errors in web UI

* deny request when an invalid user tries to transfer files

* don't allow open requests, they aren't done by the webui

* address feedback

* use a buffered reader when reading the file request, address a few nits
2024-03-14 00:10:48 +00:00
rosstimothy bd74399655 Attempt to make TestClientIdleConnection more reliable (#38849)
Increases the duration of the test to allow for more time to
process events and disables session resumption.
2024-03-13 20:17:44 +00:00
Brian Joergerandrosstimothy 02d287808f Fix TestIntegration/X11Forwarding (#39282)
* Fix EventuallyWithT call.

* 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>
2024-03-13 18:16:05 +00:00
Brian Joerger 387dd90cd4 Add write retry in addition to the read retry for x11 display test. (#39271) 2024-03-12 23:08:16 +00:00
Brian Joerger 6cd713f667 Fix ssh -X -oControlMaster to agentless nodes. (#38779)
* Fix X11 forwarding with OpenSSH option control master when connecting through the Proxy ssh forwarding service.

* Add X11Forwarding integration test with ControlMaster subtest.

* Refactor forwarding server to always forward x11 channel requests.

* Address comments.

* Fix x11 forwarding integration tests.
2024-03-12 17:45:54 +00:00
5dcb16214f Updates the Path variables in tests to use the new-style websocket endpoints (#38130)
* Updates the Path variables in tests to use the new-style websocket endpoints

These were missed in the initial PR: https://github.com/gravitational/teleport/pull/37520

* send auth requests over websocket in updated tests

* Fix web shutdown integraiton test

---------

Co-authored-by: Alex McGrath <alex.mcgrath@goteleport.com>
Co-authored-by: Steam Deck User <deck@steamdeck.lan>
2024-03-12 16:09:53 +00:00
Hugo ShakaandNoah Stride 1bdb045a12 Enable automatic upgrade server by default (#38937)
* Enable automatic upgrade server by default

This commit means the proxy now serves automatic upgrade channels by
default. The default channel is "default" and its version is the
teleport proxy binary version.

This commit also fixes a bug with the automatic update version server
returning `teleport.Version` instead of `"v"+teleport.Version` when the
version was too high. This was not a critical issue because agents are
supposed to tolerate versions not prefixed with 'v'.

* lint

* thread safety

* Update lib/automaticupgrades/channel.go

* Update lib/config/configuration.go

Co-authored-by: Noah Stride <noah.stride@goteleport.com>

* fix tests and lint

---------

Co-authored-by: Noah Stride <noah.stride@goteleport.com>
2024-03-05 23:28:40 +00:00
Noah StrideandEdoardo Spadolini c11bddc5f2 Refactor Presence service to add ListRemoteClusters, context.Context and returning updated/created RemoteClusters (#38694)
* Wire context/returning through local svc and add ListRemoteCluster

* Propagate changes through to cache

* Propagate changes up

* Remove marshal options from GetRemoteCluster

* Fix tests in lib/services/local

* Fix tests

* Add test for PresenceService_ListRemoteClusters

* Add removal TODO

* Add retry to UpdateRemoteCluster

* Fix more tests

* Fix linting

* Remove unused Create and DeleteAll RPCs

* Fix test

* Add GetAndUpdateRemoteCluster

* Add test for GetAndUpdateRemoteCluster

* Update lib/services/local/presence.go

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Update lib/services/local/presence.go

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Update lib/services/local/presence.go

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Rename GetAndUpdate to Patch

* Exit early if we know conditional update will fail

* prevent modifying revision

* Update tests

* Add `clear()`

* Fix test/lint failures

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2024-03-05 15:56:00 +00:00
Grzegorz Zdunek 7067a88537 Temporarily disable flaky part of TestClientCache (#38798) 2024-02-29 18:44:38 +00:00
Gabriel CoradoandAlan Parra 89d1aa460d Use time-based event index for app session events (#38495)
* feat(events): add event indexer based on time

* chore(events): code review changes

* chore: typos

* Apply suggestions from code review

Co-authored-by: Alan Parra <alan.parra@goteleport.com>

* chore: code review changes

* test(integration): ignore index field on audit events

---------

Co-authored-by: Alan Parra <alan.parra@goteleport.com>
2024-02-29 03:14:43 +00:00
Grzegorz Zdunek 39f9951118 Cache remote clients in Connect (#38201)
* Add remote client cache

* Add an integration test

* Close all clients when stopping the service

* Move RemoteClientCache to the place where it is used

* Do not check client cert in `Get`

* Fix code style issues

* Prevent potential race condition when removing a cached client

* Test concurrent calls to `Get`

* Add TODO

* `remoteclientcache` -> `clientcache`

* Reduce the `err` scope

* Move `Config` closer to `New` and docs

* Fix lint

* Improve logging and error handling

* Add missing comments

* `Close` -> `Clear`

* Improve the test

* Remove mentions about "remote" client

* Pass `cfg` directly to `Cache`

* `InvalidateForRootCluster` -> `ClearForRootCluster`

* Add docs for the interface

* `ClearForRootCluster` -> `ClearForRoot`

* Add config validation

* Log multiple fields at once

* Improve setting logger

* Use cached remote clients in Connect (#38202)

* Replace all simple `c.clusterClient.ConnectToProxy()` calls

* Use cached proxy client to create gateways

* Use cached proxy client to assume roles

* Invalidate clients when logging in and out

* Gracefully handle expired cert error returned by the server

* Drop `GetRootClusterURI` in headless auth watcher since URIs are already root URIs

* Simplify error check

* Make `auth.ClientI` parameter naming more consistent, use `root` prefix when needed

* Reduce error scope where possible

* Clear cached clients before passwordless login

* Use `fakeClientCache` without pointers

* Move separate `proxyClient` parameter to `CreateGatewayParams` in the gateways code

* Replace checking error string with `client.ErrClientCredentialsHaveExpired`
2024-02-28 07:53:36 +00:00
Edoardo Spadolini 8b9387b8fe Bump timeout in WaitForActiveTunnelConnections (#38582) 2024-02-23 22:30:53 +00:00
rosstimothy 76b1f4ebef Perform server version validation before using clients (#38016)
Agents performed the following steps when creating an auth client:

1) Create an auth gRPC client
2) Call proto.AuthService/GetDomainName to force gRPC to dial the
   auth server in order to validate the connection since gRPC only
   dials on the first RPC
3) Call proto.AuthService/GetCertAuthority to get the HostCA
4) Call proto.AuthService/Ping to get the server version to determine
   if the connection should be aborted unless --skip-version-check
   was provided

On the surface this seems fine, however, the skip version check
did not happen until after two RPCs to auth had already been issued.
If either of those RPCs has changed the agent could perpetually fail
to connect to the cluster even though it should have never tried
due to version differences.

The order of the steps was changed to the following such that the
version check happens first.

1) Create an auth gRPC client
2) Call proto.AuthService/Ping to force gRPC to dial AND to get the
   server version information
3) Run the server version check and abort unless --skip-version-check
   was provided
4) Call proto.AuthService/GetCertAuthority to get the HostCA

An added benefit to this is agents now require one less RPC when
joining.
2024-02-20 21:09:16 +00:00
rosstimothy a3d65adb62 Deprecate (TeleportClient) ConnectToProxy (#38219)
This legacy connection mechanism uses SSH to connect to the Proxy
and tunnel the Auth connection. It was replaced by the
(TeleportClient) ConnectToCluster which uses gRPC to reduce latency
when connecting to the cluster.
2024-02-15 16:48:59 +00:00
STeve (Xin) Huang e192ad386e Propagate user-agent from GRPC for cert.create events (#37726)
* Add user-agent to cert.create event

* fix tctl and minor stuff

* fix integration test
2024-02-08 20:39:43 +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
Anton Miniailoandrosstimothy a576cb2a91 Remove assigning by default first alphabetical kube cluster to a user. (#37242)
* Remove assigning by default first alphabetical kube cluster to a user.

* Fix tests.

* Address review comments

* Fix tests.

* Fix error message.

* Use default value.

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

* Fix error message.

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

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2024-01-29 22:47:34 +00:00