Commit Graph
793 Commits
Author SHA1 Message Date
Marek Smoliński 28907e17a0 Add MFA for Windows Desktop web access (#10271) 2022-02-18 22:01:46 +00:00
Gabriel Corado df44457b02 feat: aws database configurator (#9145) 2022-02-18 21:15:54 +00:00
Lisa Kim e82450b8ed Add missing action VerbRead to ListResources (#10422) 2022-02-18 20:51:37 +00:00
Alex McGrathandZac Bergquist 611c05106f Add support for windows desktop services proxying different desktops (#10101)
* Add support for windows desktop services proxying different desktops

* Add filter to GetWindowsDesktops, remove GetWindowsDesktop and GetWindowsDesktopByName

* Cache cleanup

* Fix cache deletes for Windows desktops

For deletes, the cache only gets the backend key, not the entire
resource. Do what database access does, which is to extract the
host ID from the path, and stuff it in the description field of
the resource header.

* Godoc cleanup

* Fix lint

* Address review comments

* Send error message if no desktop found

* Revert to x/net/websocket

This got converted to gorilla/websocket as part of moderated sessions.
We'll do a more intentional conversion post-release.

* fix lint

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2022-02-18 00:01:08 +00:00
Andrew Burke 4e3bd6c647 Clear terminal when auth server is in FIPS mode (#10095)
This change clears the terminal at the end of a session when the auth server is in FIPS mode, even if tsh isn't.
2022-02-17 10:16:36 -08:00
Alex McGrath 0abe3be6ee Add support for configurable ssh key extensions 2022-02-17 13:44:57 +00:00
Roman Tkachenko 41899806fd Add SQL Server support for database access (#10097) 2022-02-17 02:20:33 +00:00
Lisa Kim 74a21212c3 Implement resource sorter for server, appserver, dbserver (#10243)
* Define sorters for resource Server, AppServer, and DbServer
* Add sorting to ListResources in caching and presence layer
* ListResources now returns nextKey set to the limit+1th item,
  previously it returned a possible next key, where there
  may or may not be more results.
2022-02-17 00:42:03 +00:00
STeve (Xin) Huang 55fbd56217 MySQL prepared statement support (#10283) 2022-02-16 19:46:54 +00:00
Zac Bergquist adf03959b8 Add audit events for desktop clipboard access
Introduce two new audit events:

- desktop.clipboard.send: emitted when a user's local clipboard
  data is sent to teleport
- desktop.clipboard.receive: emitted when clipboard data is received
  from a remote windows desktop

Closes #9706
2022-02-16 10:53:13 -07:00
Joel ea810d30d9 Implement Moderated Sessions (#8563)
* Implement Moderated Sessions
2022-02-15 17:02:10 +01:00
Alan Parra beb2213ee7 Add passwordless-related information to protos (#10281)
Introduces webauthn.User (for usernameless logins) and extends
webauthn.SessionData and types.WebauthnDevice with relevant fields.

#9160

* Add passwordless-related information to protos
* Add missing field tags
* Update generated protos
* Reformat protos (make grpc)
2022-02-14 17:26:06 +00:00
c84b7f8142 Desktop session recording/playback (#9583)
* Record desktop sessions

Here we introduce a new protobuf type (DesktopRecording) that contains
an encoded TDP message, and update AuditWriter to treat these similarly
to SessionPrint events (which are used for SSH session recordings).

We also add desktop session playback endpoint, temporarily located at
/webapi/sites/:site/desktopplaybacktest/:session
which streams TDP messages from a recorded session over
a websocket interface.

* update session end (#9795)

* Updates SessionEnd event with fields needed for frontend

* removes the clock which didn't need to be passed

* Add `Recorded` field to `WindowsDesktopSessionEnd` (#9839)

* Adds the SessionRecording field to WindowsDesktopSessionEnd event to mimic SessionEnd events (useful for easy integration with frontend).

* 14 should have been 12

* removing test logic

* switches SessionRecording to simple boolean Recorded

* session recording websocket (#9908)

* Adds the SessionRecording field to WindowsDesktopSessionEnd event to mimic SessionEnd events (useful for easy integration with frontend).

* 14 should have been 12

* removing test logic

* switches SessionRecording to simple boolean Recorded

* Updates the websocket address

* updates desktopPlaybackHandle to restart playback once it reaches the end

* adds playback state and synchronization logic for ensuring that goroutines aren't leaked

* adds toggle functionality for play/pause

* fix for the fact that urls are case insensitive

* moves desktop_playback to its own file, fixes mistaken comment about how websocket.JSON.Receive works, fixes error messaging, wraps playbackState.Close in a sync.Once

* Adds a cond variable for the two goroutines, but doesn't solve the spinning loop problem for the hanging logic

* Adds a cancel-able context which is cancelled in ps.Close() in order to avoid a spinning loop in the websocket.Handler

* Moves the majority of playback logic into the playbackState, which is now renamed to the more accurate playbackPlayer.

* changes pp.hangWhilePaused to pp.waitWhilePaused

* Moves the context out of NewPlaybackPlayer and the playbackPlayer
struct, wraps playback goroutines in playbackPlayer.Play(ctx) in
order to comply with context semantics.

* removing unnecessary warnings

* touchups

* record screen size (#9992)

* Adds the SessionRecording field to WindowsDesktopSessionEnd event to mimic SessionEnd events (useful for easy integration with frontend).

* 14 should have been 12

* removing test logic

* switches SessionRecording to simple boolean Recorded

* Updates the websocket address

* updates desktopPlaybackHandle to restart playback once it reaches the end

* adds playback state and synchronization logic for ensuring that goroutines aren't leaked

* adds toggle functionality for play/pause

* fix for the fact that urls are case insensitive

* moves desktop_playback to its own file, fixes mistaken comment about how websocket.JSON.Receive works, fixes error messaging, wraps playbackState.Close in a sync.Once

* Adds a cond variable for the two goroutines, but doesn't solve the spinning loop problem for the hanging logic

* Adds a cancel-able context which is cancelled in ps.Close() in order to avoid a spinning loop in the websocket.Handler

* Moves the majority of playback logic into the playbackState, which is now renamed to the more accurate playbackPlayer.

* changes pp.hangWhilePaused to pp.waitWhilePaused

* Moves the context out of NewPlaybackPlayer and the playbackPlayer
struct, wraps playback goroutines in playbackPlayer.Play(ctx) in
order to comply with context semantics.

* removing unnecessary warnings

* Adds an OnRecv that's similar to OnSend, for emitting audit events for particular incoming tdp messages

* Send full `DesktopRecording` event as json over playback websocket. (#10052)

* playback websocket now sends a json representation of the DesktopRecording event rather than just the raw tdp message, in order for us to have timing data on the frontend

* updating json.Marshal to utils.FastMarshal

* Removing unnecessary comment

* playback end event (#10088)

* Adds an end event so that the playback player knows to set the progress bar to its end state

* making the end message a json

* if the marshal fails we don't want to send a message over websocket

* Use a static string

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

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

* Add participants to session end event

Desktop sessions are not joinable, so the participants list always
has a single member - the user who started the session.

This will ensure that our example role for RBAC for sessions
(which depends on the participants field) will work for desktop
sessions.

* Minor cleanup

* Only record sessions when enabled

In order for desktop sessions to be recorded, session recording
must be enabled in the cluster's session recording config and
at least one of the user's roles must enable it.

* Cleanup

* Start to address review comments

* Move TDP event handlers out of connectRDP

* Address more review comments and add some tests

* Add playback streaming test

* Consistent comments

* Fix tests

* Don't log PNG frames that exceed the size of a protobuf

Since the PNG frame message in our desktop protocol is unbounded,
it is theoretically possible for a message to exceed the size limit
of a single protobuf.

In practice, this is unlikely to occur with any legitimate RDP traffic,
as the bitmaps are at most 64x64 pixels and compressed in PNG form.
Rather than complicating the protocol to allow for PNGs to be split
across events, we simply refuse to log anything this big.

* Mark RFD 48 implemented

Co-authored-by: Isaiah Becker-Mayer <isaiah@goteleport.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2022-02-11 15:39:14 -07:00
Carson Anderson cc1e13154c Add keepalive heartbeat to kubernetes service (#9584)
This adds an rpc UpsertKubeServiceV2 to replace UpsertKubeService. Currently, kubernetes service does not have a keepalive heartbeat unlike app, db, and windows service. This brings functionality in line with the others. This would allow for future use of the keepalive to track connected agents via prometheus metrics.
2022-02-10 14:54:03 -07:00
Nic Klaassen 37d108ce14 commit forgotten "make grpc" (#10280) 2022-02-10 21:09:40 +00:00
Trent Clarke 61d2ae52d2 Adds Application certificate path to profile (#10043)
Adds Application certificate path to profile

Prior to this patch, the API Profile type had no way of exposing the
path to an application certificate. While this could be constructed
manually using the `keypaths` package, this was fragile and easy to miss
should the profile layout ever change.

This patch adds `GetAppCertPath()` to the API profile, providing a
centralised and integrated method for finding application
certificates.
2022-02-10 05:27:19 +00:00
Nic Klaassen bc441ef2cf IAM Join Method (gRPC service) (#10087) 2022-02-10 00:41:34 +00:00
Nic Klaassen e00ff42cb8 IAM Join Method (backend implementation) (#10085) 2022-02-08 18:48:13 +00:00
Edoardo Spadolini 154d6fbf97 Add the cert.create event (#9822)
* Add the `cert.create` event

For now, this is only emitted for user certificate issuance.

* Make `cert_type` a string rather than an enum

* Match field names and json tags in events.Identity

* Change events.Identity.Traits to be a wrappers.LabelValues/wrappers.Traits

* Event code shouldn't be under T10xx anymore
2022-02-08 11:13:35 +00:00
Lisa Kim ab392ef4f6 Add additional filters to ListResources (#10180)
Takes resource parser and match search and 
adds these filters to ListResources.
Allows resource filtering by labels, search keywords, 
or with the predicate language.

Part of RFD 55
2022-02-07 13:12:30 -08:00
Zac BergquistandIsaiah Becker-Mayer 69a96d4b2c Add desktop_clipboard role option (#10165)
* Add desktop_clipboard role option

As described in RFD 49, desktop_clipboard defaults to true.

Since sharing clipboards with a remote machine requires a high level
of trust, the presence of a single role in a role set which disables
the clipboard will result in the feature being disabled.

(This is in contrast to session recording, for example, where all
roles in a set must disable recording to turn it off.)

* completing TestBoolOptions

Co-authored-by: Isaiah Becker-Mayer <isaiah@goteleport.com>
2022-02-07 16:03:43 +00:00
rosstimothy fc2846ce1e update github.com/gravitational/trace to v1.1.17 (#10079)
* update github.com/gravitational/trace to v1.1.17

github.com/gravitational/trace v.1.17 adds support for `errors.Is`
to all errors it defines. This makes checking any `trace.Error` for
equivalence much easier, especially within tests.
require.ErrorIs/require.NotErrorIs should work out of the box now.
2022-02-07 10:20:52 -05:00
Zac Bergquist 878e71e685 Add role option for record_desktop_session (#9523)
This option defaults to true, as defined in RFD #0033.

The preset editor and audit roles disable desktop session recording,
as they aren't permitted access to desktops. The preset access role
enables desktop session recording. The implicit role applied to all
role sets also disables recording, otherwise it would be impossible
to disable.
2022-02-04 16:06:16 +00:00
Joel 8b7173e803 Use correct unmarshaller for json durations (#10124) 2022-02-03 16:47:51 +00:00
Marek Smoliński fbd5a2aafd Fix tsh tctl do not load all CAS (#9357) 2022-01-31 13:35:15 +01:00
Lisa Kim bbf013ce80 Add MatchSearch to resources for fuzzy search (#9892)
Adds a method to resources MatchSearch, that goes through 
select resource field values, and matches it against a list of 
user provided search values.

Part of RFD 55
2022-01-28 09:18:34 -08:00
Edoardo Spadolini 2598401589 Add access requests to audit events (#9758)
* Refactor most uses of `UserMetadata` into a handful of functions

* Add access requests to `UserMetadata`

* Explanation for the reserved field in SessionStart
2022-01-25 16:56:18 +00:00
Gabriel Corado e426b782a9 feat: add KubeService and Node to ListResources (#9613) 2022-01-25 15:48:13 +00:00
Edoardo Spadolini 95c53ad90e Access request locks (#9478)
* Add access request locks

This only contains the internal part, no user-visible changes

* Add a `tctl lock` flag to specify an access request ID

* Tests for access request locks
2022-01-24 19:40:09 +00:00
Alex McGrath 1ca73cd1e7 Add github teams to available traits 2022-01-24 10:59:59 +00:00
Marek Smoliński 7c8dc2ba05 Fix TLS Router serverName 'kube.' prefix based routing logic (#9777) 2022-01-24 09:53:00 +01:00
Edoardo Spadolini e254076700 Improved Google OIDC connector (#9697)
* go get google.golang.org/api

go get: upgraded cloud.google.com/go v0.60.0 => v0.100.2
go get: upgraded github.com/golang/snappy v0.0.1 => v0.0.3
go get: upgraded github.com/googleapis/gax-go/v2 v2.0.5 => v2.1.1
go get: upgraded go.opencensus.io v0.22.5 => v0.23.0
go get: upgraded golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d => v0.0.0-20211104180415-d3ed0bb246c8
go get: upgraded google.golang.org/api v0.29.0 => v0.65.0

* Optionally fetch transitive groups in the Google OIDC connector

* Refactor the google workspace parts of the OIDC code

* Further refactoring

This undoes the user account impersonation changes, and always requires
an admin account again.

* Test coverage

* Address review comments

* Minor refactor and name changes

* Allow domain filtering, tests now bypass addGoogleWorkspaceClaims

* Update `OIDCConnectorV2` to `OIDCConnectorV3`

* Backwards compatibility for OIDCConnector v2

This also removes the extra boolean flag that was added previously.

* Update e-ref

Enterprise builds will break unless gravitational/teleport.e#385
is included.
2022-01-21 18:26:28 +00:00
Tim Buckleyandrosstimothy 6d2ab51d0d Allow impersonation of roles without users (#9561)
* Allow impersonation of roles without users

This adds the ability to impersonate one or more roles without
impersonating a particular user.

In Teleport today, when creating an impersonator role, both users and
roles must be specified as impersonation is fundamentally tied to an
existing Teleport user:
```yaml
allow:
  impersonate:
    users: ['jenkins']
    roles: ['jenkins']
```

This is inconvenient for two reasons:
 1. A user must exist for each set of roles you'd like to
    impersonate, creating a UX burden.
 2. It makes it difficult to use impersonation to reduce one's
    permissions as you always inherit all of the roles granted to the
    target user.

For the [certificate bot][bot] we'd instead like to use impersonation
to generate end-user (impersonated) certificates with a reduced set
of permissions. For example, given the following role:
```yaml
allow:
  impersonate:
    roles: ['jenkins', 'deploy']
```

We can then use `GenerateUserCerts` to issue certifices for a subset
of the allowed roles, e.g. one set of certificates with only the
`jenkins` role attached, and another with only `deploy`.

To that end, this patch:
 1. Removes the requirement that roles define both `users` and
    `roles` in impersonate conditions
 2. Introduces a new `RoleRequests` field in `UserCertsRequest`
 3. Modifies `generateUserCerts` to gather `roles` from
    `RoleRequests` if allowed by an `allow` (with no `users`)

[bot]: https://github.com/gravitational/teleport/pull/7986

* Add `determineDesiredRolesAndTraits`; audit log on role impersonation

This splits initial role and trait determination into a new function,
`determineDesiredRolesAndTraits`, to improve control flow and clarity
given the new branches introduced for role impersonation.

Additionally, this moves the call to `CheckRoleImpersonation` down
to match regular user impersonation's flow, and emits an audit log
event on failure.

* Formatting fix

* Unit testing for role requests

This adds a new set of unit tests for role requests.

Also discovered the `impersonator` field wasn't being set for
role impersonation, so it's now set to the user's own username.
In other words, role impersonation will appear (in the audit log and
elsewhere) as self-impersonation.

* Clean up testing users between runs

* Deny most reimpersonation cases and add tests

This attempts to deny most cases of reimpersonation, where an
impersonated certificate might be used to generate certificates for
other roles the user is allowed to impersonate.

One test case is currently failing pending a solution.

* Add new DisallowReissue certificate extension

This adds a new DisallowReissue certificate extension that, if set,
prevents that identity from interacting with `GenerateUserCerts`.

This flag is always set when RoleRequests are used to prevent
unintended privilege escalation (while avoiding breaking changes to
Teleport's existing certificate generation behavior).

* Fix test lints

* Fix typo

* Fix test doc typo, add testcase for user impersonation misuse

* Apply suggestions from code review

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

* Accept context in CreateRole per review feedback

* Fix misleading comment

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2022-01-14 15:15:13 -07:00
Isaiah Becker-MayerandZac Bergquist 575da9e3de Fix first desktop discovery reconcile loop (#9654)
* Adds logic for grabbing known desktops from the auth server when the desktop discovery's reconciler starts up

* moving desktop initialization into goroutine

* Apply suggestions from code review

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>

* minor fixes

* removes initial discovery logic since it would break a multi-w_d_s setup, instead solves the problem by changing discovery's create function to an upsert

* consolidating verb check call

Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com>
2022-01-14 21:29:57 +00:00
Zac Bergquist 20c04df369 Clean up system role parsing (#9756)
* Add tests for ParseTeleportRoles

Updates #9752

* Be more tolerant when parsing system roles.

Our original attempt at canonicalizing roles didn't work for system
roles using camelcase, resulting in an awkward user experience.

Here we maintain a mapping of allowed inputs to their corresponding
system roles, and perform a case-insensitive lookup. This allows us
to support camelcase roles, and has the advantage of permitting
_ word separators as well.

Fixes #9752

* Refactor *SystemRole.Check()

Rather than having to list each role here, we rely on the new
roleMappings set to validate the role.

Additionally, remove the LegacyClusterTokenType role. This change
is guaranteed to be backwards compatible because we check for
RoleTrustedCluster everywhere we were checking for
LegacyClusterTokenType, and our roleMappings will convert the old
string that represented LegacyClusterTokenType to RoleTrustedCluster.
2022-01-14 00:13:59 +00:00
Andrew Burke c0a216ccbe Emit event when connecting to non-Teleport server (#9370)
This change adds a new audit event, `session.connect`, that is emitted when dialing to either an OpenSSH server or a trusted cluster. It also adds `emitConn`, a wrapper for a `net.Conn` that peeks at the first few bytes read and emits session.connect when it detects a non-Teleport connection.
2022-01-13 23:48:13 +00:00
Zac Bergquist e45ab655dd Fix reverse tunnel dialing for Windows Desktops
- Ensure that the dial request uses proper "server ID" format,
  which is <uuid>.<cluster_name>
- Update reverse tunnel agent to handle tunnel connections
  to desktops
2022-01-12 13:05:05 -07:00
Edoardo SpadoliniandMarek Smoliński c4bb671f2f Add the access_request.delete event (#9552)
* Add the `access_request.delete` event

* fix typo

Co-authored-by: Marek Smoliński <marek@goteleport.com>

* Use a custom RequestID field instead of ResourceMetadata in AccessRequestDelete

This is for consistency with AccessRequestCreate and other FooDelete
events for resources that don't use the Name field in Metadata to
identify the resource.

Co-authored-by: Marek Smoliński <marek@goteleport.com>
2022-01-11 10:56:26 +00:00
rosstimothy 95d0f0d27f Update google.golang.org/grpc to v1.43.0 (#9656)
Update grpc dependency to the latest version. Needed to fix the client side hang that
prevents TwoClustersTunnel from running succesfully, see #9655.
2022-01-10 15:36:50 -05:00
Isaiah Becker-Mayer bc11f2dfe6 Adds Desktops to license (#9576)
* Adds Desktops to license

* adds newline
2022-01-06 18:43:47 +00:00
Roman Tkachenko 95be5fda37 Update Postgres audit events (#9435) 2022-01-06 17:44:20 +00:00
Jakub Nyckowski f5d5323f1f Specify level of TLS verification for database connections (#9197)
Now 'verify-full', 'verify-ca' and 'insecure' modes can be used when connecting to a database. 'verify-full` is the default on and it's the most strict. 'verify-ca' skips the server-name check. 'insecure' accepts any certificate provided by a database.
2022-01-05 16:41:49 +00:00
Edoardo Spadolini 3a50ffab26 Add access requests to TLS certificates (#9501)
* Add access requests to tlsca.Identity, and store them in TLS certs

This mirrors what we already do for SSH certs.

* Keep track of access requests in web sessions

* Keep track of access requests in app sessions

* Include the current access requests when issuing new user certs

This is necessary because we extend the list of current roles
instead of starting from the statically assigned ones, so we should
also keep track of all the potential ways that those roles were
granted to the user.

* fix: pass access requests through PreAuthenticatedSignIn

* Tests for access requests in TLS certs
2022-01-03 14:22:16 +00:00
Marek Smoliński 5afd0e6204 Update API client: dial auth service with TLS Routing (#9498) 2022-01-03 11:32:45 +01: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
Gabriel Corado 5f403562ab feat: ListResources gRPC rpc (#9096) 2021-12-15 18:09:21 +00:00
Joel 2702856908 Allow a configurable event TTL in DynamoDB (#8840) 2021-12-14 18:04:44 +01:00
Marek Smoliński f906831e58 Add ability to run Mongo proxy on separate listener (#9194) 2021-12-14 14:26:14 +01:00
Marek Smoliński d24ae5b1ce Add ability to run Postgres proxy on separate listener (#8323) 2021-12-10 11:05:19 +01:00
Zac Bergquist 1a9416c19f Fix CheckAndSetDefaults for UserTokenSecretsV3 (#9290)
Since CheckAndSetDefaults mutates the receiver, we need a pointer
receiver.
2021-12-08 12:00:03 -08:00