Commit Graph
1002 Commits
Author SHA1 Message Date
rosstimothy e857153bb9 Switch from mattn/go-sqlite3 to modernc.org/sqlite (#55940)
* Switch from mattn/go-sqlite3 to modernc.org/sqlite

* fix: import sqlite in utmp test

* fix: encode connection uri params
2026-02-12 15:40:16 +00:00
Erik Tate e7ecc19c19 adding immutable labels to scoped tokens and host certificates (#62941) 2026-02-06 20:57:03 +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 <chris.thach@goteleport.com>

* Revert changes to testlib package.

Signed-off-by: Chris Thach <chris.thach@goteleport.com>

---------

Signed-off-by: Chris Thach <chris.thach@goteleport.com>
2026-02-06 19:42:33 +00:00
Kenneth fc5bdb1535 Revert "Created check for device trust after MFA before creating web session (#62019)" (#63523)
This reverts commit ddc4586440.
2026-02-06 03:44:30 +00:00
Marek Smoliński d4f2c9ef27 Align helper.StartAndWait wait time (#63190) 2026-02-02 14:08:10 +00:00
Maxim 7d2d2a891d Access Requests: Add Resource-Scoped Constraints (#60123)
* feat: Extend `AWSRole` struct w/ `RequiresRequest`

- Differentiate between already-granted vs. requestable AWSRoles when
  including requestable resources in `clusterUnifiedResourcesGet`
  req

* feat: Implement Resource Constraints support for Proxy, Auth

* fixup: Fix tests

* test: Add tests for resourceaccessid-related helpers

* fixup: Address code review feedback

* test: Update identity/events tests for new `ResourceAccessID` fields

* fixup: Expand/improve godocs/comments for sentinel ResourceID handling

* fixup: Address code review feedback

* feat: Conv ResourceID->ResourceAccessID at cert decoding

- Convert ResourceIDs present on certs to ResourceAccessIDs at decoding
  time, rather than at each callsite. Update tests/usages of tlsca/sshca
  Identities to reflect this.
2026-01-27 14:51:52 +00:00
Kenneth ddc4586440 Created check for device trust after MFA before creating web session (#62019) 2026-01-23 21:25:10 +00:00
rosstimothy 6590c944b6 Inject modules into keygen (#62843)
Contributes to #62799.
2026-01-16 18:52:50 +00:00
Marek Smoliński 94897a4e02 Add WebClientPack.Renew method (#62761) 2026-01-13 09:25:51 +00:00
Andrew Burke b7158a4235 Fix path errors moderated sftp (#62281)
This change fixes handling non-absolute paths in
moderated sftp.
2025-12-22 21:32:13 +00:00
Tiago Silva d2529eedf0 fix: Drain participant stdout to prevent blocking in kube join test (#62348)
Add goroutine to continuously drain participant stdout stream to ensure
the test doesn't block on write operations during session cleanup and we
release the resources.

Fixes https://github.com/gravitational/teleport/issues/55044

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2025-12-18 14:33:28 +00:00
Tiago Silva fc07a33534 Improve resource cleanup in TestKube/Join (#62238)
Move cleanup operations to t.Cleanup to ensure proper resource release.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2025-12-16 16:37:48 +00:00
rosstimothy 32f073e75b Disable unused services in Kubernetes tests (#62247) 2025-12-15 16:36:10 +00:00
Tiago Silva a52060cc55 Fix flaky TestKube/Join by using io.Pipe instead of os.Pipe (#62229)
In TestKube/Join, we previously used os.Pipe[1] to create stdin for the
test. However, os.File instances are implicitly closed when garbage
collected via a runtime finalizer inserted in newFile[2].

Under CPU-constrained conditions, the garbage collector can run
mid-test and detect that participantStdinW is no longer referenced.
This triggers the finalizer, which closes the writer file descriptor,
causing the reader to receive io.EOF.

Since Kubernetes terminates exec sessions when stdin closes, the EOF
can arrive before the client receives the server payload, causing the
test to fail intermittently.

Replacing os.Pipe with io.Pipe resolves this issue, as io.Pipe does
not use file descriptors and is not subject to finalizer-based cleanup.

[1] https://github.com/golang/go/blob/1b291b70dff51732415da5b68debe323704d8e8d/src/os/pipe_unix.go#L27
[2] https://github.com/golang/go/blob/1b291b70dff51732415da5b68debe323704d8e8d/src/os/file_unix.go#L224

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2025-12-13 23:30:42 +00:00
Maxim 4ebec265ed Add paginated ListAuthServers/ListProxies (#61702)
* types: Add `ListAuthServers`/`ListProxyServers` to PresenceService

- Add `ListAuthServers` and `ListProxyServers` RPCs to PresenceService

* feat: Implement `ListAuthServers`/`ListProxyServers`

- Implement new funcs
- Mark `GetAuthServers`/`GetProxies` deprecated
- Replace existing usages
2025-12-12 21:42:28 +00:00
rosstimothy 2a5c3077d2 Disable session resumption in TestIntegrations/Disconnection (#62143)
Updates https://github.com/gravitational/teleport/issues/39515
2025-12-11 17:25:21 +00:00
Luke Okraszewski b97757c13c [config] expose auth reconnect retry parameters in configuration (#61835)
* [cfg] expose auth reconnect retry parameters in configuration

The new YAML config is as follows:
```
reconnect_backoff:
    max_period: "90s"
    min_period: "9s"  # When unset max_period / 10
    step: "18s"       # When unset max_period / 5
```

Note that currently this only exposes the existing linear backoff, but
the naming here is generic enough that we could consider other policies if needed.

Changelog: Added a new global configuration section `reconnect_backoff` allowing users to configure the backoff behaviour for instances attempting auth connections.

* better naming

* fix ratios for defaults

* fix default config test

* clarify instance type
2025-12-10 17:52:59 +00:00
Nic Klaassen b1f44e526e improve hsm test cleanup (#61841) 2025-12-09 18:39:39 +00:00
Alan Parra 2740ad632a chore: Bump golangci-lint to v2.7.2 (#62066)
* chore: Bump golangci-lint to v2.7.2

* Update e/ reference

* Fix require.IsType issues

* Reverse require.Equal

* Simplify testWebsockets

* Fix TestCreateResources

* Remove trace.Unwrap
2025-12-09 17:59:21 +00:00
Grzegorz Zdunek cd3c8f84ee Fix unrecoverable ssh cert errors in tsh/Connect (#61322)
* Initialize default Username/HostLogin only in tsh

* Move `Username()` from `api.go` to `tsh.go`

* Remove wrong `Profile.SiteName` default

* Remove resetting `SiteName`

Not sure why it was needed. Perhaps to clear the default that we just removed? But even if add the default back and remove this fix, everything works.

* Gracefully handle missing SSH/TLS certs

* Remove unused `TeleportClient.LoadKeyForClusterWithReissue`

* Revert "Move `Username()` from `api.go` to `tsh.go`"

This reverts commit f7ff0ff6d1.

* Revert "Initialize default Username/HostLogin only in tsh"

This reverts commit ed38babf5e.

* When any of SSH/TLS cert is missing, return partial profile

* Only log non-nil errors

* Revert "Remove wrong `Profile.SiteName` default"

* Revert "Remove resetting `SiteName`"

This reverts commit f54ab3f22a.

* Set `SiteName` when adding cluster

* Improve comments

* Add test

* Fix test

* Add myself to TODO

* Add test for logging out with missing SSH cert

* Lint
2025-11-28 10:12:24 +00:00
Andrew Burke e1a1bf214a Fix runcommand attempt outputs clobbering each other (#61681) 2025-11-25 23:26:57 +00:00
rosstimothy 8075f2ac6d Reduce flakiness of TestIntegrationsRegular (#61740)
The test was reliant on entering \a as input to a
session which signaled to sleep for 1s before writing
the data. This made the test undeterministic because
the 1s delays might not have been long enough for the
second party to have joined and start consuming the
session data.

This changes the test to validate that the appropriate
number of parties are in the session before proceeding
to the next step of the test. All \a have been removed
from terminal input as we now know for certain that the
session contains the appropriate parties before any
input is entered.


Closes https://github.com/gravitational/teleport/issues/25982.
Closes https://github.com/gravitational/teleport/issues/13699.
2025-11-25 18:47:00 +00:00
rosstimothy 30d1f17dbf Improve reliability of waitForSessionToBeEstablished (#61736)
Several integration tests make use of the function to
know that a session was created, a SessionTracker was
created in the backend, and to retrieve the session id.

The function polled the backend for session trackers
until the context deadline set in individual tests
was exceeded. In an effort to reduce flakiness and
make the API easier for callers the helper has been
rewritten. It now leverages a require.Eventually
internally, has a hardcoded limit of 30s instead of
allowing each test to define their own, and validates
the number of expected participants in a session.


Closes https://github.com/gravitational/teleport/issues/17224.
Closes https://github.com/gravitational/teleport/issues/36959.
2025-11-25 16:37:19 +00:00
rosstimothy fdbd386e40 Prevent flakiness in TestKube/Join (#61693)
The test was reliant on all the output of a session being
replicated to all parties before a 5s timer closed the session.
To make the test more resiliant it was rewritten such that
it validates the expected output from one of the parties output,
then exits the session, then when all parties have been closed,
it examines the entire output of the other parties to validate
their output.

Fixes https://github.com/gravitational/teleport/issues/55044
2025-11-22 16:32:28 +00:00
rosstimothy 2428299b47 Reduce flakiness of TestIntegrations/TrustedCluster tests (#61700)
The tests establish trust between two clusters, connect via SSH
to a host in the leaf, tear down trust, reestablish trust, and
then attempt another SSH connection. The flakiness stemmed from
tearing down and and reestablishing trust too quickly without
first properly verifying that the leaf cluster disappeared from
the root before reestablishing trust. While the test did make
use of `helpers.WaitForClusters`, it is satisfied if tunnels
for clusters were healthy within the last 10s. But this could
be true of a stale cluster that was not yet cleaned up. To
remedy this the test was updated to first wait for the reverse
tunnel for the leaf cluster to be completely gone before
reestablishing trust and proceeding.

Closes https://github.com/gravitational/teleport/issues/60836.
Closes https://github.com/gravitational/teleport/issues/48823.
2025-11-22 00:16:27 +00:00
rosstimothy 3fb1534f88 chore: integration test improvements (#61615)
The changes here are meant to reduce resources consumed by
integration tests and eliminate the footgun of connecting to
a host before its been populated in the appropriate caches.

`(integrationTestSuite) defaultServiceConfig` now disables more services
by default. Host user creation, the Web UI and Web Service, and the
Database Proxy are all now turned off by default. The tests that require
them can opt into turning them on.

`(TeleInstance) Start` now blocks until the processes SSH server is present
in caches before returning. Most tests were already calling this manually
after Start, however, not all of them were. This is frequently forgotten
in new tests and causes flakes if client connections are attempted as
soon as Start returns. There are still cases where calling WaitForNodeCount
directly applies - tests that spin up additional nodes or tests that create
nodes in a leaf cluster.
2025-11-21 18:31:56 +00:00
Luke Okraszewski 6d8fca2157 [chore] disable debug service in integration tests (#61529)
The datadir in this test consists of TempDir
and typically suffix which exceeds the
BSD socket limits causing the test to fail on MacOS.

This commit disables the debug service in the failing tests,
for testing the debug service specifically it should be
enabled in the test itself.
2025-11-19 17:55:41 +00:00
Luke Okraszewski 3215c089bc [chore] fix race in TwoClustersTunnel (#61474)
This test previously passed in CI, relying
on slower machines and fails locally on both
Mac and in buildbox on macbook pro m3 with:

```
cluster site-A is offline
```

Adding the wait resolves the issue.
2025-11-18 15:34:46 +00:00
Nic Klaassen 3ef19859f7 enable verbose logging in HSM integration tests (#61458) 2025-11-18 12:34:05 +00:00
Grzegorz Zdunek 6615e42ecc Connect: close cluster clients when profile changes (#61090)
* Include expiration time in `LoggedInUser`

This will allow the profile watcher to detect when the user relogged.

* Display expiration time in UI

* Add `ClearStaleClusterClients` RPC

* Implement `ClearStaleClusterClients`

* Clear stale clients when profile changes

* Improve session expiration component

* Move refresh button back to top

* `ClearCachedStaleClientsForRoot` -> `ClearStaleCachedClientsForRoot`

* `unchanged` -> `stale`

* Make "closing stale clients" a subtest

* Add `clientcache` test

* Remove `getProfile` error wrapping

* Improve comment

* Convert story to controls
2025-11-17 11:02:40 +00:00
Andrew Burke 5fa63c3a7e Fix sftp using wrong addr for signing proxy headers (#61077)
This change fixes a bug where file uploads/downloads in the web ui
would fail if proxy protocol was active and the web listen addr
was unset.
2025-11-14 19:22:45 +00:00
Brian Joergerandrosstimothy b8ffed9838 Coordinate session ID with Node in Proxy recording mode (#59850)
* Generalize PrepareToReceiveSessionID.

* Initialize session ID in the connection context and update it from node current-session-id request.

* Add session-id-query-v2@goteleport.com request and ensure new session ID is correctly set in proxy recording mode during the channel request.

* Replace PrepareToReceiveSessionID with simpler in-place logic.

* Don't emit session events or tracker when proxy forwarding to a Teleport Node.

* Fix missing session tracker for outdated Teleport Node.

* Remove extra major version grace period.

* Update integration test.

* Cleanup current session ID handling and fix failing tests.

* Fix tests.

* Address comments.

* Restructure currentSessionID handling.

* Set newSessionID in test server context.

* Fix integration test.

* Fix AuditOn integration test.

* Address comment on channel close.

* Track session on forwarding node.

* Fix web shutdown.

* Fix nil pointer dereference in test.

* Fix test flake.

* Fix nil pointer in test.

* Fix test flake.

* Update lib/srv/ctx.go

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

* Forwarding Node accepts client connection after receiving preparing session ID from node. This way, the forwarder can reject client connections if there is an issue preparing the session ID (impossible join sessions).

* Remove check for session.data event which may not be emitted in time for the test.

* Address comments.

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2025-11-13 01:13:25 +00:00
Bartosz Leper 045d0b6ed0 Unify behavior of the uploaders (#60534)
* Unify behavior of the uploaders

- Changes the behavior of uploaders to allow uploading pending
  summaries. It also makes all uploaders consistently fail to overwrite
  existing recordings and final summaries.
- Upgrades the gofakes3 library to support the If-None-Match headers.
- Copies the MemBuffer utility from the enterprise code.

* Fix a deadlock in gcsessions.Handler

The deadlock occurred when the upload passed a certain number of parts,
in which case the errors channel buffer got saturated and the object
deletion goroutines started piling up, ultimately leading to locking the
main loop that iterated through the object slice when the semaphore
channel got its buffer filled up too.

This deadlock prevented running the GCS uploader integration tests.

* review

* Another review round

- Move the pending session downloading to the caller
- Add a missing MemBuffer test
- Tweaks to the memory uploader (required by the Enterprise change)

* Build fix

* review

* Fix lint and integration tests

* Delete the pending summaries when uploading final, use versioning on s3

* Some comments

* license
2025-11-12 17:33:32 +00:00
rosstimothy b05fddec87 Reduce TestKube/Exec flakiness (#61260)
* Reduce TestKube/Exec flakiness

The test was not explicitly providing the target Kubernetes
cluster. As a result of this the test harness would try to
infer the Kubernetes cluster by examining the inventory. This
could potentially happen fast enough that no Kubernetes clusters
exist in the inventory yet. As a result the empty field in the
identity could lead to the `Kubernetes cluster "" not found`
error reported in https://github.com/gravitational/teleport/issues/59462.

Closes https://github.com/gravitational/teleport/issues/59462.

* Extract alpine-webserver:v1 building from GHA

The logic to construct an image used by Kubernetes integration
tests has been moved to standalone make targets in the fixtures
folder to facilitate easier local testing. The GHA workflows
have been updated to call the new targets directly.
2025-11-12 00:48:43 +00:00
Gavin Frazar 8f0330366c Reduce MongoDB connections from agent (#60716)
To reduce the number of connections established to MongoDB servers,
Teleport Database Service instances will now cache connection pools to
MongoDB servers and reuse the connections when handling connections from
the same Teleport client.
2025-11-07 19:28:02 +00:00
rosstimothy fc95c42e2a Remove (auth.Server) SetClock (#60526)
The ability to alter the auth server clock existed
to allow tests to inject a fake clock. While this sounds
great it introduces opportunity for data races if other
components are already consuming the existing clock. For
example:

```

==================
WARNING: DATA RACE
Write at 0x00c003014720 by goroutine 168:
  github.com/gravitational/teleport/lib/auth.(*Server).SetClock()
      /__w/teleport.e/teleport.e/lib/auth/auth.go:2308 +0x88
  github.com/gravitational/teleport/lib/client_test.newStandaloneTeleport()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:629 +0x11ad
  github.com/gravitational/teleport/lib/client_test.newStandaloneTeleport()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:621 +0x1092
  github.com/gravitational/teleport/lib/client_test.TestTeleportClient_Login_local.func21()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:290 +0x14e
  testing.tRunner()
      /opt/go/src/testing/testing.go:1934 +0x21c
  testing.(*T).Run.gowrap1()
      /opt/go/src/testing/testing.go:1997 +0x44

Previous read at 0x00c003014720 by goroutine 9018:
  github.com/gravitational/teleport/lib/auth.(*Server).GenerateHostCerts()
      /__w/teleport.e/teleport.e/lib/auth/auth.go:5127 +0x59d
  github.com/gravitational/teleport/lib/auth.GenerateIdentity()
      /__w/teleport.e/teleport.e/lib/auth/init.go:1606 +0x450
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).reRegister()
      /__w/teleport.e/teleport.e/lib/service/connect.go:450 +0x25a
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).rotate()
      /__w/teleport.e/teleport.e/lib/service/connect.go:1160 +0xaa7
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).syncServiceRotationState()
      /__w/teleport.e/teleport.e/lib/service/connect.go:1017 +0x20b
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).syncRotationState()
      /__w/teleport.e/teleport.e/lib/service/connect.go:996 +0x1c9
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).syncRotationStateAndBroadcast()
      /__w/teleport.e/teleport.e/lib/service/connect.go:962 +0x4e
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).syncRotationStateCycle()
      /__w/teleport.e/teleport.e/lib/service/connect.go:906 +0xcb
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).periodicSyncRotationState()
      /__w/teleport.e/teleport.e/lib/service/connect.go:870 +0x5f3
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).periodicSyncRotationState-fm()
      <autogenerated>:1 +0x33
  github.com/gravitational/teleport/lib/service.(*LocalService).Serve()
      /__w/teleport.e/teleport.e/lib/service/supervisor.go:605 +0x35
  github.com/gravitational/teleport/lib/service.(*LocalSupervisor).serve.func1()
      /__w/teleport.e/teleport.e/lib/service/supervisor.go:328 +0x4a2

Goroutine 168 (running) created at:
  testing.(*T).Run()
      /opt/go/src/testing/testing.go:1997 +0x9d2
  github.com/gravitational/teleport/lib/client_test.TestTeleportClient_Login_local()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:285 +0x691
  testing.tRunner()
      /opt/go/src/testing/testing.go:1934 +0x21c
  testing.(*T).Run.gowrap1()
      /opt/go/src/testing/testing.go:1997 +0x44

Goroutine 9018 (running) created at:
  github.com/gravitational/teleport/lib/service.(*LocalSupervisor).serve()
      /__w/teleport.e/teleport.e/lib/service/supervisor.go:317 +0x10a
  github.com/gravitational/teleport/lib/service.(*LocalSupervisor).Start()
      /__w/teleport.e/teleport.e/lib/service/supervisor.go:360 +0x2f6
  github.com/gravitational/teleport/lib/client_test.startAndWait()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:804 +0x91
  github.com/gravitational/teleport/lib/client_test.startAndWait()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:802 +0x45
  github.com/gravitational/teleport/lib/client_test.newStandaloneTeleport()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:621 +0x1092
  github.com/gravitational/teleport/lib/client_test.TestTeleportClient_Login_local.func21()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:290 +0x14e
  testing.tRunner()
      /opt/go/src/testing/testing.go:1934 +0x21c
  testing.(*T).Run.gowrap1()
      /opt/go/src/testing/testing.go:1997 +0x44
==================  
```

The setter is also redundant - Auth already exposes a way
to be constructed with a custom clock. In order to get rid
of the races once and for all, the clock setter was removed and
all tests have been updated to plumb the clock through on
construction.
2025-10-29 15:19:44 +00:00
Luke Okraszewski a35dd06d8a [api] Add ListSemaphores (#60672)
* [api] Add ListSemaphores

This commits deperecates GetSemaphores, which should be replaced by a paginated counterpart:
ListSemaphores

Note that GetSemaphores is also used as a point getter when both Kind and Name are
given. This commit only focuses on pagination and as such takes the existing pattern
and adds paging support without adding a point getter for consistency with other RPCs.

Ranging is not implemented on client side due to the compound key used.

Towards: gravitational/teleport.e/issues/6759
Changelog: Add paginated API ListSemaphores, deprecate GetSemaphores

* nil safe getters for filter, simplify match

* only use new list for non point gets
2025-10-29 11:37:59 +00:00
Erik Tate 198c0cd651 adding support for scoped joining of SSH nodes using dynamic tokens (#60362) 2025-10-28 22:00:18 +00:00
Gavin Frazar ada75723a7 Fix MongoDB connection leak (#60645)
This fixes a topology monitoring connection leak.
The leak was triggered by an error during server selection or the
initial auth handshake with the MongoDB server.
2025-10-28 18:15:23 +00:00
Grzegorz Zdunek 2d1bc7b909 Connect: make logout function idempotent (#60553)
* Remove `ClusterRemove` RPC, make logging out idempotent

* Move calling `removeKubeConfig` and `maybeRemoveAppUpdatesManagingCluster` to main process

The main process should not depend on the renderer to clean up its own resources.

* Remove cleaning up kube dir

* Lint
2025-10-28 13:17:55 +00:00
Andrew Burke 66d0c8e7be Allow moderated session peers to transfer files (#60489) 2025-10-24 21:08:14 +00:00
STeve (Xin) Huang f87522b686 [mcp] "tsh mcp connect" support for streamable HTTP (#60120)
* implement "tsh mcp connect" for streamable HTTP

* wait for 5s just to be conservative
2025-10-22 18:37:18 +00:00
Vadym Popov a8ae574479 Add OS and ARCH info for client tools managed updates (#59891)
* Add OS and ARCH info for client tools managed updates

* Optimized initial tsh/tctl installation in tests to perform it once and re-use

* Add reading binary headers in order to identify OS and ARCH if it is not defined in configuration file.
2025-10-20 19:03:49 +00:00
Vadym Popov 84fe9926b9 Run Client Tools Managed Updates Tests on Windows CI Env (#57059)
* Disable race test for integration tests of client tools managed updates and run them on windows platform

* Fix tests where tool name for Windows have extension

* Fix test with break event of windows

* Revert the disabling of the -race flag for MU tests, as recompilation takes more time than running the tests
2025-10-16 00:16:24 +00:00
Nic Klaassen 652ee86f59 use new join service for host joins (#59778)
* use new join service for host joins

* fall back to legacy join on connection errors
2025-10-15 18:48:04 +00:00
rosstimothy 348699d998 Improve tsh ssh error messages (#60099)
Fixes https://github.com/gravitational/teleport/issues/60055 and
https://github.com/gravitational/teleport/issues/53267.

Errors emitted when access is denied or hosts are missing from
the inventory have been updated to be clearer to end users.

The current error when connecting to a host that does not exist

```bash
$ tsh ssh tim@fake-host
ERROR: failed connecting to host fake-host:0: failed to receive cluster details response
failed to dial target host
direct dialing to nodes not found in inventory is not supported
```

has been updated to remove ancillary details that have zero meaning to anyone
other than a Teleport developer and better clarify the host does not exist.

```
$ tsh ssh tim@fake-host 
ERROR: failed connecting to host fake-host: target host fake-host is offline or does not exist
```

The access denied error


```
$ tsh ssh tim@server01 uptime
ERROR: access denied to tim connecting to server01:0
```


has had a relatively minor and possibly unnoticed
change to omit the port from the dial target.


```
$ tsh ssh tim@server01 uptime
ERROR: access denied to tim connecting to server01
```

fix: use net.SplitHostPort instead of strings.Cut
2025-10-14 12:59:18 +00:00
Tiago SilvaandEdoardo Spadolini 2ae3a21a51 fix: prevent crypto/ssh to block on dialing (#59967)
* fix: prevent `crypto/ssh` to block on dialing

`crypto/ssh` dialing doesn't support timeouts or context cancellation
propagation by default. Although `ssh.ClientConfig` has a field
`Timeout`, this field is only used when establishing a new TCP
connection but it's never used for ssh handshake.

This means that if the target server never replies and no intermediary
closes the connection, the connecton will be kept alive forever causing
Teleport dialer to deadlock and never recover.

Although teleport `ssh` package has `NewClientConnWithDeadline`, not all
every Teleport implementation of `net.Conn` supports read deadlines,
which means we can have cases where the system also deadlocks when using
`NewClientConnWithDeadline` and a timeout.

This PR tries to solve it by closing the underlying connection when the
minimum time between the context's deadline, the timeout and if none set
30s.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* Apply suggestion from @espadolini

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

* fix code

* rename methods to correctly describe the behavior

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* handle code review comment

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2025-10-10 14:00:39 +00:00
STeve (Xin) Huang ff6ac612fb [refactor] client.NewMCPServerDialer (#60020)
* [refactor] client.NewMCPServerDialer

* TestVerifyTLSCertLeafExpiry

* TestMatchResourcesByFilters

* fix typo

* fix lint
2025-10-09 17:13:14 +00:00
Hugo Shaka 1d6aa82d9d Expect the auth backend/cache to be initialized before turning ready (#59907) 2025-10-08 19:27:02 +00:00
STeve (Xin) Huang 93cc1f51f2 mcputils for streamable HTTP transport conversion (#60024)
* mcputils for streamable HTTP transport conversion

* remove need of context from mcptest functions

* add test for notification
2025-10-08 16:39:56 +00:00