Commit Graph
279 Commits
Author SHA1 Message Date
STeve (Xin) Huang b9fea4bd36 PoC v2 with double-encryption 2026-08-18 09:30:07 +01:00
Kevin ae4bb28b8b Add traits matching logic for users (#66020) 2026-05-05 23:42:31 +00:00
Brian Joerger a09174cd0b Add piv tag for lint-api make target; Fix lint errors in piv package. (#65669) 2026-04-29 17:50:49 +00:00
Ghassan Gedeon Achi 7bea6c9416 feat(client): add Access Graph TLS cert to KeyRing (#65957)
Adds a separate PEM-encoded TLS certificate on KeyRing
(AccessGraphTLSCert) used to authenticate directly to the proxy's
Access Graph API. It reuses TLSPrivateKey and is persisted alongside
the other per-proxy artifacts at
<baseDir>/keys/<proxy>/<username>-access-graph.crt.

Included wiring:
  - KeyRing helpers: AccessGraphTLSCertificate,
    AccessGraphTLSCertValidBefore, and AccessGraphClientTLSConfig.
    AccessGraphClientTLSConfig builds a tls.Config that trusts system
    CAs rather than the cluster CA, since the client is speaking
    directly to the public proxy.
  - FSKeyStore: read, write, and delete of the new cert file. The
    write and read go through a small helper that holds the same
    write/read lock on the TLS key file used by writeTLSCredential,
    so the AccessGraph cert cannot drift from TLSPrivateKey under a
    concurrent key rotation. Load is optional, so keyrings without
    the cert still work.
  - MemKeyStore.GetKeyRing propagates AccessGraphTLSCert for parity
    with the FS store.
  - Store.GetKeyRing parse-validates the AccessGraph cert when
    present, mirroring the existing TeleportTLSCertValidBefore call
    for the main TLS cert. Expired certs round-trip unchanged, matching
    the main TLSCert contract ("it's the responsibility of the
    TeleportClient to perform cleanup").

Note:
  - The identity file format was not updated to carry an AccessGraph
    TLS cert, which would be a breaking change to a long-lived,
    externalizable artifact. The tctl access graph workflow mints the
    cert against the proxy on demand and persists it in the client
    keystore, so identity-file portability isn't needed.

Tests:
  - keypaths.AccessGraphTLSCertPath path formatter.
  - FSKeyStore + MemKeyStore round trip of a distinct AccessGraph cert,
    minted via a new signAccessGraphCert helper that mirrors the
    production identity shape (Usage=UsageAccessGraphAPIOnly plus a
    WebSessionID). Plus delete behaviour for present and absent cert
    files on the FS store.
  - Store.GetKeyRing: absent, valid, expired, and unparseable
    AccessGraph cert paths. Expired round-trips; only unparseable is
    rejected.
  - KeyRing AccessGraph helpers: NotFound paths and tls.Config
    construction (system-CA trust, ServerName=ProxyHost, MinVersion
    TLS 1.2).

This is the client-side plumbing required by the tctl access graph
commands to obtain, persist, and reuse a proxy-facing TLS cert across
runs. Server-side session lifetime decoupling will follow in a
separate change.
2026-04-28 00:11:34 +00:00
Tiago Silva 73e9d77910 Fix AWS endpoint validation (#66088)
We should always be checking for a suffix, not containment.

Signed-off-by: Tiago Silva <[email protected]>
2026-04-24 17:23:51 +00:00
306b6a9db0 Set Teleport version in SSH clients (#65004)
* Set Teleport version in SSH clients.

Signed-off-by: Chris Thach <[email protected]>

* Add more tests. Fix lint.

Signed-off-by: Chris Thach <[email protected]>

* Fix import. Fix lint exclude.

Signed-off-by: Chris Thach <[email protected]>

* Fix lint - come on!

Signed-off-by: Chris Thach <[email protected]>

* Fix race by making a defensive copy.

Signed-off-by: Chris Thach <[email protected]>

* Use ErrorIs.

Signed-off-by: Chris Thach <[email protected]>

* Deep clone client conf. Early return for err. Make consistent.

Signed-off-by: Chris Thach <[email protected]>

* Return new conf if nil. Add trace.Wrap to missing.

Signed-off-by: Chris Thach <[email protected]>

* Add IsSSHFeatureSupported. Switch from api to api_test for test pack. Make prefix exported const.

Signed-off-by: Chris Thach <[email protected]>

* Revert accidental commit.

Signed-off-by: Chris Thach <[email protected]>

* Return sentinel error for older clients or non-teleport clients to improve downstream handling.

Signed-off-by: Chris Thach <[email protected]>

* Clean up.

Co-authored-by: Chris Thach <[email protected]>

* Apply suggestions from code review

Co-authored-by: Edoardo Spadolini <[email protected]>

* Remove defensive check.

Signed-off-by: Chris Thach <[email protected]>

* Change from trace.BadParam to reg error.

Signed-off-by: Chris Thach <[email protected]>

* Use strings.Cut and improve readability.

Signed-off-by: Chris Thach <[email protected]>

* Use error struct.

Signed-off-by: Chris Thach <[email protected]>

* Add test that errors if ssh.ClientConfig changes.

Signed-off-by: Chris Thach <[email protected]>

* Move to subpackage.

Signed-off-by: Chris Thach <[email protected]>

* Use static assertion instead.

Signed-off-by: Chris Thach <[email protected]>

* Return error if config is nil.

Signed-off-by: Chris Thach <[email protected]>

* Allow clients to override client version via config.

Signed-off-by: Chris Thach <[email protected]>

* Fix test because I forgot to update it.

Signed-off-by: Chris Thach <[email protected]>

* Move assert to test file.

Signed-off-by: Chris Thach <[email protected]>

* Remove error return val.

Signed-off-by: Chris Thach <[email protected]>

* Relax parser to allow for more.

Signed-off-by: Chris Thach <[email protected]>

* Fix lint.

Signed-off-by: Chris Thach <[email protected]>

* WIP take on a tracessh wrapper. Will fail CI.

Signed-off-by: Chris Thach <[email protected]>

* Add tests and polish new package.

Signed-off-by: Chris Thach <[email protected]>

* Revert changes to tracessh. Add lint config.

Signed-off-by: Chris Thach <[email protected]>

* Revert changes to use tracessh.

Signed-off-by: Chris Thach <[email protected]>

* Delete extra s.

Co-authored-by: Chris Thach <[email protected]>

* Apply suggestions from code review.

Signed-off-by: Chris Thach <[email protected]>

* Add IsEmpty helper methods.

Signed-off-by: Chris Thach <[email protected]>

* First pass of refactoring.

Signed-off-by: Chris Thach <[email protected]>

* Second pass refactor.

Signed-off-by: Chris Thach <[email protected]>

* Third pass refactor.

Signed-off-by: Chris Thach <[email protected]>

* Fix nil panic.

Signed-off-by: Chris Thach <[email protected]>

* Fix missing user value.

Signed-off-by: Chris Thach <[email protected]>

* Fix missing User value.

Signed-off-by: Chris Thach <[email protected]>

* Remove Get from name. Polish.

Signed-off-by: Chris Thach <[email protected]>

* Fix incorrect signers for clients. Make changes consistent.

Signed-off-by: Chris Thach <[email protected]>

* Allow ClientConfig to be empty in proxy config.

Signed-off-by: Chris Thach <[email protected]>

* Fix eager signers regression in generateClientConfig.

Signed-off-by: Chris Thach <[email protected]>

* Add edge case for space after prefix.

Signed-off-by: Chris Thach <[email protected]>

* Fix issues from code review.

Signed-off-by: Chris Thach <[email protected]>

* Drop suffix. Update comments.

Signed-off-by: Chris Thach <[email protected]>

* Update ClientConfig docs.

Signed-off-by: Chris Thach <[email protected]>

* Add warning about using the Teleport version.

Signed-off-by: Chris Thach <[email protected]>

* Teleport version is mandatory.

Signed-off-by: Chris Thach <[email protected]>

* Revert timeout to make Claude/Codex happy.

Signed-off-by: Chris Thach <[email protected]>

* Remove alias in places that didn't need it. Revert lib/cloud/gcp/alloydb.go.

Signed-off-by: Chris Thach <[email protected]>

* Add wrapper for tracessh.Client.

Signed-off-by: Chris Thach <[email protected]>

* Add tests for generate client config.

Signed-off-by: Chris Thach <[email protected]>

* Drop config from field name to shorten.

Signed-off-by: Chris Thach <[email protected]>

* Fix lint issues.

Signed-off-by: Chris Thach <[email protected]>

---------

Signed-off-by: Chris Thach <[email protected]>
Co-authored-by: Edoardo Spadolini <[email protected]>
2026-04-07 18:06:00 +00:00
Tiago SilvaandNic Klaassen e54bfb9ab7 enforce region validation on all AWS config loading (#64893)
* enforce region validation on all AWS config loading

Replace direct uses of `github.com/aws/aws-sdk-go-v2/config.LoadDefaultConfig`
with the internal `lib/cloud/aws/config.LoadDefaultConfig` wrapper, which
validates any explicitly requested AWS region before use. Enforces this via a
new forbidigo linter rule.

Signed-off-by: Tiago Silva <[email protected]>

* Apply suggestions from code review

Co-authored-by: Nic Klaassen <[email protected]>

* fix unit tests

* include underscores and uppercase letters

* add ConfigureRegion

---------

Signed-off-by: Tiago Silva <[email protected]>
Co-authored-by: Nic Klaassen <[email protected]>
2026-04-07 08:48:47 +00:00
Alan Parra 0834a01360 Add api/utils/tlsutils.ParseCertificatePEMStrict (#64114) 2026-03-02 16:29:35 +00:00
Chris Thach c26680a73c Lint to enforce using t.Context() instead of context.TODO() 👮🏾 (#63596)
* Update linter to restrict using context.TODO() in Go tests.

Signed-off-by: Chris Thach <[email protected]>

* Revert changes to testlib package.

Signed-off-by: Chris Thach <[email protected]>

---------

Signed-off-by: Chris Thach <[email protected]>
2026-02-06 19:42:33 +00:00
Dan Upton c78a17ac44 api/utils/retryutils: Do not log stack trace when waiting to retry (#62725) 2026-01-12 17:48:49 +00:00
Gavin Frazar 47fa5142f9 fix aws e2e test (#62528)
* Fix data race in e2e AWS tests

* replace pgx.Conn with pgxpool.Pool, which is safe for concurrent usage
* remove redundant mutex

* Format retry wait duration as a readable string

* Update healthcheck logger component

To disambiguate from normal user connections, the health checker will
use a new logger component: "db:health".

* Skip granting teleport-auto-user to Redshift admin

This is not necessary for Redshift and the syntax is not correct either,
because Redshift grants must use "GRANT ROLE" instead of "GRANT".
This removes a superfluous log message about bad grant syntax.

* Run proxy and local proxy tests sequentially

This potentially fixes test flakiness.
The Redshift deactivation and deletion SQL scripts both check
stv_sessions for active user connections, which can cause failures when
a parallel test is still running.

* Log on test cleanup failure
2025-12-31 05:20:03 +00:00
Zac Bergquist 35ef392bc4 docs: update FIPS info (#61973)
This consolidates all references to BoringCrypto and FIPS-140-2 to
a single section of the docs, using more generic FIPS terminology
elsewhere. As a result, we only need to change one place when we
update our FIPS module in the future.

In addition, mention the specific versions of BoringCrypto and
associated CMVP certificate numbers.
2025-12-15 18:29:48 +00:00
rosstimothy a6a6284c88 Scopes: validate scope when dialing (#61859)
The scope of the certificate presented by agents to the reversetunnel
server is now tracked and stored with the remoteConn. Dial requests,
both local and via peers, are now populated with the scope the user
is logged into which the reversetunnel server uses to enforce that
dials for hosts are only honored if the target scope matches.
2025-12-13 00:12:57 +00:00
Pavel 90db5fc0dc return clearer error when fips tsh version connects to non-fips cluster (#62157) 2025-12-12 14:57:40 +00:00
Alan Parra 6b21966eaf Add a distinguished name string parser (#62036)
* Add a distinguished name string parser

* Replace "RFD" with "RFC"

* Allow empty non-quoted strings

* Allow spaces between attributeType and '='
2025-12-10 17:55:56 +00:00
Luke Okraszewski 5486f519e6 [clientutils] preserve pagesize between page calls (#61844)
With this change rangeInternal will preserve the last used pageSize which prevents issues with excess allocations when every page contains items too large for a successful list call.

Towards: #61839

Changelog: Fixes client side pagination utilities to preserve page size between list calls which previously led to high memory consumption on the server side leading to crashes.
2025-11-28 15:10:57 +00:00
Luke Okraszewski 067dd9f265 Auto page size adjustment for GetUsers (#60560)
It is possible that the default page size will still exceed grpc
limits when user objects are large enough. This change will
use the auto page size adjustment in this case to attempt to recover
gracefully.

Fixes: #60933
2025-11-18 10:32:09 +00:00
Kevin d1d465444b Add support for tsh logout --proxy to work without --user flag when only one identity exists (#60851)
* Added support for `tsh logout --proxy` to work without `--user` when one identity exists

* Fix lint

* Refactor

* Refactor

* Refactor and update log messages
2025-11-14 23:45:22 +00:00
Kevin 976c7eb61d Improve resource name validation for AWS Roles Anywhere and AWS OIDC generate command (#61024)
* Fix resource name validation for AWS Roles Anywhere generate command

* Refactor, fix lint

* Add better UI validation for AWS Integration name; refactor

* Refactor and add leading/trailing whitespace check, add better UI validation for AwsOidc

* Remove unused export
2025-11-14 17:06:39 +00:00
Andrew Burke 10bfff2294 Gracefully handle corrupted private keys (#61126)
This change allows tsh to treat corrupted private keys as though
they were not present (and trigger relogin flows) It also attempts
to prevent said corruption in the first place.
2025-11-14 17:03:28 +00:00
Luke OkraszewskiandChris Thach a3604b973f [clientutils] Add CollectWithFallback helper (#59582)
* [clientutils] Add CollectWithFallback helper

This helper is useful when migrating from non-paginated
to paginated resource getters. Internally it will use
auto page sizing for a given page getter and fall back
to unary getter when the remote does not support the new
RPC.

* Update api/utils/clientutils/resources_test.go

Co-authored-by: Chris Thach <[email protected]>

* Update api/utils/clientutils/resources_test.go

Co-authored-by: Chris Thach <[email protected]>

* Update api/utils/clientutils/resources_test.go

Co-authored-by: Chris Thach <[email protected]>

---------

Co-authored-by: Chris Thach <[email protected]>
2025-09-30 14:50:02 +00:00
Zac Bergquist a4eb5edab6 Remove integrations/lib/backoff (#59113)
Plugins had their own backoff utils when they were a separate repo,
but now that they're in Teleport's repo we can reuse existing retry
utils.

Closes #47102
2025-09-19 00:49:34 +00:00
STeve (Xin) Huang cff2d31134 [mcp] refactor jwt token and app header rewrite logic (#58601) 2025-09-17 16:49:08 +00:00
Pawel Kopiczko 128924ff58 Add UpdateWithRetry util func (#59028) 2025-09-12 16:17:33 +00:00
Marek Smoliński 6d7b3e2e1c Add manual Access List Clone flow instead of json roundtrip (#58592) 2025-09-03 17:51:33 +00:00
86852353ed GCP AlloyDB support (#56078)
* Proto changes

* Types changes

* Configuration changes

* Cloud client, `go.mod`

* Add method to fetch AlloyDB token

* Engine changes

* `make -C integrations/operator crd`

* lint fix

* `make -C integrations/terraform docs`

* change GCPCloudSQL comment in proto

* Update lib/srv/db/postgres/alloydb.go

Co-authored-by: Marco Dinis <[email protected]>

* Update lib/srv/db/common/auth.go

Co-authored-by: Marco Dinis <[email protected]>

* address review comments

* lint fix

* Rename `is_alloy_db` to `is_alloydb`

* Clarify comments for AlloyDB database fields in DatabaseGCP struct

* Nudge user towards proper permissions

* Update lib/srv/db/postgres/alloydb.go

Co-authored-by: rosstimothy <[email protected]>

* remove todo in favor of longer comment

* reduce indentation

* suggest custom IAM role with minimal required scope

* Major implementation update:
- new URI format `alloydb://<connection uri>`
- removed some configuration fields; added `gcp.alloydb.endpoint` instead
- added connection URI resolution against configured endpoint type
- made query cancellation and health checks aware of AlloyDB needs
- unified query cancellation logic to use the `connector` type

* Revert description changes for flags; these are redundant for AlloyDB

* Enhance error handling in ParseAlloyDBConnectionURI function and add comprehensive test cases for invalid URIs

* split `endpoint` into `endpoint_type` and `endpoint_override`

* Remove indentation from custom error messages

* Log resolved database address

* fix serialization test

* explain the logic in `getGCPType`

* use string instead of enum for endpoint type

* add missing cast

---------

Co-authored-by: Marco Dinis <[email protected]>
Co-authored-by: rosstimothy <[email protected]>
2025-08-20 15:04:12 +00:00
Gavin Frazar b97c78cf18 Add database type elasticache-serverless (#58019) 2025-08-20 05:08:37 +00:00
Luke Okraszewski 46c0d03106 [clientutils] Add ranging helper for client depagination (#57937)
`RangeResources` can be used to range over a generic resource
in the range [start, end) with auto page size adjustment.
2025-08-19 11:05:31 +00:00
Luke Okraszewski b4b9e97a75 Add TELEPORT_UNSTABLE_GRPC_RECV_SIZE env var option (#57846)
Setting this env var allows overwriting the max
size of a grpc message the client can recieve (default is 4MB).

Towards: https://github.com/gravitational/teleport.e/issues/6759
changelog: Add TELEPORT_UNSTABLE_GRPC_RECV_SIZE env var which can be set to overwrite client side max grpc message size.
2025-08-19 10:11:54 +00:00
Pawel Kopiczko f11e3c4fd9 Fix AccessListMember proto conversion for zero timestamps (#57652) 2025-08-08 20:06:39 +00:00
Edoardo Spadolini 549118b591 Disallow new uses of gogoproto jsonpb (#57492)
* Disallow new uses of gogoproto jsonpb

* fix wrong package name in depguard description
2025-08-04 12:57:23 +00:00
Grzegorz Zdunek 76d090d23e Prevent sending TDP messages in chunks during desktop sessions in Connect (#57022)
* Prevent sending TDP messages in chunks during desktop sessions in Connect

* Improve comments
2025-07-24 08:13:07 +00:00
Pawel Kopiczko 8c2b13d4d6 Fix AccessListService.UpsertAccessList MemberOf update (#56760) 2025-07-18 21:21:23 +00:00
Zac Bergquist 74cac38111 Remove unused API utils (#56688) 2025-07-11 15:17:14 +00:00
rosstimothy e81212dfcc Unify resource pagination (#56418)
This converts hand rolled collections of resources via ListFoo
RPCs in tctl and the cache to make use of clientutils.Resources.
The main driver for the change is consistency and simplifcation.
Having a single place that pagination logic exists should help
reduce the chances of any pagination bugs in the future. The helper
also reduces the amount of code needed at a call site to aggregate
resources.

The guts of clientutils.IterateResources have been moved to
clientutils.Resources which returns an iter.Seq2[T, error] instead
of the callback based approach. This makes the api simpler and allows
making use of the itertools/stream helpers. Additionally, the page
size used within clientutils.Resources was made to dynamically adjust
based on receiving any errors indicating that the max message size was
exceeding.
2025-07-08 12:05:28 +00:00
dependabot[bot]andTim Ross 86ecb47423 Bump the go group with 98 updates (#56289)
* go mod tidy all

* replace golang.org/x/exp/rand with math/rand/v2

* make go-generate

* revert github.com/go-webauthn/webauthn to v0.11.2

* update region regex

* revert github.com/ClickHouse/clickhouse-go/v2 v2.37.2

---------

Co-authored-by: Tim Ross <[email protected]>
2025-07-01 16:33:26 +00:00
Edoardo Spadolini 1cb642736a Avoid counterproductive checks in IsUserAuthority and IsHostAuthority (#56250) 2025-06-30 19:00:52 +00:00
Brian Joerger fc68015032 Fix local hardware key support spot tests. (#56065) 2025-06-25 18:31:15 +00:00
Brian Joerger bbad53a611 Remove unused function and aliases. (#55958) 2025-06-24 21:32:08 +00:00
Brian Joerger 8adeb860d2 Update piv-go to v2.3.0 (#55890)
* Use piv-go v2.

* Fix import.
2025-06-18 22:26:09 +00:00
Nic KlaassenandRafał Cieślak a61a4874c7 [vnet] feat: add SSH configuration diagnostic (#55594)
* [vnet] feat: add SSH configuration diagnostic

This commit adds a VNet diagnostic that reports whether the default user
OpenSSH config file (`~/.ssh/config`) includes VNet's generated SSH
config file.

* fix lint

* fix license

* Render paths as code, use TextSelectCopy for snippet

* add code stying for path

* add ssh report to diag story

* handle ~/.ssh/config not existing

* handle unescaped windows path separators and single quotes

* fix typo in comment

* Diag report story: Include error when sshConfigAttempt is set to "error"

* read ~/.ssh/config as part of the diag instead of abusing cat

* fix lint

---------

Co-authored-by: Rafał Cieślak <[email protected]>
2025-06-18 22:20:50 +00:00
Rafał Cieślak dfd21d4280 Fix validation in PIV PIN and PUK form in Connect, increase new PIN timeout (#55401)
* Properly validate new PUK confirmation

* Align PIN & PUK length with tsh

* Increase timeout for the prompt for setting new PIN and PUK
2025-06-05 22:37:49 +00:00
Nic Klaassen 2bedd3f8df [vnet] feat: write OpenSSH-compatible config file for VNet SSH (#55239) 2025-06-01 07:07:02 +00:00
Nic Klaassen 3a3099e2ec [vnet] feat: write VNet SSH keys to TELEPORT_HOME (#55228) 2025-06-01 05:50:10 +00:00
Erik Tate 479e99b866 adding support for encryption/decryption keys to keystore manager for (#54428)
gcp, pkcs11, and software backends
2025-05-29 19:40:43 +00:00
Marco Dinis c5c94aee18 WebAPI: endpoint that returns the oneoff command for AWS Roles Anywhere set up (#54853)
* WebAPI: oneoff script for AWS Roles Anywhere set up

* use w.Write instead of fmt.Fprint
2025-05-28 08:30:03 +00:00
Brian Joerger 9892cf65aa Warmup hardware key touch before login. (#55017) 2025-05-24 00:19:31 +00:00
Brian Joerger 7c975ce27c fix: release PIV connection during PIN prompts - avoid "the smart card has been reset" error (#54700)
* Refactor connection sharing logic to allow reconnection logic.

* Refactor signature method into organized parts; Move signPromptMu further down the callstack to allow better concurrent access; Add attestMu to prevent certificate corruption.

* Handle PIV reconnection within doWithSharedConn.

* Add test; Fix issues.

* Add debug log.

* Clean up locks.

* Only prompt PIN on retry; Clean up prompt logic.

* Add todo for upstream PR.

* Prevent PIV operations that don't support concurrency from being run concurrently; add test.

* - Revert connection sharing refactors.

- Add exclusiveOperationMu mutex and test.

* Address comments; Move touch prompt into abandonableSign for clearer synchronous logic.

* Restore cancel cause behavior.

* Address signature concurrency comments.

* Fix signature channel.
2025-05-23 18:42:41 +00:00
Brian Joerger a2e7c20feb feat: Hardware Key Agent validates known keys (#54691)
* * Have hardware key agent validate known keys instead of always validating by the PIV slot cert.

* Refactor cert check logic with a custom error.

* Add test.

* Update rfd.

* Fix lint.

* Address comments.

* Require knownKeyFn to be provided.

* Require fallbackService to be provided to agent service.

* Address comments.
2025-05-16 18:38:44 +00:00
Brian Joerger 8b0a848abf fix: don't cache an incorrect PIV PIN (#54614)
* Verify PIV PIN before we cache it; Fix lint for pincache.go with build tag.

* Add local test for PIN caching in the YubiKey service.

* Minor fixes.
2025-05-09 23:56:22 +00:00