Commit Graph
158 Commits
Author SHA1 Message Date
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
Brian Joerger f3feb7fa12 Add WebAuthn support for admin actions in the WebUI (#34814)
* Add WebAuthn support for admin actions in the WebUI.

* Resolve comments; Use async/await.

* Resolve comments.

* Re-add universal mfa parsing logic to the web server.

* Fix lint.

* Address comments.

* Incorporate suggested changes.

* Fix lint.
2023-11-28 19:14:03 +00:00
Brian Joerger d21b17cfc7 Re-add missing MFA prompt hint logic. (#34802) 2023-11-21 19:33:11 +00:00
Brian Joerger 9c70432929 Fix default key slot comments and docs. (#34350) 2023-11-09 18:15:46 +00:00
Brian Joerger 621c7b3a5b Make MFA prompt client agnostic (#34087)
* Make MFA prompt client agnostic for universal use, e.g. in Teleport Connect.

* Refactor to address CR.

* Resolve comments.

* Add tc.PromptMFA.

* Fix lint.

* Extract common high level interfaces and structs into api/mfa for better flexibility in API MFA prompts.

* Resolve comments.

* Remove unused field.

* Fix miss-set quiet field.
2023-11-09 18:14:12 +00:00
rosstimothy d5a796c056 Enable testify lint (#34222)
Updates our golangci-lint configuration to enable testifylint and
fixes all issues found.

Bump e ref to include gravitational/teleport.e#2567
2023-11-06 20:38:38 +00:00
Nic Klaassen 8421f0b875 feat: generate randomized ExternalCloudAudit config (#33555) 2023-10-20 19:15:45 +00:00
Brian JoergerandMike Jensen 129df08ba4 Enable hardware key support in the WebUI (#32781)
* Add web_session private key policy.

* Add attestation logic for web session.

* Prevent users from retrieving their own web session secrets.

* Update RFD.

* Attest extended web sessions if the original web session was attested.

* Update rfd/0080-hardware-key-support.md

Co-authored-by: Mike Jensen <jentfoo@users.noreply.github.com>

* Fix policy set unit test.

---------

Co-authored-by: Mike Jensen <jentfoo@users.noreply.github.com>
2023-10-13 19:59:11 +00:00
Brian Joerger c0b3299de7 Add support for Hardware Key PIN (#31743)
* Update RFD with hardware key pin policies.

* Consolidate policy logic and update tests.

* Add pin private key policies; Make PIV PIN/Touch prompts work together.

* Prompt user to set pin/puk from default.

* Handle unexpected PIN auth errors.

* Resolve RFD password prompt comment.

* Handle incompatible private key policy in role sets (future-proof).

* Resolve comment on require mfa type string godocs and tests.

* A satisfying change.

* Address PIN/PUK prompt comments and other code suggestions.

* Resolve comments.

* Fix test that prompts for pin twice.

* Fix test.
2023-10-13 19:07:43 +00:00
Brian Joerger 4d094a7743 Remove deprecate function; update e ref. (#32275) 2023-10-12 00:31:46 +00:00
Brian Joerger a36d4d1e34 Configure custom PIV slot for hardware key support (#31732)
* Update RFD.

* Add custom PIV slot logic.

* Add custom piv slot to cluster auth preference.

* Fix error handling of parsing private key policy errors.

* Add new PIVSlot string type.
2023-10-11 01:36:22 +00:00
Michael Wilsonandrosstimothy ed488aabcc Add the Access List review backend. (#32924)
* Add the Access List review backend.

The Access List review backend has been added to Teleport.

* Update tests to remove frequency_changed.

* Update lib/services/access_list.go

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

* Update lib/services/access_list.go

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

* Tweak errors, add gRPC client to go along with new interfaces.

* Update comments, fix errant bugs with api client, remove reviews getter.

* Fix comments in proto, tweaks to tests and backend.

* Remove call to SetName.

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2023-10-05 20:32:25 +00:00
Marco André Dinis 44209ce8dc DiscoveryMatchers: move checkandset to types package (#32857)
* DiscoveryMatchers: move checkandset to types package

* add opensearch to iamrole as users
2023-10-04 13:48:09 +00:00
Brian Joerger 2c53f04310 Client check for YubiKey private key touch/pin policies (#32264)
* Preemptively check yubikey private key touch/pin policies on the client side.

* Replace hardware key signer functions with private key methods.

* Refactor overwrite/generate key logic.
2023-09-29 00:10:05 +00:00
Brian Joerger f87c46ad73 Make Hardware Key unit test interactive (#32235)
* Make yubikey unit test interactive and add to test plan.

* Move yubikey hardware signer method tests to interactive yubikey test.

* Remove hardware key interactive unit test from testplan
2023-09-27 18:55:47 +00:00
Andrew Burke cf3bf183b9 Drain unused SSH channels (#32505)
This change drains unused SSH channels and requests to prevent a
situation where an attacker could repeatedly open channels and
send data that won't be read, causing Teleport to eventually run
out of memory.
2023-09-27 17:05:48 +00:00
Brian Joerger 64d94666b7 Refactor PIV metadata certificate logic (#32250)
* Change PIV metadata cert to be self signed by an ephemeral key so it can be signed without touch/pin.

* Refactor touch prompt logic.

* Prompt user before overwriting non-teleport certificates instead of just returning an error.

* Update RFD and Docs.

* Address CR.

* Export some methods and variables for use in tests.

* Address comments.
2023-09-26 18:04:40 +00:00
Alan Parra 13c283036b Deprecate AddMFADevice and its top-level messages (#32516)
* Test registration with unusable devices

* Count devices according to cluster settings

* Use AddMFADeviceSync in test helpers

* Use AddMFADeviceSync on lib/auth tests

* Remove AddMFADeviceRequestInit from mfaAddTestOpts

* nit: Pass testing.T to lib/web.TestTerminalRequireSessionMFA funcs

* Ignore AddMFADevice usage in interceptor tests

* Deprecate AddMFADevice and its top-level messages

* Update generated protos

* Deprecate lib/client RPC wrapper

* Deprecate AddMFADevice in lib/auth.IdentityService

* Address deprecation warnings
2023-09-26 13:16:29 +00:00
Brian Joerger 1c88f9ed1b Move lib/utils/prompt to api/utils/prompt (#32334)
* Move /lib/utils/prompt to /api/utils/prompt.

* Replace uses of lib/utils/prompt with api/utils/prompt and delete pacakge.

* go mod tidy.
2023-09-25 19:31:37 +00:00
Brian Joerger adb4194e3b Fix tsh logout with broken key dir (#32351)
* Check for compare failed error when checking user's keys.

* Add test.

* Return not found error when tls certificate is missing.
2023-09-22 17:47:28 +00:00
Brian Joerger 7a9a987847 Have hardware_key_touch count towards MFA verification instead of replacing the normal MFA verification flow. (#31663) 2023-09-18 16:47:34 +00:00
STeve (Xin) Huang 76e5747baf Validate unknown AWS regions from discovery matchers (#31533)
* Validate unknown AWS regions from discovery matchers

* move and simply regex check
2023-09-13 15:54:41 +00:00
Brian Joerger 9b29150ca0 Add MFA prompt to Clients for Admin Actions. (#30203)
* Add MFA PerRPCredentials.

* Add RetryWithMFA unary interceptor.

* Add MFA prompt retry mechanism for Admin API requests.
2023-08-25 19:14:13 +00:00
Brian Joerger cf6473feb9 Add gRPC error interceptors to API client (#30578)
* Move gRPC error intercetpors to api/utils/grpc/interceptors.

* Use error interceptors in api client and mock server.

* Apply suggestions from CR.

* Unwrap FromGRPC errors in middleware.

* Use gRPC auth service in tests instead of external example service.

* It's gRPC!!!

* Fix unit test.

* Add error interceptor to proxy client.

* Fix merge conflict.
2023-08-24 23:27:06 +00:00
Forrest 4e66a6fc67 support case-insensitive routing option (#29320)
* support case-insensitive routing option

* update docs
2023-08-17 00:48:19 +00:00