Commit Graph
1214 Commits
Author SHA1 Message Date
Brian Joerger 78c19bd65c feat: Hardware Key Agent - Add hardwarekey.Service interface with adapted PIV implementation (#53674)
* Add hardware key service interface; Add mock service for tests.

* Add piv implementation of hardware key service.

* Remove old yubikey parsing logic in favor of hardwarekey.PrivateKeyRef.

* Remove HardwareSigner in favor of hardwarekey.PrivateKey.

* Add test; Cleanup comment; Don't require pin/touch prompts in tests with MockHarwdareKeyService by default.

* Fix tests.

* Add TODOs.

* Use unhashed digest for WarmupHardwareKey.

* Address comments.

* Fix race condition in test service.

* Address comments.
2025-04-09 22:14:19 +00:00
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
Andrew Burkeandjoerger b4b79e3928 Enable SSO MFA for headless (#53741)
This change adds support for SSO MFA in headless mode.

Co-authored-by: joerger <bjoerger@goteleport.com>
2025-04-07 19:26:21 +00:00
Zac Bergquist 693d110642 fix: use Go 1.18+ build tag syntax (#53746)
All of our supported release branches are well past Go 1.18, so
we don't need to support the old build tag syntax.

Changes made by running `go fix ./...`.
2025-04-07 12:35:51 +00:00
Lisa Kim a2e401650b Partial revert of CSRF auth related removals (#53367)
* Partial revert of CSRF auth related removals

Required to support backwards compatibility of the enterprise
plugin endpoint.

* Remove CSRF checking in header

* Address CR

* Inline helper funcs
2025-04-01 20:32:04 +00:00
rosstimothy be8fe5c76d Join Kubernetes sessions in the web ui (#52993)
Adds the ability to join existing Kubernetes sessions in the web ui
as peers, observers, or modertators.

Closes #52315.
2025-03-25 14:14:48 +00:00
STeve (Xin) Huang 5ea6361215 make sure db route is converted from tlsca to proto (#53246) 2025-03-21 14:20:37 +00:00
Noah StrideandMarco Dinis 0586278cde Migrate GetClusterName to gRPC (#53164)
* Adjust GetClusterName method signature to include context.Context

* Start hacking on gRPC GetClusterName impl

* Fix test mocks to match signature

* Fix integration tests

* Fix integrations tests

* Missing ctx

* New GetClusterName RPC implementatin

* Add fallback cluster name

* Correct godoc comment

* Remove unused method

* Remove unused import

* Fix E2E test

* Fix tests

* Fix deferred context cancel in test conflicting with parallel subtests

* Fix import

* Fix imports

* Update lib/auth/auth_with_roles.go

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>

---------

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>
2025-03-20 10:07:02 +00:00
Krzysztof Skrzętnicki 7d7e9d3fe3 Support -oSendEnv in tsh (#53010)
* Support `-oSendEnv` in `tsh`

* Fix spelling
2025-03-20 07:52:45 +00:00
STeve (Xin) Huang 54652cf690 Force directConnection=true for mongo clients (#52979) 2025-03-12 13:58:18 +00:00
Erik Tate 7f3eb19d61 removing TOTP as a valid MFA method when using per-session MFA (#52602) 2025-03-11 17:50:25 +00:00
Zac Bergquist b0049ecc2a Remove the custom current user lookup function (#52144)
We added this function to mitigate slow user.Current() calls in
Windows Active Directory environments. Go 1.24 ships with an optimized
verison of user.Current, rendering this utility unnecessary.

Closes #41922
2025-03-04 23:43:54 +00:00
Rafał CieślakandGrzegorz Zdunek 468663ed91 Add version incompatibility warning to Connect (#51832)
* Refactor client version compat for reuse in lib/teleterm

* Remove ClustersService.getAuthSettigns, add test helper

* FormLogin: Nest AuthSettings under distinct prop

* Return client version status with auth settings

* Add UI for compatibility warning

* Do not use wildcards for TOO_OLD to mirror tsh

Also, handle TOO_OLD first to mirror lib/client/api.go.

* Adjust buttons to mirror the look of primaryAction/secondaryAction of Alert

* Do not show pre-release "-aa" suffix

* Fix title case in button

* Add skipVersionCheck to docs

---------

Co-authored-by: Grzegorz Zdunek <grzegorz.zdunek@goteleport.com>
2025-03-03 16:29:50 +00:00
rosstimothy 967053bb94 Use b.Loop in benchmark tests (#52520)
Prefer using b.Loop instead of b.N style benchmarks now that we are
using Go 1.24.

See https://pkg.go.dev/testing#B.Loop for more details.
2025-02-26 19:08:05 +00:00
Vadym Popov 0da5d6e1c6 Prevent keystore cleanup to remove bin directory (#52331) 2025-02-20 05:14:58 +00:00
fheinecke e3615114b6 Add support for JSON format to '/webapi/auth/export' endpoint (#50193)
* Add support for HTTP 'Accept' header to '/webapi/auth/export' endpoint

Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>

* Switch PR to use new `format` parameter

---------

Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>
2025-02-19 21:41:35 +00:00
Stephen LevineandEdoardo Spadolini 13edd077e1 [teleport-update] Add proper healthcheck for agents (#51613)
* Add socket readiness monitor

* cleanup

* add 404 check

* check

* better cleanup

* fix bug

* typo

* fix 404

* improve logging

* cleanup

* disable socket redirect

* avoid race condition with socket removal

* verify PID

* cleanup

* Update lib/autoupdate/agent/process.go

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

* feedback

* fix subtle race condition

* debugging

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2025-02-05 16:57:38 +00:00
Forrest b9232c3013 transition ssh enforcement to sshca.Identity (#51468) 2025-02-04 18:01:53 +00:00
rosstimothy 2cced62805 Fix violations of non-constant format strings linter (#51812)
Depends on https://github.com/gravitational/teleport.e/pull/6006.
Now that we are compliant, the ignore rule was removed from the
golangci-lint config to prevent future regressions.
2025-02-04 16:43:35 +00:00
rosstimothy b25252a39e Prevent reauthentication for tilde prefix expansion errors (#51464)
In https://github.com/gravitational/teleport/pull/24254 expansion
of tilde prefixes(i.e. `tsh scp CHANGELOG.md root@host:~foo/`) was
explicitly denied. However, because the error returned to the user
is a trace.BadParameter error the reauthentication logic kicks in
and attempts to resolve the issue with fresh credentials. This
error is now caught and wrapped in a NonRetryableError to prevent
the authentication logic from providing a weird UX.

Updates https://github.com/gravitational/teleport/issues/22886.
2025-01-29 22:48:01 +00:00
Zac Bergquist 889f02d12f Remove an old TODO re: tsh key TTLs (#51514) 2025-01-27 23:04:04 +00:00
Forrest 5791a9888a Add host fields and protos for ssh identities (#51024)
* add host fields to sshca.Identity

* add ssh identity proto
2025-01-27 18:51:37 +00:00
STeve (Xin) Huang 4d7ce4506e Refactor integration CA export (#51427)
* Refactor integration CA export

* remove UseCompatVersion

* add more comments
2025-01-27 14:15:09 +00:00
Nic Klaassen c8d8c21578 [vnet] refactor AppProvider for Windows implementation (#51216)
* [vnet] refactor AppProvider for Windows implementation

* allow empty cert pool

* fix unconvert lint

* fix root cluster ca pool

* edit log message

* return errors when failing to get appinfo for matching app

* edit comment on ClientApplication interface

* add missing license header
2025-01-24 00:10:27 +00:00
Alan Parra 2e89fd72c7 feat: Support multiple active CAs in Web exports (#51301)
* Move /auth/export code to own file

* Implement "/auth/export?format=zip"

* Refactor existing tests

* Test format=zip

* Fix comment

* Use bytes.NewReader

* Remove lib/client.ExportAuthorities
2025-01-23 14:34:13 +00:00
Alan Parra 6181c0bed2 feat: Support multiple active CAs in tctl auth export (#51298)
* Support multiple active CAs in `tctl auth export`

* Remove the ExportAuthoritiesSecrets func

* Mention path in the --out-prefix help

* Rename --out-prefix to --out

* Write script-friendly output
2025-01-22 19:31:23 +00:00
Alan Parra e442174257 Add client-side functions to export multiple authorities (#51189)
* Introduce ExportAll functions

* Refactor tests

* Test ExportAll in existing test suite

* Test ExportAll with multiple active CAs

* Update godocs

* Update godocs
2025-01-22 15:14:42 +00:00
Vadym Popov fc01a5a698 Fix auto-update re-exec arguments modified by aliases (#50228)
* Fix auto-update re-exec arguments modified by aliases

* Make arguments to be required to set

* Restore progress bar show before request

* Improve integration tests to execute with `tsh` and `tctl`

Added a full-cycle integration test to verify client tools
auto-updates within a test cluster by modifying AutoUpdateConfig
and AutoUpdateVersion resources. The test executes the login
command using alias configurations to ensure no recursive
re-execution occurs.

The updater binary used in integration tests has been replaced
with the `Run` logic of tctl and tsh.

* Set generated test password by env variable instead of constant value

* Restore priority of env check over remote check

In case of double re-execution case we should stop second one to prevent loop re-execution
Drop localDir set during compilation
2025-01-17 09:54:45 +00:00
Paul Gottschling 70d70a2d60 Fix outdated docs URLs (#50923)
- Web UI source
- README
- lib
- api

Do not touch docs URLs in test case names or test data where we don't
expect users to navigate to the URLs.
2025-01-16 18:17:35 +00:00
rosstimothy 063603ad78 Remove any notion of teleport namespace from tsh (#51076)
Updates https://github.com/gravitational/teleport/issues/49509.

Most of the places namespaces were already configurable were had
been forcing the default namespace. This extends that by removing
the ability to pass in a custom namesapce and hardcodes the
default namespace at the inner most call site to reduce the surface
area of namespaces.

With the removal of the --namespace flag from the base tsh command,
kubernetes subcommands have also been updated to use --namespaces
in addition to --kube-namespace. The former should be preferred,
while the later exists solely for backward compatibility.
2025-01-15 19:13:48 +00:00
Brian Joerger 4c1264cb44 Fix defunct TestX11Forward (#51035)
* Fix test.

* Expect context canceled error in test.
2025-01-15 18:30:49 +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
rosstimothy 883c53a53c Remove logrus dependency (#50930)
This is the _last_ step required to migrate from logrus to slog.
All components in the repository have been migrated to use slog
allowing the logrus formatter to be deleted.

The slog handler tests that validate the output have been updated
to assert the format directly instead of comparing it to the output
from the logrus formatter.
2025-01-10 16:58:56 +00:00
Forrest a26c2a94e8 add ssh identity object (#50787) 2025-01-09 22:30:37 +00:00
Lisa Kim d5409cb481 Create v2 web api endpoints and required related changes (#50472) 2025-01-09 19:58:52 +00:00
rosstimothy 2aed5bf6da Remove logrus (#50829)
* Remove all direct logrus usage from teleport module

The only remaining use of logrus is from integrations, which is
unfortunately imported by teleport.e, and prevents logrus from
being moved to an indirect dependency. The logrus formatter and
initialization of the logrus logger will remain in place until
integrations is using slog. To prevent any accidental inclusions
of logrus within the teleport module the depguard rules have been
updated to prohibit importing logrus. The rules also include
prohibit a few common log packages that tools like gopls might
automatically import.

* Refactor logger initialization

Consolidates configuring of global loggers to a single function.
This is mainly to facilitate configuring the logger for
teleport scp, but will also allow us to remove the copy of logger
initialization that currently exists in integrations/lib/logger.

* fix: document ValidateFields

* fix: remove copied yaml tags

* fix: update file path comment
2025-01-09 16:41:28 +00:00
Forrest c6ad9b221e add emptiness testutils (#50655)
* add emtiness testutils

* move golden to testutils
2025-01-07 16:36:01 +00:00
Krzysztof Skrzętnicki 7b0de4136e Support Oracle connections without wallet (#49753)
* Add support for Oracle connections without wallet. Backwards compatible.

* Bypass maybeAddOracleOptions for non-Oracle protos

* use named const

* fix lint issues

* Update PR to slog

* lint fix
2025-01-03 18:01:46 +00:00
Steven Martin 46ed1f4486 update log messages (#50679) 2025-01-02 16:54:07 +00:00
Gabriel Corado b48b9a6249 refactor: use websocket error send on repl errors (#50613) 2025-01-02 16:39:02 +00:00
Rafał Cieślak 1e2b257107 tsh proxy app: Add support for multi-port TCP apps (#50429)
* Pass around PortMapping rather than port as string

* Pass target port to local proxy

* Validate target port

* Accept target-port flag in tsh app login

* Don't reuse certs for multi-port apps

* Add a test for multi-port tsh proxy app

* Use strings.Cut instead of strings.SplitN

* Remove appInfo from localProxyApp

* Remove unused method appInfo.appLocalCAPath
2025-01-02 16:05:21 +00:00
Steven Martin d0463ec931 update log messages (#50673) 2025-01-01 15:27:05 +00:00
Zac Bergquist e356649f3c Complete CSRF cleanup for Teleport 18 (#50534)
* Restore CSRF Token for SSO flows

This is a partial revert of #50358.
We need to keep the CSRF token in the SSO flows for now, as it is
used to ensure that the flow is completed by the same actor who
initiated the sign-on.

* Make the purpose of the lib/httplib/csrf package clear

This package is only used to protect against login CSRF with SSO flows.

Teleport's web API is protected from CSRF by nature of using a bearer
token, and does not require this package. This particular pacakge is
only necessary for SSO because the user is not yet logged in when the
SSO flow begins, so they don't have a bearer token.

* Remove the remaining bits of unneeded CSRF code

Additionally expand upon the godocs for our various middlewares
so that it's clear which ones provide CSRF protection.
2024-12-30 15:38:24 +00:00
rosstimothy 60aaa6dc1a Convert lib/client to use slog (#50498) 2024-12-23 18:46:43 +00:00
rosstimothy c61461b4fd Improve client tools host resolution (#50175)
Host resolution performed because labels, fuzzy search, or predicate
expressions were supplied to commands that establish connections to
a single host has historically been performed client side in tsh.
While that works in most cases, it can prevent correctly
resolving hosts in some situations, i.e. when there are ambiguous
hosts and tsh is unaware that the cluster routing strategy is set
to ROUTE_TO_MOST_RECENT.

To improve the experience, a new ResolveSSHTarget was added to
Auth to allow host resolution to be performed server side. The
resolution works in a similar manner to, and was inspired by
GetSSHTargets. In the event that the new RPC is not implemented,
because the client is newer than Auth, tsh has also been updated
to pull the cluster networking config and address any host
ambiguity if allowed.

As a result tsh scp and tsh proxy ssh should be much more
tolerant to, and still permit access in situations where
ambiguous hosts are present for some amount of time. Prior to
this the only way to connect in these situations was to find
the UUID of the correct target instance and try again after
seeing an ambiguous host error.
2024-12-20 15:57:26 +00:00
Brian Joerger 7269273fb5 Add SSO MFA prompt for WebUI MFA flows (#49794)
* Include sso channel ID in web mfa challenges.

* Handle SSO MFA challenges.

* Handle sso response in backend.

* Handle non-webauthn mfa response for file transfer, admin actions, and app session.

* Simplify useMfa with new helpers.

* Fix lint.

* Use AuthnDialog for file transfers; Fix json backend logic for file transfers.

* Make useMfa and AuthnDialog more reusable and error proof.

* Use AuthnDialog for App sessions.

* Resolve comments.

* Fix broken app launcher; improve mfaRequired logic in useMfa.

* Fix AuthnDialog test.

* Fix merge conflict with Db web access.

* fix stories.

* Refactor mfa required logic.

* Address bl-nero's comments.

* Address Ryan's comments.

* Add useMfa unit test.

* Fix story lint.

* Replace Promise.withResolvers for compatiblity with older browers; Fix bug where MFA couldn't be retried after a failed attempt; Add extra tests.
2024-12-20 03:51:12 +00:00
Zac Bergquist a9d27e1d02 Fix web session playback when a duration is not provided (#50262)
Prior to Teleport 15, the web UI would download the entire session
recording into browser memory before playing it back (crashing the
browser tab for long sessions).

Starting with Teleport 15, session playback is streamed to the
browser and played back as it is received instead of waiting for
the entire session to be available.

A side effect of this change is that the browser needs to know
the length of the session in order to render the progress bar
during playback. Since the browser starts playing the session
before it has received all of it, we started providing the length
of the session via a URL query parameter.

Some users have grown accustomed to being able to access session
recordings at their original URLs (without the duration query
parameter). If you attempt to play recordings from these URLs after
upgrading to v15, you'll get an error that the duration is missing.

To fix this, the web UI needs to request the duration of the session
before it can begin playing it (unless the duration is provided via
the URL). There are two ways we could get this information:

1. By querying Teleport's audit log
2. By reading the recording twice: once to get to the end event
   and compute the duration, and a second time to actually play
   it back.

Since we only have a session ID, an audit log query would be
inefficient - we have no idea when the session occurred, so we'd
have to search from the beginning of time. (This could be resolved
by using a UUIDv7 for session IDs, but Teleport uses UUIDv4 today).

For this reason, we elect option 2. This commit creates a new web
API endpoint that will fetch a session recording file and scan through
it in the same way that streaming is done, but instaed of streaming
the data through a websocket it simply reads through to the end to
compute the session length. The benefit of this approach is that it
will generally be faster than option 1 (unless the session is very
long), and it effectively pre-downloads the recording file on the

Note: option 2 is not without its drawbacks - since the web UI is making
two requests that both read the session recording, the audit log will
show two separate session_recording.access events. This isn't ideal
but it is good enough to get playback working again for customers
who don't access playbacks by clicking the "Play" button in the UI.
2024-12-19 18:07:36 +00:00
rosstimothy 267b9f0f26 Convert lib/teleterm to use slog (#50335) 2024-12-18 22:46:08 +00:00
Gabriel Corado 903b5f5cbe Add WebSocket handler for WebUI database sessions (#49749)
* feat(web): add websocket handler for database webui sessions

* refactor: move common structs into a separate package

* refactor(web): use ALPN local proxy to dial databases

* feat(repl): add default registry

* refactor(web): code review suggestions

* refactor: update repl config parameters

* refactor: move default getter implementation

* feat(web): add supports_interactive field on dbs

* refactor: code review suggestions

* refactor: update database REPL interfaces

* chore(web): remove debug print

* feat: register postgres repl

* refactor(web): update MakeDatabase to receive access checker and interactive

* chore(web): remove unused function
2024-12-14 02:16:29 +00:00
Gabriel Corado 89ea69cafa Add PostgreSQL REPL implementation (#49598)
* feat(repl): add postgres

* refactor(repl): change repl to use a single Run function

* test(repl): reduce usage of require.Eventually blocks

* refactor(repl): code review suggestions

* refactor(repl): code review suggestions

* test(repl): increase timeout values

* fix(repl): commands formatting

* refactor(repl): send close pgconn using a different context

* fix(repl): add proper spacing between multi queries

* test(repl): add fuzz test for processing commands
2024-12-13 19:44:37 +00:00