Commit Graph
93 Commits
Author SHA1 Message Date
Tiago Silva 4c337d1a7f Add AccessGraphPlugin system role (#40714)
This PR introduces the `AccessGraphPlugin` system role used by Access
Graph plugins to access the Auth server API and Access Graph api.

Part of https://github.com/gravitational/access-graph/issues/635

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2024-04-23 09:43:45 +00:00
Bartosz Leper ed93168ea5 Lower bcrypt cost when testing (#40254)
* Lower bcrypt cost when testing

* Review
2024-04-08 16:50:20 +00:00
Marco André Dinis 976cfd1fa0 Add node:rw to RoleDiscovery to allow EICE (#40194)
This PR adds a missing permission to the RoleDiscovery so that it can
create nodes of EICE kind.
These nodes are the only ones created by the DiscoveryService.
Teleport Nodes are created when the teleport process joins the cluster
Agentless Nodes are either created via `tclt` or `teleport join` command
2024-04-04 15:01:14 +00:00
Krzysztof SkrzętnickiandAnton Miniailo 24021556c4 Implement persistence for database_object resource (#39756)
* Implement persistence for database_object resource

* Split monolithic service test

* Add `t.Parallel()` to the tests

* lint fix

* Update copyright year

Co-authored-by: Anton Miniailo <anton@goteleport.com>

* `make grpc`

---------

Co-authored-by: Anton Miniailo <anton@goteleport.com>
2024-04-03 08:28:11 +00:00
Andrew LeFevre 2143f5ba64 add kubernetes waiting container backend service and API (#39317)
* add kubernetes waiting container backend service and API

* remove other resource type

* add unit test

* fix after rebasing

* address feedback

* remove KubeWaitingContainerRequest

* check for nil in validation func

* remove UnwrapResource153

* fix test

* address feedback

* address linter issues

* fix cache watch kind test
2024-03-20 16:03:39 +00:00
rosstimothy 9734fcbdbd Convert SetSessionRecordingConfig usages to new Create/Update/Upsert API (#39249)
Migrates callers off the deprecated API and onto the new API so
that SessionRecordingConfig can be protected via optimistic locking
when appropriate.
2024-03-15 19:55:57 +00:00
rosstimothy 20888bf130 Convert SetAuthPreferences usages to new Create/Update/Upsert API (#38895)
Migrates callers off the deprecated API and onto the new API so that
AuthPreferences can be protected via optimistic locking when appropriate.
2024-03-14 22:05:20 +00:00
rosstimothy bea120ac96 Convert SetClusterNetworkingConfig usages to new Create/Update/Upsert API (#39219)
Migrates callers off the deprecated API and onto the new API so that
ClusterNetworkingConfig can be protected via optimistic locking when
appropriate.
2024-03-14 14:37:42 +00:00
rosstimothy 1aec5414f1 Replace constants from trace with equivalents defined in teleport (#39307)
* Remove logging from circuit breaker

The logging is never output, and if it was would be very verbose.
Instead of dropping the level down to trace the logger is removed
entirely.

* Add constants from trace library

The logging functionality in trace is being removed in an upcoming
release. To prepare the logging component keys are copied from trace
into teleport.

* Convert trace.ComponentFields to teleport.ComponentFields

* Replace trace.Component with teleport.ComponentKey

* Replace trace logging constants
2024-03-14 13:04:29 +00:00
Brian Joerger f57021d956 Don't count mfa-verifeid Private Key Policy as MFA for Admin Actions (#39257)
* Don't count hardware key support as MFA verification for admin actions.

* Add clarifying comments to IsMFAVerified methods to prevent future misuse.

* Update test.
2024-03-13 17:57:26 +00:00
Tiago Silva 581b9c739a Lock AWS Sync into a single discovery service (#39171)
* Lock AWS Sync into a single discovery service

This PR prevents multiple `discovery_services` running with the same
configuration to race against each other and push new resources to
Access Graph service.

This PR also introduces the notion of features to identify the list of
supported resources by the Access Graph service to which the service is
connected to.

Paired with https://github.com/gravitational/access-graph/pull/591

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

* handle review comments

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2024-03-12 12:33:32 +00:00
89d85656c3 Add EKS auto discovery for dynamic integration based fetchers. (#38204)
* AWSOIDC: Move enrollment of EKS clusters to the gRPC service.

* Fix after rebase.

* Add EKS auto discovery for dynamic integration based fetchers.

* Remove commented code.

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

* Remove unneeded code.

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

* Add missing godoc.

* Initiate map with length.

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

* Fix typo in the interface name.

* Introduce iam join method for EKS enrollment.

* Correctly process DiscoveredEKSCluster in kube watcher.

* Remove remaining CreateToken related code from Discovery service.

* Change var initialization.

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

* Remove dev version detection for EKS enrollment.

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

* Revert "Introduce iam join method for EKS enrollment."

This reverts commit 0eb3f4f1226239a5d4e768ebe9129535be318ccb.

* Fix usage of a missing function.

* Refactor cluster features to be a function.

* Change discovery to use gRPC call for EKS enrollment.

* Remove unused mock.

* Correct a comment.

* Remove token creation permission from Discovery service.

* Fix after rebase.

* Improve sorting clusters by region and integration.

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>

* Return and error if cluster features are missing.

* Fix tests.

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Co-authored-by: Marco André Dinis <marco.dinis@goteleport.com>
Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
2024-02-29 00:10:39 +00:00
rosstimothy f00343cc53 Add SessionRecordingConfig support to cluster configuration RPC service (#38591)
* Remove marshal options from GetSessionRecordingConfig

* Add SessionRecordingConfig support to cluster configuration RPC service

Extends the clusterconfigv1.Service to implement RPCs for interacting
with SessionRecordingConfig. The various GetSessionRecordingConfig
interfaces were also all updated to remove the marshal options since
they were never used and served no purpose.
2024-02-28 01:22:29 +00:00
rosstimothy d7b814010e Add ClusterNetworkingConfig support to cluster configuration RPC service (#38590)
* Remove marshal options from GetClusterNetworkingConfig

* Add ClusterNetworkingConfig support to cluster configuration RPC service

Extends the clusterconfigv1.Service to implement RPCs for interacting
with ClusterNetworkingConfig. The various GetClusterNetworkingConfig
interfaces were also all updated to remove the marshal options since
they were never used and served no purpose.
2024-02-27 22:29:53 +00:00
rosstimothy eb58a01eb1 Remove marshal options from GetClusterAuditConfig (#38593) 2024-02-27 14:11:17 +00:00
Krzysztof SkrzętnickiandBartosz Leper 9d7c59f9a4 Implement persistence for db_object_import_rule resource (#37806)
* Implement persistence for db_object_import_rule resource

* Apply suggestions from code review

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>

* Use plural interface name: DatabaseObjectImportRules. Fix typos. Refactor test.

* token => pageToken

* Simplify resource command

* Fix permission checks

* add details

* refactor, rebase fixes

* better name

* Fix several issues.

- Change type of `db_labels` proto field to the new shared `label` message.
- Implement missing method.
- Cause compilation errors in case of unipmlemented methods.
- Add test coverage for `tctl` commands.
- Change output of Marshal/Unmarshal methods.

* Fix test

* Fix nondeterminism in test

* Add mising docs

* Resolve protobuf breaking changes

* Shorten component name for logging

* Add access test

* Fix test

* Update error message and tests

* Remove temp test `TestCreateUser`

---------

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>
2024-02-22 03:54:27 +00:00
Brian Joerger 98a7986ec4 Remove deprecated authz functions, update e ref. (#38067) 2024-02-12 22:27:58 +00:00
Brian Joerger 6ac3732976 Remove quiet/silent flags from authz checks (#37832)
* Always log role check errors to Trace level.

* Remove all quiet/silent flags from role checks.
2024-02-12 21:17:02 +00:00
Brian Joerger faf97aad9e Refactor authz package helper methods - AuthorizeAdminAction (#37565)
* Add authz context helper methods for authorizing admin actions.

* Replace uses of old authz helper methods.

* Address comments.
2024-02-09 21:42:46 +00:00
Brian Joerger eba938662c Refactor authz package helper methods - AuthorizeWith* (#37564)
* Add authz context helper methods.

* Replace uses of old authz helper methods.

* Remove unused context parameter.

* Apply suggestion.

* Add non-variadic verb argument instead of empty verbs check.

* Resolve Alan's comments.

* Remove new usage of old helper.
2024-02-09 01:51:22 +00:00
Brian Joerger 3d0e30c90b Always convert authorizer error (#37767)
* Always convert authorizer error.

* Remove redundant calls to ConvertAuthorizerError.

* Make ConvertAuthorizerError a private method.

* Remove outdated test.

* Fix affected tests.
2024-02-09 00:55:16 +00:00
STeve (Xin) Huang 505a21c7a7 Fix an issue tsh uses wrong default username for auto-user provisioning enabled databases in remote clusters (#37274)
* Fix an issue `tsh` uses wrong default username for auto-user provisioning enabled databases in remote clusters

* fix lint and improve message

* fix godoc

* remove extra quote
2024-01-29 14:10:05 +00:00
Brian Joerger 2235bda89f Remove deprecated field; update e ref. (#36593) 2024-01-24 22:01:31 +00:00
Brian Joerger 8d933d066a Update Admin Action MFA enforcment (#37136)
* Only enforce admin MFA when webauthn is required.

* Add TELEPORT_UNSTABLE_DISABLE_MFA_ADMIN_ACTIONS env flag for an emergency escape hatch.

* Fix TestAdminActionMFA unit tests.
2024-01-24 20:06:52 +00:00
Brian Joerger 85b7d9b460 Make tctl users add prompt for MFA just once (#36997)
* Refactor MFA prompt logic for the API client to enable various MFA
ceremony use cases.

* Address comments.

* Prompt for MFA before creating a user with tctl.

* Check if AdminActionMFA is enforced before attempting to create an MFA auth challenge.
2024-01-23 19:48:28 +00:00
Brian Joerger 7f5e233407 Allow reused MFA for specific admin action endpoints (#36830)
* Allow reused MFA for specific admin action endpoints.

* Add godoc.

* Fix IsMFARequire_AdminAction and add test.
2024-01-22 20:02:56 +00:00
Brian Joerger d563b2c787 Scoped WebAuthn: server changes (#36782)
* Refactor how authorizer interfaces with ValidateMFAAuthResponse.

* Pass MFA challenge extensions through create/validate flows and endpoints.

* Address comment.

* Address comments.

* Fix account recovery test by using proper scope.

* Address comments.
2024-01-22 18:52:45 +00:00
Brian Joerger 6353c3ac16 Migrate RotateExternalCertAuthority to gRPC (#36540)
* Add RotateExternalCertAuthority to gRPC TrustService.

* Add server implemenation.

* Mark deprecated HTTP endpoint for deletion.

* Add client implementation and HTTP fallback.

* Address comments.

* Limit RotateExternalCertAuthority to internal services explicitly.

* Add RBAC tests for RotateExternalCertAuthority.

* Remove outdated test.
2024-01-18 21:14:37 +00:00
Michael Wilson 21566a12c0 Grant the Okta service permissions to manage access lists. (#36189)
The Okta service will now be able to manage access lists and associated
resources.
2024-01-18 15:48:52 +00:00
Gabriel Corado e6f61abc9e Add client remote address to some audit events (#36354)
* feat: add client addr to administrative events

* test(auth): update assert
2024-01-10 13:22:08 +00:00
Brian Joerger e8339ae856 MFA for Admin Actions: users (#35386)
* Make user endpoints admin actions.

* Fix user tests.

* Fix update user in the webui.

* Add tctl admin action test suite.

* Minor test suite refactors.

* Resolve comments.

* Use localhost as RPID in test.
2023-12-14 21:39:32 +00:00
Trent Clarke e44b359a7e Grant Okta RW on locks (#35348)
In order for the Okta service to be able to lock out deleted users,
it needs the ability to create and manipulate locks. This PR grants
the builtin Okta Role the ability to do so, but also puts limits on
this ability.

 1. The Okta service may only create and manipulate locks with an
    `okta` origin label,
 2. The Okta service may only create and manipulate locks that
    target a User with an `okta` origin label, and nothing else,
 3. The Okta service may only delete locks with an Okta origin

This PR also
 * Implements `ResourceWithLabels` interface on `types.LockV2` in order
   to re-use the existing Okta restrictions,
 * Refactors the existing Okta restrictions to make them accessable for
   Lock CRUD, and
 * Adds tests for Lock CRUD
2023-12-12 04:20:26 +00:00
Brian Joerger 2115d4d25a Reduce scope of admin action MFA to webauthn clusters. (#35615) 2023-12-11 21:09:23 +00:00
rosstimothy 7cdd591475 Improve UserMetadata used in User audit events (#35493)
Ensures that the metadata always contains the identity of the user
performing the action and stops falling back to the user that
last created the resource. Also adds a helper function to the
authz.Context to make getting the UserMetadata from the already
retrieved identity easier.
2023-12-08 16:12:04 +00:00
Alan Parra a469c4ce2b feat!: Apply role device mode to App Access (#35274)
* Apply role device mode to App Access

* nit: Don't capture traces on guard errors

* Consistently return ErrTrustedDeviceRequired

* Surface device error trust error for apps

* Reply with a custom message for device trust errors

* Review: Remove the DisableDeviceAuthorization field

* Review: Refactor device trust message into its own method

* Review: Wrap guard errors

* Review: Simplify device error message
2023-12-04 17:53:30 +00:00
fheinecke b178b8b732 Updated Teleport codebase to AGPL3 license (#35259)
Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>
2023-12-01 17:48:14 +00:00
Marco André Dinis 0ab79442ce Discovery: Use Integration credentials for fetchers (#34582)
* Discovery: Use Integration credentials for fetchers

* fix typos, improve docs, add clients.closer

* be explicit about using ambient or integration credentials

* remove integration assignment when using ambient credentials

* be explicit about using ambient credentials in db service

* fix cache key for region only sessions

* re-trigger license/cla check
2023-11-24 13:42:02 +00:00
Brian Joerger 48dc80cf15 MFA for admin actions: Add server side check (#33676)
* Add method to check MFA challenge response for admin actions.

* Add tests.

* Move AuthorizeAdminAction to authz package.

Add ValidateMFAAuthResponse as a dependency for the authorizer.

Update tests to include a mock ValidateMFAAuthResponse method.

* Resolve comments.
2023-11-16 21:30:24 +00:00
Trent Clarke f5b548ee72 Grant the Okta service the right to write Users (#33630)
* Grant the Okta service the right to write Users

In preparation for the Okta service syncing user accounts, this patch grants the Okta
service the right to create/update/delete users, in addition to the existing read
permission.

* Restricts User RBAC operations on the built-in Okta role

* Address review comments

 - Consolidates update checking into a single function
 - Adds implementation for new user service

* remove unused code

* Refactor Okta access and tests

* Fix merge detritus

* Doc updates

* Hopefully last pass

* Linter appeasement

* Consilidated checks

* Update auth_with_roles_okta_rbac_test.go

docs
2023-11-15 01:25:43 +00:00
Nic Klaassen ce5de4c4a2 fix!: respect deny rules for access requests (#34438)
Access Request follow their own set of RBAC rules.
Usually, none of the typical create/read/list/delete verbs are required
in any user's roles.
Access is handled via custom rules based on the allow.request, deny.request,
allow.review_requests, and deny.review_requests role fields.

The create/read/list/delete verbs commonly used for other resources are
usually all or nothing (barring `where` expressions), but a more nuanced
set of rules apply to access requests. E.g. users should always be
allowed to see access requests that they created or are allowed to
review, without being allowed to see other access requests in the
cluster.

This seemed mostly logical once you thought about it long enough, but
one detail that has been lacking so far is that explicit deny rules in
the user's roles have no effect at all, even though explicit allow rules
grant god-mode access to create or view any access requests in the
cluster.

Even with the following role, you could still create and view
access requests:

```yaml
kind: role
version: v6
metadata:
  name: example
spec:
  allow:
    request:
      roles: ["*"]
    review_requests:
      roles: ["*"]
  deny:
    rules:
      - resources: ["access_request"]
        verbs: ["create", "read", "list"]
```

This commit makes any explicit deny rules actually take effect.

Fixes https://github.com/gravitational/customer-sensitive-requests/issues/103

changelog: Respect explicit deny rules for Access Requests.
2023-11-14 20:15:35 +00:00
Anton Miniailo 6d873431da Fix headless login timing out prematurely (#34163) 2023-11-03 16:29:17 +00:00
Anton Miniailo 1e8cc61d87 Consolidate context usage for client src/dst addresses into authz package (#22530) 2023-11-01 18:26:03 +00:00
rosstimothy 2087a2fda8 Implement Create/UpdateRole on the auth server (#33491)
In addition to adding server and backend handling for create and
update roles, the services.Access interface was updated to return
a role from the existing Create/UpsertRole methods. Bumps the e
ref to incorporate the associated changes needed there to prevent
breaking the build.
2023-10-18 17:06:50 +00:00
Alan Parra 8f584d42de Use authz helpers for user role checking (#33396)
* Replace helper with authz.IsXUser methods

* Use UnmappedIdentity in helpers

* Fix TestIsUserFunctions
2023-10-17 17:19:50 +00:00
Marek Smoliński f3545eba3f Security Reports (#30853) 2023-10-16 10:11:54 +00:00
Brian Joerger c0b3299de7 Add support for Hardware Key PIN (#31743)
* Update RFD with hardware key pin policies.

* Consolidate policy logic and update tests.

* Add pin private key policies; Make PIV PIN/Touch prompts work together.

* Prompt user to set pin/puk from default.

* Handle unexpected PIN auth errors.

* Resolve RFD password prompt comment.

* Handle incompatible private key policy in role sets (future-proof).

* Resolve comment on require mfa type string godocs and tests.

* A satisfying change.

* Address PIN/PUK prompt comments and other code suggestions.

* Resolve comments.

* Fix test that prompts for pin twice.

* Fix test.
2023-10-13 19:07:43 +00:00
Marco André Dinis de3a0cc5fd DiscoveryConfig: init service and add resource to tctl (#32399)
* DiscoveryConfig: init service and add it to `tctl`

This PR starts the DiscoveryConfig service in gRPC server and allows
`tctl` to interact with those records.

It also adds access to the `editor` role.
Users should be able to RW any DiscoveryConfig.

DiscoveryService should be able to watch those resources, so that it can
act upon any changes.

* add revision

* add upsert method

* improve tctl -f command
2023-10-11 10:24:05 +00:00
Bernard Kim 27fae1a28a Add support for deploy service agent auto updates (#31982)
* Add support for ecs agent auto updates

* fix unit test

* Remove unused var

* Addres feedback

* Use list of available AWS database regions

* Run update task on proxy instances

* Revert GenerateAWSOIDCToken

* Move const to start of file

* Address feedback

* Create separate DeployServiceUpdater struct

* Address feedback

- Perform updates in parallel
- Add additional logging
- Add additional documentation

* debug

* Address feedback

- Check OwnershipTags
- Use semaphore pkg
- Release semaphore lease on success

* Make OwnershipTags explicitly required

* Add cluster alert

* Fix typo and update message

* Revert cluster alert

* Update err messages

* Check minimum compatible server version

* Update log msg
2023-10-10 22:00:09 +00:00
rosstimothy 84e1be110a Complete services.Users interface refactoring (#33233)
* Update e ref

* Complete services.Users interface refactoring

Removes temporary functions required to migrate the interface
without breaking e.

Closes #32949.
2023-10-10 19:56:42 +00:00
rosstimothy b60ea81d54 Update users interface (#32987)
services.UsersService now takes a context and returns the user
from write operations as shown in the diff below. The bulk of the
changes are from modifying code to account for the additional
parameter and/or return value. Functional changes to better make
use of the new API will come in follow up PRs.

```diff
// UserGetter is responsible for getting users
type UserGetter interface {
	// GetUser returns a user by name
-	GetUser(user string, withSecrets bool) (types.User, error)
+	GetUser(ctx context.Context, user string, withSecrets bool) (types.User, error)
}

// UsersService is responsible for basic user management
type UsersService interface {
	UserGetter
	// CreateUser creates user, only if the user entry does not exist
-	CreateUser(user types.User) error
+	CreateUser(ctx context.Context, user types.User) (types.User, error)
	// UpdateUser updates an existing user.
-	UpdateUser(ctx context.Context, user types.User) error
+	UpdateUser(ctx context.Context, user types.User) (types.User, error)
	// UpdateAndSwapUser reads an existing user, runs `fn` against it and writes
	// the result to storage. Return `false` from `fn` to avoid storage changes.
	// Roughly equivalent to [GetUser] followed by [CompareAndSwapUser].
	// Returns the storage user.
	UpdateAndSwapUser(ctx context.Context, user string, withSecrets bool, fn func(types.User) (changed bool, err error)) (types.User, error)
	// UpsertUser updates parameters about user
-	UpsertUser(user types.User) error
+	UpsertUser(ctx context.Context, user types.User) (types.User, error)
	// CompareAndSwapUser updates an existing user, but fails if the user does
	// not match an expected backend value.
	CompareAndSwapUser(ctx context.Context, new, existing types.User) error
	// DeleteUser deletes a user with all the keys from the backend
	DeleteUser(ctx context.Context, user string) error
	// GetUsers returns a list of users registered with the local auth server
-	GetUsers(withSecrets bool) ([]types.User, error)
+	GetUsers(ctx context.Context, withSecrets bool) ([]types.User, error)
	// DeleteAllUsers deletes all users
-	DeleteAllUsers() error
+	DeleteAllUsers(ctx context.Context) error
}
```

Depends on gravitational/teleport.e#2346
Implements step 3 of #32949
2023-10-10 14:07:46 +00:00