Commit Graph
117 Commits
Author SHA1 Message Date
Brian Joerger 58f71101d8 feat: Hardware Key Agent - Add api/utils/keys/hardwarekey package (#53671)
* Move hardware key files into new hardwarekey package.

* Tidy up PIVSlot logic and remove its piv-go dependency.

* Add godoc comments to cliPrompt methods; Update cliprompt.go license year.

* Add godocs.
2025-04-07 19:31:11 +00:00
Gavin Frazar b69d49b2a2 Simplify lib/utils/aws (#51627)
This eliminates the SigningService in favor of a free function
SignRequest, which eliminates AWS credential loading and simplifies the
AWS utils package.
In the process of doing this refactor, the AWS app handler has been
changed to use AWS SDK v2 to load its credentials as well.
2025-01-30 20:14:45 +00:00
Zac Bergquist d71293f964 Replace usages of x/exp/maps with stdlib maps package (#51448) 2025-01-28 14:54:40 +00:00
Grzegorz Zdunek e4e09a11a0 Reissue kube certs when assuming access request (#50553)
* Reissue kube certs when assuming access request

* Fix and add tests

* Explain when the cert can be not found

* Replace `clearCertsFn` with `middleware` field

* Improve iterating over gateways

* Improve a comment
2025-01-14 15:54:10 +00:00
Alan Parra 73abfe87cc fix: Move testGatewayConnectionFunc to proxy_helpers.go (#51022) 2025-01-14 14:33:29 +00:00
rosstimothy 852fc7d605 Remove unused servicecfg.Config.Console field (#50944)
Depends on https://github.com/gravitational/teleport.e/pull/5829
2025-01-13 16:58:27 +00:00
Rafał Cieślak 3653dda622 Add basic support for target port in gateways in Connect (#50912)
* Update type for targetSubresourceName on DocumentGateway

The way DocumentsService.createGatewayDocument is implemented means that
the targetSubresourceName property is always present, but it can be undefined.

* Use "local port" instead of "port" in DocumentGatewapApp

* Rewrite gateway FieldInputs to use styled components

* Update comments in protos

* useGateway: Stabilize useAsync functions of ports

* Add padding to menu label if it's first child

* Add support for required prop to Input and FieldInput

* Add UI for changing target port

* ActionButtons: Show ports of multi-port apps when VNet is not supported

Now that we have support for the target port in Connect's gateways, we
can show the ports and then open a gateway for that specific port on
click.

* Add RWMutex to gateways

* Clear app gateway cert on target port change

* Remove gateways/app.LocalProxyURL

It was used only in tests and it made sense only for web apps anyway.

* TestTCP: Close connections when test ends

* Create context with timeout in testGatewayCertRenewal

…instead of in each function that uses it.

* Add tests for changing the target port of a TCP gateway

* Parallelize app gateway tests within MFA/non-MFA groups

* Make testGatewayConnection take ctx as first arg

This will be needed in tests that check target port validation.

* Validate target port of app gateways

* Increase timeouts in app gateway tests

* Change icons from medium to small

* Use consistent spacing in AppGateway

* Add godoc for ValidateTargetPort

* Add retry with relogin to change target port
2025-01-13 16:55:41 +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
Bernard Kim a221604dc5 Add UpsertTrustedClusterV2 RPC (#49789)
* Add UpsertTrustedClusterV2 rpc

This supersedes UpsertTrustedCluster rpc. V2 performs resource name
validation.

* Replace confusing UpsertValidationTrustedCluster name

* Use UpsertTrustedClusterV2 in tests

* Address feedback

- Remove unnecessary ping
- Update error messages
- Use skipNameValidation consts
- Validate cluster name before establishing trust
- Do not reveal cluster name in error message
- Use BadParameter instead of CompareFailed

* Use webclient.Find

* Fix test/lint

* Allow label updates

* Fix test

* Fix error handling

* Implement CreateTrustedClusterV2 and UpdateTrustedClusterV2

* Address feedback

* Minor fixes

* Move V2 RPCs to the trust service

* Update comment

* Drop V2 suffix

* Require matching revision

* Fix upsert/update revision

* Drop V2 from Create and Update APIs

* Lint: Fix typo
2024-12-21 04:24:29 +00:00
rosstimothy 41bae13c2f Convert lib/srv/alpnproxy to use slog (#50018) 2024-12-12 14:25:57 +00:00
rosstimothy da9ed65f7d Attempt to reduce flakiness of integration tests (#49850)
Closes #47156.

All of the tests suffering from issues dialing hosts, and failing
with a `failed to dial target host` error were incorrectly waiting
for nodes to become visible before establishing connections. The
main culprit for most of the failures was `waitForNodesToRegister`,
though a few tests had a very similar hand rolled variant, which
incorrectly returned when the nodes appeard in Auth. However, since
the Proxy is the one performing dialing, they should have waited
for the nodes to appear in the Proxy.

To resolve, `waitForNodesToRegister` and all hand rolled equivalents
have been removed in favor of `(TeleInstance) WaitForNodeCount` which
correctly uses the `CachingAccessPoint` of the RemoteSite instead
of `GetClient`. Additionally, `helpers.WaitForNodeCount` was updated
to validate that the node watcher used for routing in the Proxy
also contained the expected number of nodes.
2024-12-06 16:46:43 +00:00
Zac Bergquist c7765fa7f1 Fix incorrect usages of "it's" (#48252) 2024-10-31 23:35:30 +00:00
Grzegorz Zdunek 95af4c1808 Support custom hardware key prompt (#47273)
* Allow passing custom prompt to YubiKey

* Handle `prompt.Touch` cancellation

* Pass `HardwareKeyPrompt` through all the layers

* Add an empty `HardwareKeyPromptConstructor` to Connect

* Remove `ParsePrivateKeyWithCustomPrompt`

* Add missing godoc

* Fix teleterm tests

* Include `cliprompt.go` only for `go:build piv && !pivtest`

* Lint and test fixes
2024-10-16 10:00:03 +00:00
Nic Klaassen f91a9c416c support key algorithms for host identities (#46420)
* support key algorithms for host identities

* add signature_algorithm_suite to webapi/find

this fixes joining through the reverse tunnel port which doesn't expose
webapi/ping
2024-09-16 18:08:56 +00:00
Tiago Silva 2aa51b7546 exclude alpn upgrade connections from PROXY line enforcement (#45968)
* exclude alpn upgrade connections from PROXY line enforcement

When clients use multiplex mode behind a TLS-terminating load balancer (LB), Teleport circumvents this limitation by establishing a connection that is upgraded to WebSockets.

On the upgraded WebSocket connection, clients initiate a TLS handshake and send their actual requests.

However, when `proxy_protocol: on` is enabled, the proxy line validation is re-applied to the upgraded connection, causing the request to fail. This occurs because the LB only included the proxy line in the initial WebSocket request, which was consumed. After the upgrade, the connection is routed to the ALPN router, and if it reaches the Kubernetes Proxy, it tries to enforce the presence of the PROXY line.

Since the PROXY line was not present, the request failed.

This PR excludes websocket upgraded connections from PROXY line validation.

* rephrase error message and rename function

* simplify code by unwrapping till net.Conn
2024-08-28 21:26:38 +00:00
Alan Parra be520a30e9 chore: Bump google.golang.org/grpc/cmd/protoc-gen-go-grpc to v1.5.0 (#44739)
* chore: Bump google.golang.org/grpc/cmd/protoc-gen-go-grpc to v1.5.0

* Update generated protos

* Fix various Unimplemented{Service}Server pointer embeds
2024-07-29 15:05:34 +00:00
STeve (Xin) Huang f240bfb312 Amazon DocumentDB access part 1 (#43867)
* Amazon DocumentDB access part 1

* fix lint

* make derive
2024-07-16 15:17:06 +00:00
Michelle Bergquist 70b95e385d Surface Cloud Entitlements (#42394)
- Cloud entitlements are now available on Features
- Legacy logic applies if entitlements are not present
2024-06-28 00:22:13 +00:00
Anton Miniailo 68eafbdbb4 Fix wrong context usage for reissuing expired certificate for tsh proxy kube. (#43374)
* Fix wrong context usage for reissuing expired certificate for tsh proxy kube.

* Rename context to closeContext

* Add test for request context expiration.

* Add missing context in tests.

* Remove flakiness from the test.
2024-06-27 19:07:46 +00:00
Brian Joerger 800e8e896d MFA for App Access - tsh for cloud apps (#40985)
* Add generic app proxy implementation.

* Incorporate forwarding proxy in generic app proxy.

* Utilize cert checker middleware for http local proxies.

* Use generalized local proxy app for aws.

* Use generalized local proxy app for azure.

* Use generalized local proxy app for gcp.

* Refactor, simplify, and unify app logic logic for app, proxy app, and
cloud commands.

* * Load existing app certs before reissuing new certs for proxy app
commands

* Fix the same intended functionality for tsh proxy db

* Fix hardware key test for tsh app login.

* Remove unused code.

* Fix merge conflict.

* Address Gavin's comments.

* Restore RetryWithRelogin for app commands by making missing profile status a retryable error; cache profile status in appInfo.

* Address Tim's comments.

* Remove read lock.

* Add tests to CertChecker and LocalCertGenerator.

* Fix lint.
2024-06-20 20:32:55 +00:00
rosstimothy 16c59959c7 Remove lib/shell from lib/client (#43119)
The shell package requires cgo and by importing it in lib/client,
which all client tools have in their dependency tree, it prevents
them  from building without GCO_ENBALED=1.

Updates https://github.com/gravitational/teleport/issues/43112.
2024-06-17 21:46:37 +00:00
Grzegorz Zdunek 6bcb99e9d5 Add support for per-session MFA for databases (#42521)
* Add support for per-session MFA in databases by using the cert returned from `onExpiredCert`

* Remove test helpers that are not needed anymore

* Add integration tests requiring per-session MFA to be supported

* Make `Application` in `MFA is required to access Application "abc"` lowercase

* Refactor `DBCertChecker` to fit Connect needs and remove `dbMiddleware`

* Remove unnecessary condition in a test

* Convert positional arguments to `dbGatewayCertRenewalParams`

* Do not nest the function to issue a db cert

* Remove mongodb check from `reissueDBCert` in tshd

* Revert "Do not nest the function to issue a db cert"

This reverts commit c3a9bf2cf3.

* Revert "Refactor `DBCertChecker` to fit Connect needs and remove `dbMiddleware`"

This reverts commit e01861071e.
2024-06-11 11:20:34 +00:00
Nic KlaassenandRafał Cieślak d23ed2438f [vnet][5] app proxying (#41033)
* [vnet] app proxying

* Make uri.AppendLeafCluster noop if name is empty

This makes it easier to converting profileName + leafName combos into
URIs.

* Make sure daemon.Service.NewClusterClient sets MFAPromptConstructor

* auth -> authclient

* remove unnecessary changes in teleport storage

* plumb clock and test cert refreshes

* s/zeebo/testify

* fix tcp echo handler

* only login to one cluster at a time

* add godoc comments in clientcache

* test cert expiry, serialize clock advances

* add comments on relogin mutex

* typo fix

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
2024-05-28 17:49:12 +00:00
rosstimothy 8e59e36e90 Refactor registration code into lib/auth/join (#41679)
* Refactor joining code into lib/auth/join

auth.Register and auth.RegisterParams were moved into the new package
to prevent clients(tbot) from depending on lib/auth. For the moment
only iam joining has been moved into the new package. All other
join methods have been left behind in their lib/auth/join_foo.go
file and will be addressed in future PRs if need be.  This removes
lib/auth entirely from tbot and reduces its binary size by ~10-20MB.

* fix: disabling second factor auth in tests

* fix license
2024-05-18 16:56:28 +00:00
rosstimothy 1b5e0b0082 Reduce exposure of lib/cloud/gcp (#41678)
* Move imds related code into their own packages

Separating imds from cloud vm, kubernetes, etc. prevents the
dependency tree expanding to include extra cloud related things
for callers that only require an imds client.

* Move cloud constructors for types.KubeCluster out of lib/services

lib/services is meant to be a relatively dependency free package
that provides basic interfaces and functions for dealing with
types. NewKubeClusterFromGCPGKE, NewKubeClusterFromAWSEKS, NewKubeClusterFromAzureAKS
caused a slew of cloud related dependencies to be imported in
lib/services which increases binary sizes of client tools.

They have all been moved into lib/srv/discovery/common since
they were only consumed by other code in lib/srv/discovery.

* Decouple servicecfg and lib/auth/keystore

This was the last remaining way for lib/cloud/gcp to slip
into client tools that aren't importing lib/auth directly.

```
goda tree "reach(github.com/gravitational/teleport/tool/tctl...:all, cloud.google.com/go/compute/apiv1)"
├ github.com/gravitational/teleport/tool/tctl
    └ github.com/gravitational/teleport/tool/tctl/common
      ├ github.com/gravitational/teleport/lib/config
        ├ github.com/gravitational/teleport/lib/pam
          └ github.com/gravitational/teleport/lib/service/servicecfg
            └ github.com/gravitational/teleport/lib/auth/keystore
              └ github.com/gravitational/teleport/lib/cloud
                └ github.com/gravitational/teleport/lib/cloud/gcp
                  └ cloud.google.com/go/compute/apiv1
        └ github.com/gravitational/teleport/lib/service/servicecfg ~
      ├ github.com/gravitational/teleport/lib/service/servicecfg ~
      ├ github.com/gravitational/teleport/tool/tctl/common/accessmonitoring
        └ github.com/gravitational/teleport/lib/service/servicecfg ~
      ├ github.com/gravitational/teleport/tool/tctl/common/loginrule
        └ github.com/gravitational/teleport/lib/service/servicecfg ~
      ├ github.com/gravitational/teleport/tool/tctl/sso/configure
        ├ github.com/gravitational/teleport/lib/service/servicecfg ~
        └ github.com/gravitational/teleport/tool/tctl/sso/tester
          └ github.com/gravitational/teleport/lib/service/servicecfg ~
      └ github.com/gravitational/teleport/tool/tctl/sso/tester ~
```

* fix lints

* tidy integrations/event-handler

* fix license

* fix: only populate cloud clients if aws kms configured
2024-05-17 10:29:02 +00:00
rosstimothy 7fe7a6b2a0 Replace dependencies on lib/auth with lib/authclient (#41623)
* Remove authclient.Client/ClientI/NewClient aliases in lib/auth

* Remove WebSessionReq aliases in lib/auth

* Remove GithubAuthResponse aliases in lib/auth

* Remove GithubAuthRequest aliases in lib/auth

* Remove KubeCSR alias in lib/auth

* Remove KubeCSRResponse alias in lib/auth

* Remove OIDCAuthResponse alias in lib/auth

* Remove OIDCAuthRequest alias in lib/auth

* Remove ValidateOIDCAuthCallbackReq alias in lib/auth

* Remove OIDCAuthRawResponse alias in lib/auth

* Remove CreateUserTokenRequest alias in lib/auth

* Remove SAMLAuthResponse alias in lib/auth

* Remove SAMLAuthRequest alias in lib/auth

* Remove ValidateSAMLResponseReq alias in lib/auth

* Remove SAMLAuthRawResponse alias in lib/auth

* Remove ValidateTrustedClusterRequest alias in lib/auth

* Remove ValidateTrustedClusterRequestRaw alias in lib/auth

* Remove ValidateTrustedClusterResponse alias in lib/auth

* Remove ValidateTrustedClusterResponseRaw alias in lib/auth

* Remove AuthenticateUserRequest alias in lib/auth

* Remove ForwardedClientMetadata alias in lib/auth

* Remove PassCreds alias in lib/auth

* Remove OTPCreds alias in lib/auth

* Remove SessionCreds alias in lib/auth

* Remove AuthenticateSSHRequest alias in lib/auth

* Remove SSHLoginResponse alias in lib/auth

* Remove TrustedCerts alias in lib/auth

* Remove AuthoritiesToTrustedCerts alias in lib/auth

* Move auth.HostFQDN to authclient

* Move auth.WithClusterCAs, auth.DefaultClientCertPool and auth.ClientCertPool to authclient

* Switch alpn proxy to use authclient.CAGetter instead of auth.ReadProxyAccessPoint

* Use a smaller scoped interfaces in lib/proxy/peer to remove lib/auth dependency

* Move auth.TryCreateAppSessionForClientCertV15 to authclient

* Move auth.ErrNoMFADevices to authclient

* Move access point interfaces to authclient. Aliases left behind to prevent breaking builds

* remove lib/auth dependency from lib/reversetunnelclient

* fix lints

* fix license

* Bump e ref to include gravitational/teleport.e#4174

* Use authclient.Client in new tctl diag commands

* Stop using auth.UserTokenType aliases
2024-05-16 17:34:58 +00:00
rosstimothy abd15f314d Refactor process state into its own package (#41630)
Creates a new lib/auth/state package that now contains all items
related to process identity and local storage. Since these things
are consumed by client tools isolating them in their own package
will allow tools to trim the dependency tree by shedding lib/auth
for a smaller package. No functional changes have been added in
addition to moving code around. There are aliases to the old
types left around to prevent breaking builds. They will be removed
in a follow up when teleport.e is updated to consume the new package.
2024-05-16 13:51:55 +00:00
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
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
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
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
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
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
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
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
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
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
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
Rafał Cieślak 21f036548c lib/teleterm app access: Add middleware for handling expired certs (#36520)
* Add middleware for app gateways

* Accommodate for app gateways in integration tests

The previous version of tests depended on receiving helpers.TeleInstance
from higher up. It was then used to generate valid and expired user certs,
as well as to get client.TeleportClient.

proxy.Suite (Kube tests) and dbhelpers.DatabasePack (db tests) expose
helpers.TeleInstance so it wasn't a problem. However, appaccess.Pack,
which we're going to use for app access tests, does not expose it.

To work around that, we introduce two new fields to gatewayCertRenewalParams,
tc (which accepts client.TeleportClient) and generateAndSetupUserCreds.
These two fields get rid of the dependency on helpers.TeleInstance.

* Add integration tests for app gateways
2024-01-11 16:48:40 +00:00
Hugo Shaka 54ede1e11c Fix teleport.e integrations builds (#35996)
* Move automaticupgrades packages in `lib/automaticupgrades`

* Fix `kube-agent-udpater` Dockerfile
2023-12-27 14:39:42 +00:00
Rafał Cieślak 83e03670da Add support for MFA in kube proxies in Connect (#35772)
* Improve error handling in gateway/kube_test.go

* Make gatewaytest.mustGenCertSignedWithCA public

It will be needed to generate and then return cert without saving it to
a file.

* Move AddMetadataToRetryableError to where it's actually needed

Cluster.reissueDBCerts is called in two scenarios:

* During the request to create a db gateway: this request is made by
  the Electron app, so we need to add metadata to let the app know that
  this error can be resolved by relogin.
* When someone attempts to use the proxy but the user cert has expired:
  this happens outside of the Electron app request-response cycle and
  thus adding metadata is unnecessary.

* Make gatewaytest.MustGenCACert public, accept CA for MustGenAndSaveCert

This will make writing tests where we need to supply either Cert or KeyPath
and CertPath a little bit easier.

* Kube gateways: Store cert in memory instead of on disk

* Add ctx to testGatewayCertRenewal

If a gateway requires MFA, daemon.Service.CreateGateway can potentially
block forever. To work around this, we want the tests to pass a context
around so that we can set a timeout on the context in MFA tests.

* Convert test function args into structs

This will make it easier to pass webauthnLogin for tests that need MFA.

* Refactor handling of mock tshd events service addr

* Add tests for MFA

* Do not save kube key in local agent

Connect issues a new cert for every gateway anyway.

* Check kube certs after issue in teleterm gateways

This makes sure that Connect does the same checks as tsh.

* reissueDBCerts → reissueGatewayCerts

* Pass mfaPrompt from daemon to GatewayCreator

This also fixes a problem where the mfaPrompt passed from GatewayCreator
was not the expected one. daemon.Service.ResolveClusterURI attaches
MFAPromptConstructor on clusterClient. However, GatewayCreator does not
call daemon.Service.ResolveClusterURI, it calls
clusters.Storage.ResolveCluster which does not attach the proper prompt
constructor.

* Refactor GetPromptReasonSessionMFA into WithPromptReasonSessionMFA

* Verify that PromptMFA on tshdEventsService gets called during MFA ceremony

* reissueKubeCert: Get rid of unused mfaRequired var

* Use fake storage in gateway CRUD tests

Now that daemon.Service.CreateGateway needs a TeleportClient, we have
to use a fake storage that's able to provide it.

* Fix synchronization between webauthnLogin and PromptMFA

* Use sync/atomic for function call counts
2023-12-21 07:46:42 +00:00
Hugo ShakaandBernard Kim 3472a60e13 automatic upgrades: use default version channel everywhere (#35342)
* Use default upgrade channel

This commit:
- initializes default upgrade channels based on the server features
- makes all integrations use the upgrade channels instead of hitting
  hardcoded s3 bucket
- makes the version channel return its own version if the target
  version is too high
- makes the NoVersion handler properly: returned as an error. This way
  soneone relying on the version getter doesn't have to check
- moves the version kube-agent-updater lib in main teleport libs
- add tests for noVersion channels

* Update lib/web/join_tokens.go

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

* address marco's feedback

* address marco's feedback pt.2

---------

Co-authored-by: Bernard Kim <bernard@goteleport.com>
2023-12-18 19:57:32 +00:00
Hugo Shaka 856bb39ea9 Add a version server in the proxy + use it in agent chart (#35150)
This PR adds an embedded [version server](https://goteleport.com/docs/architecture/agent-update-management/#version-server-and-source-of-truth) in the proxy to address: https://github.com/gravitational/cloud/issues/6773

The version server can be configured through `teleport.yaml`:

```yaml
proxy_service:
  enabled: "yes"
  automatic_upgrades_channels:
    stable/cloud:
      forward_url: https://updates.releases.teleport.dev/v1/stable/cloud
    preview/cloud:
      static_version: v12.5.4
```

The forwarded call results are cached for a minute.
2023-12-12 01:03:45 +00:00
rosstimothy 1515dc0114 Remove CheckAndSetDefaults from types.Resource (#35561) 2023-12-08 18:05:38 +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
Edoardo Spadolini 93be07558e Deflake TestIntegrations/Discovery again (#34953)
* Fix integration/helpers.WaitForClusters

* fixes to all remote cluster integration tests

* remove leftover debug message

* use random load balancer
2023-11-27 15:26:09 +00:00
Anton MiniailoandNic Klaassen a4be12fbcf Reorganize service config test fields (#34208)
* Reorganize process config test fields

* Move PollingPeriod back from Testing field

* Fix comment text

Co-authored-by: Nic Klaassen <nic@goteleport.com>

---------

Co-authored-by: Nic Klaassen <nic@goteleport.com>
2023-11-16 05:29:07 +00:00