Commit Graph
31 Commits
Author SHA1 Message Date
Marco Dinis 0d515ec020 Use slog in lib/integration/awsoidc package (#41210)
* Use slog in `lib/integration/awsoidc` package

* fix type field
2024-05-06 15:44:42 +00:00
Nic Klaassen ef0f92d010 fix: prevent deleting AWS OIDC integration used by EAS (#40630)
* fix: prevent deleting AWS OIDC integration used by EAS

The External Audit Storage feature for Teleport Cloud depends on an AWS
OIDC integration to exist in order to get credentials for the customer
AWS account.
It's currently possible for a customer to delete the AWS OIDC
integration referenced by the EAS configuration, leading to the EAS
integration breaking and the Auth service crashing the next time it's
started up.

This commit prevents deleting an AWS OIDC integration currently
referenced by and EAS integration, and prevents creating an EAS
integration referencing an unknown AWS OIDC integration.

* use PreDeleteCheck instead of calling EAS service

* reorder tests and add missing cleanup

* create integrations svc on the fly

* switch to AtomicWrite

* set revision of returned resources

* deprecate gRPC DeleteAllIntegrations and use more general cacheMode
2024-04-23 21:22:16 +00:00
Marco André Dinis fef8c56c0d AWS OIDC: only auth, proxy and discovery can generate tokens (#39146) 2024-04-10 13:42:28 +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 2943df38b1 Fix EAS Token generation (#40154)
In the latest release, we added support for S3 bucket as OIDC Provider
URL.
There are two places were the Token is generated.
One used in Discover Wizard, EICE access and Auto-Discover.
Another one for the External Audit Storage.

The first was updated to include the S3 Bucket as possible Issuer.
EAS flow was not updated.

This PR merges both flows.
2024-04-05 13:06:03 +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
Marco André Dinis a0068878de AWS OIDC: Accept custom issuers (#38785)
* AWS OIDC: Accept custom issuers

This PR adds a new field into the AWS OIDC fields:
- issuer

This is the issuer that was configured in AWS.
It is used by teleport to set the `issuer/iss` field when generating the
JWT.
This way we'll be able to set a custom issuer.
As an example, we could set this to be a public S3 bucket which doesn't
suffer from the thumbprint validation issuer.

* ensure issuer is a valid https url

* use s3 uri instead of any url for issuer

* typo and require s3 fields

* add missing s3 location when creating integration

* improve error messages
2024-03-15 18:08:35 +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
75c7d01741 AWS OIDC: Move enrollment of EKS clusters to the gRPC service. (#38683)
* AWSOIDC: Move enrollment of EKS clusters to the gRPC service.

* Add missing godoc.

* Remove unneeded code.

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

* Fix after rebase.

* Remove proxyPublicAddr field from grpc request.

* Change test address.

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

* Remove isCloud and enableAutoUpgrades fields from grpc request.

* Update EKS cluster name field in AWSOIDC integration

* Fix tests.

* Refactor variable initiation.

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

* Fix after rebase

* Remove unused code.

---------

Co-authored-by: Marco André Dinis <marco.dinis@goteleport.com>
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2024-02-28 19:28:21 +00:00
Marco André Dinis dd84c87e1f AWS OIDC: CreateEICE service (#38548)
This PR creates a new method on the AWS OIDC gRPC service that deploys
multiple EC2 Instance Connect Endpoints.

This is part of a refactor that moves the API calls behind the Auth
Service.
2024-02-28 15:52:59 +00:00
Marco André Dinis 0a3e7464d6 AWS OIDC: List EKS Clusters service (#38440)
* AWS OIDC: List EKS Clusters service

This PR creates a new method on the AWS OIDC gRPC service that lists eks
clusters.

This is part of a refactor that moves the API calls behind the Auth
Service.

* doc pb
2024-02-27 21:08:48 +00:00
Marco André Dinis c51cebe978 AWS OIDC: DeployService service (#38511)
* AWS OIDC: DeployService service

This PR creates a new method on the AWS OIDC gRPC service that deploys
an ECS Service.

This is part of a refactor that moves the API calls behind the Auth
Service.

* add rbac test and rename teleport config string

* revert e
2024-02-23 17:43:15 +00:00
Marco André Dinis 021adacb88 AWS OIDC: List EICE service (#38332)
* AWS OIDC: List EICE service

This PR creates a new method on the AWS OIDC gRPC service that lists ec2
instance connect endpoints.

This is part of a refactor that moves the API calls behind the Auth
Service.

* add required fields and aws api ref

* add test
2024-02-20 17:24:26 +00:00
Marco André Dinis 47028caeab AWS OIDC: List EC2 service (#38326)
This PR creates a new method on the AWS OIDC gRPC service that lists ec2
instances as Teleport Nodes.

This is part of a refactor that moves the API calls behind the Auth
Service.
2024-02-20 12:07:51 +00:00
Marco André Dinis 44957e2eb2 AWS OIDC: List SecurityGroups service (#38348)
This PR creates a new method on the AWS OIDC gRPC service that lists
SecurityGroups.

This is part of a refactor that moves the API calls behind the Auth
Service.
2024-02-20 11:27:05 +00:00
Marco André Dinis 76e751ff07 AWS OIDC: DeployDatabaseService service (#38092)
* AWS OIDC: DeployDatabaseService implementation

This PR creates a new method on the AWS OIDC gRPC service that deploys a
database service.
The deployment logic already existed.

* review pt1
2024-02-16 11:12:12 +00:00
Marco André Dinis a2591f25d7 AWSOIDC: ListDatabases service (#37853)
* AWSOIDC: ListDatabases service

This PR implements the ListDatabases service.
The Web API will now use this service instead of calling the
GenerateAWSOIDC Token.

* log and skip instead of failing when convertion fails
2024-02-16 09:34:55 +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 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
Marco André Dinis 5c63683645 AWS OIDC Service: bootstrap and ListDatabases stub (#37335)
This PR adds a new gRPC Service to handle the AWS OIDC Integration
actions.

All the HTTP exposed actions will use this new service.
Eg, list databases, list ec2 instances, and so on

This PR adds the new service and a placeholder for the first action to
me refactored: ListDatabases.
This action is not used/implemented yet.
2024-02-05 18:18:11 +00:00
Marco André Dinis 876362b0b1 AWSOIDC: Compute Proxy's Endpoint for issuing a token (#37253)
* AWSOIDC: Compute Proxy's Endpoint for issuing a token

Instead of receiving the issuer URL as param, use the internal state of
the proxies to fetch the public endpoint.

This deprecates the field so that old clients can still talk to the
AuthServer, but their Issuer param is ignored.

* Add single param for cached resources

* use cache for everything except keystore
2024-01-26 13:35:16 +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
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
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
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
Marco André Dinis f3a5d9695e Integrations: AWS OIDC - ListDatabases action (#24460)
* AWSOIDC Integration: ListDatabases

This PR adds a new Action for the AWSOIDC Integration: ListDatabases
The goal of this action is to provide the User a list of RDS Databases
from which the User will pick one to be added as a Teleport Database
Resource.
This way, the user doesn't need to copy/paste DB name, endpoints and
labels.

Before being able to call this action, the User has to set up an AWS
OIDC integration.

How does it work:
```
                    Client (web app)
                     │     ▲
                     │     │4. Returns list of DBs
 1. List Databases   │     │   (name, tags, status, endpoint)
                     │     │
                     │     │
                     │     │
                     │     │
                     ▼     │       3. rds.DescribeDBInstances
               ┌───────────┴────┐     (auth: token)                ┌─────────┐
               │                ├─────────────────────────────────►│         │
               │ Teleport Proxy │                                  │   AWS   │
               │                │     3.1. Get OIDC Config         │         │
               │                │◄─────────────────────────────────┤         │
               │                │     3.2. Get RSA Public Key      │         │
               │                │◄─────────────────────────────────┤         ├─────────┐ 3.3.
               │                │                                  │         │         │Validates token signature
               │                │                                  │         │         │with received public key
               │                │   3.4 Returns list of DBs        │         │◄────────┘
               │                │◄─────────────────────────────────┤         │
               └─┬──────────────┘                                  └─────────┘
                 │
                 │  2. Sign Token
                 │
                 ▼
              ┌───────────────────┐
              │                   │
              │   Teleport Auth   │
              │  RSA Private Key  │
              └───────────────────┘

```

* add resource and account ids to DB resource

* move api namespaces

* use types.Database instead of custom database format

* add database uri

* fix comments and rate limiter

* test name override when converting RDS V2 DBs

* fix webapi database URI field

* TestClusterDatabasesGet: add parallel
2023-04-19 15:42:53 +00:00
Marco André Dinis a71e822db0 Integrations service for CRUD operations (#23989)
* Integrations service for CRUD operations

This adds the services that will handle the CRUD operations.
It also includes a custom JSON serializer.

* improve integration.unmarshaljson

* add trace.wrap to service

* add CheckAndSetDefaults and godocs

* Integration resource: remove status
2023-04-05 16:49:43 +00:00