Commit Graph
22 Commits
Author SHA1 Message Date
rosstimothy ef859498bc Vendor gravitational/trace/trail in api (#51032)
* Vendor gravitational/trace/trail in api

Pulling in the trail package directly in api will allow the trace
module to shed the grpc-go dependency. This needs to land prior
to https://github.com/gravitational/trace/pull/112 being included
in a new version of trace.

There should be no noticable change in the api depdency tree since
it already depends on grpc-go. Some additional items from the
trace/internal package were also vendored within trail as needed.
Additionally, some of the public api of trail that was not being
consumed has been made private.

* fix: appease linters
2025-01-14 21:04:01 +00:00
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
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 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
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
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
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 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
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 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
rosstimothy a5898a2a99 Convert tsh ssh to use the proxy transport service instead of ssh (#23228)
* Convert tsh ssh to use the proxy transport service instead of ssh

In an effort to reduce latency establishing sessions `tsh ssh` is
migrating away from connecting to the Proxy via SSH in favor of
using gRPC. The SSH handshakes with the Proxy increase latency in
situations where the distance between geolocations of the client
and Proxy are large. TLS handshakes used by the gRPC service have
proven to reduce latency by ~20% in the same scenario.

A new `lib/client.ClusterClient` has been introduced that should
be used instead of `lib/client.ProxyClient` to connect to a Teleport
cluster. Most of the functionality within the `ClusterClient` was
a direct copy from the `ProxyClient`.

The `lib/client.TeleportClient` now has a `ConnectToCluster` method
which will connect to both the Proxy and Auth service via the
`api/client.ProxyClient` which first attempts to use gRPC and reverts
back to SSH to preserve backwards compatability. The `ClusterClient`
should be passed around and reused instead of following the
established pattern of `tc.ConnectToProxy` followed by a
`proxy.ConnectToCluster` to get an `auth.ClientI`.

Additionally some of the `agentless` package was refactored to reduce
dependencies and allow it to work with connections to the Proxy that
originated via gRPC instead of SSH.

Changes to the integration tests are mostly to accomodate IP Pinning
and ensure that it works for both connections established via SSH
and gPRC.

This is the final PR needed to complete #19812.

* fix typos and unify span attributes

* pass node name to ConnectToNode

* simplify jump host resetting
2023-04-04 21:31:39 +00:00
rosstimothy 1427e194af Refactor stream.Source implementations (#23351)
The interface smuggling within `stream.ReadWriter.Close` now checks
for `io.Closer` instead of `grpc.ClientStream` to allow clients
that need to perform additoinal closing logic besides sending a
`CloseSend` message to do so. All existing client implementations
of `stream.Source` now implement `io.Closer` so they are still
cleaned up properly.

The multiplexed ssh streams are now tied together to prevent attempts
to send a message at the same time. In addition, the client ssh
streams have been updated to only send a single `CloseSend` on which
ever protocol is terminated first.
2023-03-22 14:33:16 +00:00
rosstimothy 9440763235 Implement transport client (#21947)
Provides a client that can be used to connect to and interact with
the transport service in `lib/srv/transport`. The client abstracts
the fact that a gRPC stream is being used for the `net.Conn` created
by `DialCluster` and `DialHost`.

This also moves `lib/utils/grpc/stream` to `api/utils/grpc/stream`
so that the client and server can make use of the same stream
abstractions.

Part of #19812
2023-02-21 14:38:57 +00:00