Commit Graph
27 Commits
Author SHA1 Message Date
Isaiah Becker-Mayer fc33246807 Fixes dissonance between disconnect_expired_cert vs require_session_mfa (#18607) 2022-12-07 17:00:38 +00:00
Michael Wilson 85fac93653 Make TestTCP* tests in appaccess more deterministic. (#18233)
The appaccess TestTCP* tests are highly reliant on time. This has been
reduced (but not eliminated) by using a fakeClock and a channel for
signaling monitor triggered connection closures.
2022-11-08 21:40:54 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Michael WilsonandZac Bergquist 08beb1b959 Ensure that TrackingReadConn and TrackingReader conform to io.Reader (#17377)
* Ensure that TrackingReadConn and TrackingReader conform to io.Reader

Implementations of io.Reader should return io.EOF directly when the end of
the stream is reached, because callers will compare the error using ==.

* Update lib/srv/monitor_test.go

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

* Use require.Equal for conn_test.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2022-10-14 15:01:38 +00:00
Nic Klaassen 0246c89434 Fix flaky TestProxyClientDisconnectDueToIdleConnection (#13162) 2022-06-04 01:19:56 +00:00
Nic Klaassen 74fdc4a8da attempt to fix flaxy TestProxyClientDisconnectDueToLockInForce (#13136) 2022-06-03 17:33:51 +00:00
Zac Bergquist 78246b77c1 Properly cleanup the connection monitor for desktop sessions (#9913)
This fixes a bug where desktop sessions that are closed by the user
leak the connection monitor goroutine, forcing it to continuously
check for idle connections, while failing to close them because
they were already closed.
2022-01-26 08:46:38 -07:00
Zac Bergquist 7c96ba9177 Allow locking a desktop
Prior to this change, desktop access only respected locks
on users or roles. This introduces a desktop as a lock target,
preventing new connections and terminating existing connections
to a locked desktop.

Note: when a lock is created, connection attempts will fail
with the generic "websocket connection failed" error.
This will be addressed with #8584.

Updates #8742
2021-12-28 09:08:40 -07:00
Trent Clarke e8e4c8ee80 Resolve race in db tests (#9117)
When disconnecting a client due to an expired certificate, the monitor
was emitting the disconnection event before forcing the client to
disconnect. This led to races in tests that wait on the disconnection
event, where tests would:

    1. wait for the disconnection event before proceeding
    2. receive the disconnection event
    3. take action based on the disconnection event, assuming that the
        client was disconnected, when there is no guarantee that the
        disconnection has actually happened yet.

This patch re-orders the disconnection and event broadcast, such that
the disconnection happens first, meaning that if a watcher receives
the disconnection event, then the disconnection has already been
attempted.
2021-11-24 17:10:06 -08:00
Zac Bergquist 01ced111f4 Add RBAC for Windows desktop access (#8520)
* Add RBAC for Windows desktop access

This commit adds RBAC checks for Windows Desktops as described in
RFD 33 and RFD 34:

- add Windows desktop logins & labels to role definition
- introduce new file config for host labels based on a regexp match
- auth server API performs access checking for Windows desktop resources
- add RDP client callback to authorize the user
- support user/role locks
- respect the client idle timeout setting

Note: in cases where an connection is terminated to to RBAC, the web UI
currently displays "websocket connection failed" because the connection
is closed from the server. We'll need to follow up with a nice error
message for the client side to improve the UX here.

Other changes:

* Remove OSS RBAC migration marked for deletion
* Stop creating a default admin role
* add wildcard desktop access to the preset access role

Updates #7761
2021-10-12 14:52:59 -06:00
Marek Smoliński 97ea93969e Fix ConnectionMonitor DisconnectExpiredCert (#8288) 2021-09-16 21:18:13 +02:00
Andrej Tokarčík 9f410881f8 Handle stale lock views with strict/best-effort modes (#7798) 2021-08-10 16:56:56 +02:00
Brian Joerger 9b8b9d6d0c rollback - Upgrade api version. (#7751) 2021-07-30 15:34:19 -07:00
Brian Joerger c040aca4c1 Upgrade api version. (#7609) 2021-07-28 13:51:21 -07:00
Andrej Tokarčík 7d878fff24 Enforce locks in auth.Authorize (#7625) 2021-07-28 18:54:21 +02:00
Andrej Tokarčík d5ca862280 Apply locks to connections tracked by srv.Monitor (#7506) 2021-07-23 14:11:50 +02:00
Trent Clarke ca1e47bef0 Adds custom timeout message to SSH sessions (#7120)
* Adds the idle_timeout_message to the auth_service config file block
* Plumbs the value through to the session monitor
* Writes the message to stderr when a session times out due to inactivity
* Adds some machinery to the test helpers to configure appropriate tests

See-Also: #6091
2021-06-25 14:12:50 +10:00
Brian Joerger 7bff7c41bd Remove API aliases (#6983) 2021-06-04 13:29:31 -07:00
Marek Smoliński eb7bb01d34 Support disconnect_expired_cert for database access (#6857) 2021-05-31 10:26:50 +02:00
a-palchikov 7c87576a8b flaky tests: consistent logging (#4849)
* Update logrus package to fix data races
* Introduce a logger that uses the test context to log the messages so they are output if a test fails for improved trouble-shooting.
* Revert introduction of test logger - simply leave logger configuration at debug level outputting to stderr during tests.
* Run integration test for e as well
* Use make with a cap and append to only copy the relevant roles.
* Address review comments
* Update integration test suite to use test-local logger that would only output logs iff a specific test has failed - no logs from other test cases will be output.
* Revert changes to InitLoggerForTests API
* Create a new logger instance when applying defaults or merging with file service configuration
* Introduce a local logger interface to be able to test file configuration merge.
* Fix kube integration tests w.r.t log
* Move goroutine profile dump into a separate func to handle parameters consistently for all invocations
2020-12-07 15:35:15 +01:00
Sasha Klizhentas d160507430 Session streaming
This commit introduces GRPC API for streaming sessions.

It adds structured events and sync streaming
that avoids storing events on disk.

You can find design in rfd/0002-streaming.md RFD.
2020-09-28 23:08:56 -07:00
Andrew Lytvynov b839da9eb6 Track SSH client activity per ssh.Channel
This is the lowest-level transport we have after SSH session is
established. Any data going either direction indicates some activity.

Note: we also track writes from server to client as activity. If a user
starts a script that prints something every minute and steps away, the
session should keep going as long as `client_idle_timeout > 1m`.

This also fixes things like large SCP transfers.
2020-08-11 22:11:56 +00:00
Andrew Lytvynov e6aab1dcaa errcheck: add missing error logging in lib/srv 2020-06-01 17:00:07 +00:00
Andrew Lytvynov 44cfbd4b6d Fix common misspellings detected by misspell linter 2020-05-11 16:44:27 +00:00
Roman Tkachenko 1828e21ef4 [Forward-port] Update audit events with additional fields. (#2655) 2019-04-17 10:16:28 -07:00
Sasha Klizhentas c805de5421 Always add 'system:authenticated' to impersonation groups.
Looks like impersonated users do not get 'system:authenticated'
as a default. This leads to kubectl to fail for some restricted users,
who don't have 'system:discovery' like permissions added to the roles.

This commit always injects the group if not present in the request.

See https://github.com/kubernetes/kubernetes/issues/43227 for a similar
solution
2019-03-25 12:52:45 -07:00
Sasha Klizhentas 0c7912f105 Disconnect expired k8s clients, fixes #2618
This commit implements disconnects of kubernetes
clients with expired certificates and terminates
idle sessions, according to 'disconnect_expired_cert'
and 'client_idle_timeout' existing settings making
the behavior consistent with SSH sessions.
2019-03-25 12:52:45 -07:00