Commit Graph
182 Commits
Author SHA1 Message Date
Brian Joerger 6a1d6662dd Unify and simplify MFA Ceremony helpers (#46986)
* Refactor MFA ceremony helpers.

* Refactor session MFA ceremony to use new MFA ceremony helpers.

* Simplify calls to NewMFACeremony.

* Remove remaining usage of tc.PromptMFA in favor of Ceremony.

* Rename prompt constructor.

* Add godoc to ceremony; update tests.

* Cleanup.

* Resolve comments; fix tests.

* Update comments.

* Fix test.

* Fix lint.
2024-10-02 19:09:45 +00:00
Nic KlaassenandEdoardo Spadolini 1efa0ae77c fix: tolerate mismatched key PEM headers (#46725)
* fix: tolerate mismatched key PEM headers

Issue #43381 introduced a regression where we now fail to parse PKCS8
encoded RSA private keys within an "RSA PRIVATE KEY" PEM block in
some cases.
This format is somewhat non-standard, usually PKCS8 data should be in a
"PRIVATE KEY" PEM block. However, certain versions of OpenSSL and
possibly even Teleport in specific cases have generated private keys in
this format.

This commit updates ParsePrivateKey and ParsePublicKey to be more
tolerant of PKCS8, PKCS1, or PKIX key data no matter which PEM header is
used.

Fixes #46710

changelog: fixed regression in private key parser to handle mismatched PEM headers

* fix typo in comment

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

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2024-09-18 19:20: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
Edoardo Spadolini 4957735a31 Get rid of internal reloads (#44882)
* disable tls client resumption

* avoid redundant verification in TLSDial

* fix wrong use of InsecureSkipVerify in HTTP auth client

* avoid overwriting GetClientCertificate in api client

* Use a getter function for CAs in TunnelAuthDialer

* Use dynamic connector data for the agent's auth client

* Make getPROXYSigner dynamic

* WIP: the thing (reloadless)

* Fix TestInstanceCertReissue

* Fix TestIntegrations/RotateFoo

* get rid of the whole reload mechanism

* Update most tests to not check for reloads

* Get rid of TestDatabaseAccess/RotateTrustedCluster

The test has been unconditionally skipped for two years now.

* avoid clobbering the auth connector

* overwrite clientState in update_servers anyway

* fix integration/hsm tests

* Document ListenForNewEvent

* fix RunWithSignalChannel godoc

* simplify ListenForNewEvents

* Remove forgotten commented code

* Explain the t.Setenv trick for non-parallelism

* explain waitingForNewEvent in integration/hsm
2024-09-11 21:13:09 +00:00
Nic Klaassen c15825c751 use configured algorithms for dynamic SSH host certs (#46329)
* dynamic SSH host certs use configurable algorithms

* lazily PrecomputeKeys everywhere

* slightly speed up TestTSHConfigConnectWithOpenSSHClient
2024-09-11 19:21:50 +00:00
Krzysztof Skrzętnicki 7ce2d0e323 Fix incorrect PostgreSQL spelling (#46072) 2024-09-02 08:24:57 +00:00
Marco DinisandRoman Tkachenko 54cdfb6895 AWS OIDC: Ping rpc and endpoint (#45702)
* AWS OIDC: Ping rpc and endpoint

* Update lib/integrations/awsoidc/ping.go

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

* Update integration.go

---------

Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2024-08-23 07:35:15 +00:00
Nic Klaassen 6eb6b981b3 Split user keys for k8s access (#44779)
* split user keys for k8s access

* remove unnecessary loop

* prevent race when reading/writing key/cert pairs

* reuse RSA keys

* single file for kube key and cert

* update comment with file layout
2024-08-13 17:41:33 +00:00
Nic Klaassen 7906e13952 split user keys for db access (#44718) 2024-08-08 01:10:41 +00:00
Nic Klaassen cbb19fece2 Split user keys for app access (#44609)
* rfd edits

* split keys for app access

* update paths visualization

* godocs

* speed up TestAppCommands

* fix possible panic in test

* fix piv test
2024-08-06 22:40:57 +00:00
Nic Klaassen afca8aefc8 allow EC ssh keys in FIPS mode (#44476)
* allow EC ssh keys in FIPS mode

* fix test
2024-07-19 19:59:54 +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
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
Nic Klaassen fb8ef40e01 remove RSA-specific methods on keys.PrivateKey (#43982) 2024-07-10 18:50:39 +00:00
Nic Klaassen a48c4f7765 configurable key algorithms for proxy to database agent certs (#43329)
* configurable algorithms for proxy to database agent certs

* rfd edit

* use v1 suite in test

* fix typo

* fix bad merge
2024-06-26 23:06:22 +00:00
Nic Klaassen bcb169912d consolidate (un)marshalling of keys to/from PEM format (#43260)
* consolidate (un)marshalling of key PEMs

This commit consolidates various functions we have for marshalling
private and public keys to and from the PEM format, mostly by replacing
functions from lib/utils and lib/tlsca with equivalents in api/utils/keys.

The new functions also support ECDSA and Ed25519 keys, which is
necessary for the implementation of RFD136.

* speed up TestMTLSClientCAs

* fix new use in local proxy middleware
2024-06-21 19:32:11 +00:00
Forrest c653a844f1 add ability to disable unqualified hostname lookups (#42952) 2024-06-20 20:20:16 +00:00
Alan Parra 435a21badc chore: Bump AWS modules (#42316)
* chore: Bump AWS modules

* Tidy all modules

* Accept the "eu-isoe-west-1" AWS region as valid
2024-06-03 19:05:30 +00:00
Gavin Frazar 12c113bc84 add GCP Spanner (#40859) 2024-05-07 22:21:27 +00:00
Alan Parra 72780dce68 fix: Forbid SSO users from logging in using passwordless (#41062)
* Save the WebAuthn UserHandle in the mock Key

* Simplify passwordless tests

* fix: Forbid SSO users from logging in using passwordless

* Rename tests to TestPasswordlessProhibitedForSSO
2024-04-30 19:07:57 +00:00
Marco André Dinis 0ab0909367 Use HandshakeContext instead of Handshake for TLS Connections set up (#40588) 2024-04-29 07:31:31 +00:00
Zac Bergquist 8cd1c429f5 Fix up some poor wording (#40832)
Closes #40294
Closes #39172
2024-04-23 22:01:41 +00:00
Forrest 82281e1191 route based on match quality score (#40559) 2024-04-18 23:02:26 +00:00
Edoardo Spadolini e96f103954 Fix some gRPC-tunneled connections (#40632)
* Fix some gRPC-tunneled connections

* Fix tests checking the return value of dial()
2024-04-18 16:11:00 +00:00
5c930ca9a5 Fix flaky test TestProxySSHJumpHost (#40052)
* Use testServer.MakeTestServer to fix issue with parallel runs using the same ports.

* Add deprecation comments for test server helpers outside of tools/teleport/testenv.

* Update tool/teleport/testenv/test_server.go

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

* Disable SSH resumption

Enable LoadAllCAs

Update comments

* Prevent context.Canceled from being wrapped across transport stream

trail doesn't properly handle conversions to and from errors that
are context.Canceled which results in code paths trying to evaluate
errors.Is(err, context.Canceled) failing. The error recevied is
an interceptors.RemoteError, which wraps a trace.TraceErr, which
contains a status.Status with codes.Canceled. To work around this
until trail is updated the server half of the stream was updated
to return an io.EOF if if encouters a canceled error.

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Co-authored-by: Tim Ross <tim.ross@goteleport.com>
2024-04-04 21:20:30 +00:00
rosstimothy 8f1522bb34 Convert api to use slog instead of logrus (#39255)
THe use of slog now allows logrus to be removed from the api
module entirely.
2024-03-18 21:20:28 +00:00
Brian Joerger f57021d956 Don't count mfa-verifeid Private Key Policy as MFA for Admin Actions (#39257)
* Don't count hardware key support as MFA verification for admin actions.

* Add clarifying comments to IsMFAVerified methods to prevent future misuse.

* Update test.
2024-03-13 17:57:26 +00:00
Brian Joergerandrosstimothy 0b72ea691a Fix admin MFA flow for tctl bots add (#39220)
* Make the MFA for admin actions interceptor re-prompt for MFA when a request fails due to a reusable MFA response being denied by the server.

* Allow reused MFA for get/list tokens.

* Update api/utils/grpc/interceptors/mfa.go

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

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2024-03-12 20:23:33 +00:00
Brian Joerger 5577bdad45 Add e2e tests for Hardware Key support (#38994)
* Add fake yubikey private key implementation for tests.

* Add TestHardwareKeyLogin.

* Simplify Hardware Key support test plan.

* Enable piv test package in tests.

* Add TestMarshalAndParsePrivateKey.

* Address simple comments.

* Remove *testing.T from mockSSOLogin in; Add and use better helper methods for mocking sso login.

* Refactor test to dynamically set mock attestation data; revert related changes.
2024-03-07 21:37:21 +00:00
Krzysztof Skrzętnicki d6915c8dea Implement granular db permissions for Postgres (RFD 151) (#37808)
* Implement granular db permissions for Postgres (RFD 151)

* docs, whitespace

* Make sure query is closed, even in case of errors along the way

* fix imports
2024-03-04 19:28:22 +00:00
Brian Joerger 328986789e Hardware key serial number attestation (#37728)
* Add support for hardware key serial number attestation through user
trait.

* Modify AttestHardwareKey interface to return full attestation data

* Add serial number to attestation data and verify it

* Add unit test.

* Address comments.

* Don't accept partial matches.

* Fix build and test errors.
2024-02-10 01:07:58 +00:00
STeve (Xin) Huang 6684370580 Improve error message when auto-user provisioning fails on reader endpoints (#37557)
* Improve error message when auto-user provisioning fails on reader endpoints

* fix lint
2024-02-08 19:48:07 +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
Alan Parra f7dfb5ce81 fix: Do not wrap io.EOF intercepted by stream Sends (#37647)
* Verify that intercepted stream Sends wrap io.EOF

* fix: Do not wrap io.EOF intercepted by stream Sends

* Use a helper func, fix duplicate Send/Recv calls

* Fix typo
2024-02-01 18:05:06 +00:00
Brian Joerger 6a5a151809 Refactor admin MFA ceremony - don't create an MFA challenge the client can't solve (#37367)
* Refactor MFA ceremony logic to avoid creating challenges when the client has no way to solve it.

* Add client-side ErrMFANotSupported for better MFA ceremony error handling.
2024-01-29 18:38:25 +00:00
Brian Joerger bca9688bb2 Fix hardware key sign err shadow bug. (#37285) 2024-01-25 21:48:33 +00:00
Zac Bergquist 4329c28960 Remove some dead code (#37269) 2024-01-25 19:42:43 +00:00
357b2c8207 Refactor Admin Action MFA prompt (#37127)
* Move Admin Action RPC name to debug; rephrase client-visible prompt.

* Update api/mfa/prompt.go

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

* Update api/mfa/prompt.go

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

---------

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2024-01-24 19:36:03 +00:00
Brian Joerger 1db61a6a81 Client MFA Ceremony refactor (#36996)
* Refactor MFA prompt logic for the API client to enable various MFA
ceremony use cases.

* Address comments.
2024-01-23 01:16:18 +00:00
Alan Parra 96defc6065 fix: Do not attempt relogin on remote BadParameter errors (#36866)
* fix: Do not attempt relogin on trace.BadParameterError

* Special case remote errors in IsErrorResolvableWithRelogin

* Do not wrap Recv EOF errors

* Fix various tests

* Use errors.Is to check for io.EOF
2024-01-18 21:15:58 +00:00
rosstimothy a39c21716b Fix routing to public addresses (#36617)
#36584 allowed routing to work for public addresses, however it
used GetPublicAddr to retrieve the public address. types.Server can
have multiple public addresses though which means routing was only
ever considering the first public address defined. This updates
the routing logic to use GetPublicAddrs so they are all considered.
2024-01-12 15:35:29 +00:00
Andrew Burke ffeb59ea80 Route to server by public addr (#36584)
This change fixes a bug where tsh ssh could not dial a node with
its public address.
2024-01-11 20:34:05 +00:00
Brian Joerger e7ac968247 Address deprecation TODOs for or before v15. (#36473) 2024-01-11 01:03:22 +00:00
STeve (Xin) Huang 9402a41245 Added support to select database roles from tsh. (#35867)
* Support selecting db roles.

* add active roles in tsh db ls

* add select db role ut

* add a warning when connecting to older version

* review comments

* chnage slices import

* --db-roles to --db-role

* fix ut
2024-01-10 02:47:02 +00:00
Brian Joerger 01db597c04 Add fix for PIV PIN policy bug in YubiKeys with firmware version 5.3.1. (#36427) 2024-01-09 23:23:33 +00:00
Andrew Burke d29a6ed6c8 Add callback flag to tsh login (#35457)
This change adds the --callback flag to tsh login, which overrides
the base URL printed when doing an SSO login.
2024-01-09 19:32:58 +00:00
Zac Bergquist 44a6bb1933 Use pkg slices from the standard library (#35905)
Prefer the stdlib version of the experimental package.
Includes a depguard update to prevent future regressions,
as well as an e-ref update to appease depguard.

Generated with:

    $ gofmt -w -r '"golang.org/x/exp/slices" -> "slices"' . && \
        make fix-imports
2023-12-19 23:06:53 +00:00
Brian Joerger e99b342a1f Fix OTP prompt (#35537)
* Fix otp prompt; remove related dead code.

* Implement basic read waiting for fake readers in tests.

* Add regression test.
2023-12-12 20:43:43 +00:00
Andrew Burke 7221745bf8 Fix gcp ssh always using external IP (#35151)
This change fixes a bug where the discovery service would always try
to SSH into a GCP instance with its external IP address, which may
not exist.
2023-12-07 20:11:01 +00:00
Brian Joerger d3ff1deeb9 Clarify error message. (#35179) 2023-11-30 13:59:31 +00:00