Commit Graph
47 Commits
Author SHA1 Message Date
Justinas StankevičiusandJakub Nyckowski 6fbfadc230 Access Graph: sync AWS identity providers (#41368)
* Add AWSSAMLProviderV1 to access graph proto

* Access Graph: sync AWS SAML Providers

* Parse SAML entity descriptor before sending to TAG

* Add protos for AWS OIDC providers

* Fetch AWS OIDC providers

* Fetch signing certificates for AWS SAML providers

* Deflake identity provider fetch test

The concrete implementation of IAM mock uses a map,
resulting in non-deterministic iteration order.
Sort the results before comparing to alleviate.

* Update lib/srv/discovery/fetchers/aws-sync/iam_test.go

Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>

---------

Co-authored-by: Jakub Nyckowski <jakub.nyckowski@goteleport.com>
2024-05-14 16:20:36 +00:00
Marco DinisandEdward Dowling 0aaf1b21c3 AWS OIDC: Script to configure EC2 Auto Discover with SSM (#41053)
* AWS OIDC: Script to configure EC2 Auto Discover with SSM

There's a new teleport command that adds an inline policy which enables
the AWS OIDC Integration to handle EC2 Auto Discover using the script
mode (SSM).
It also adds the SSM Document used in the teleport installation.

There's also a new endpoint which returns the one off script that uses
that command.

* Update lib/integrations/awsoidc/ec2_ssm_iam_config.go

Co-authored-by: Edward Dowling <EdwardDowling@users.noreply.github.com>

---------

Co-authored-by: Edward Dowling <EdwardDowling@users.noreply.github.com>
2024-05-09 17:20:27 +00:00
Tiago Silva cf20bc282d Fix missing permission to describe access entries (#40940)
This PR fixes a missing permission when describing access entries for
eks clusters

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2024-04-26 12:11:20 +00:00
Zac Bergquist 8cd1c429f5 Fix up some poor wording (#40832)
Closes #40294
Closes #39172
2024-04-23 22:01:41 +00:00
Marco André Dinis dc5975ea37 AWS OIDC: IAM set up for AWS App Access (#40575)
* AWS OIDC: IAM set up for AWS App Access

AWS App Access using AWS OIDC Integration requires a new policy in the
AWS OIDC Role.
This PR adds a one-off script that executes the configuration command
that adds said policy.

* improved comments, remove dead code, improve logging

* improve comment and http client var name

* move back to interface

* remove default client

* rename role to rolename

* enable fips endpoint support

* restrict target roles by their tags

* use true for tag value
2024-04-19 14:56:44 +00:00
Marco André Dinis 455632e28a EC2 Auto-Discovery: EICE support (#35504)
* AutoDiscover: add support for EICE nodes

* ignore openssh nodes when updating labels from serverinfo

* downcase imports

* improve comment on why we need account/instance and subkind

* add applyovertime method

* skip nodes that wont expire in the near future

* create helper functions
2024-03-26 16:16:20 +00:00
Marco André Dinis 64ad6ba632 AWS OIDC IdP Configuration: support S3 buckets as provider (#39026)
This PR adds support for setting the AWS OIDC Integration with an S3
bucket as issuer.
2024-03-15 22:11:25 +00:00
Marco André Dinis 62933c4f3a AWS OIDC - DeployService: Add ecs:TagResource policy (#39066)
If the Resource Tagging Authorization setting is enabled, the client
must hold the `ecs:TagResource` policy in order to create resources with
Tags.
2024-03-07 16:03:50 +00:00
Tiago Silva 8f357eb432 AWS-OIDC: add ListRolePolicies and ListAttachedRolePolicies (#38926)
* AWS-OIDC: add ListRolePolicies and ListRoleAttachedPolicies

This PR adds missing  iam:ListAttachedRolePolicies and iam:ListRolePolicies IAM permissions to TAG setup wizard.

This complements PR https://github.com/gravitational/teleport/pull/38071

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

* fix typo

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2024-03-05 11:02:50 +00:00
Tiago SilvaandAnton Miniailo 2eef6d7d2c Discovery: Allow configuring AWS TAG IAM integration (#38071)
* Disovery: Allow configuring AWS TAG IAM integration

This PR allows the configuration of IAM permissions required for Access
Graph AWS Sync using Teleport OIDC integration.

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

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

* handle code review suggestions

* Update lib/web/integrations_awsoidc.go

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

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
Co-authored-by: Anton Miniailo <anton@goteleport.com>
2024-02-14 19:16:40 +00:00
rosstimothy b7318b5c7e Enable errorlint via golangci-lint (#37669)
Adds the new linter and configures it to prevent direct error
comparisions and type assertions in favor of errors.Is and errors.As.
All current violations caught by the linter have been updated
accordingly.
2024-02-02 15:59:24 +00:00
Anton MiniailoandMarco André Dinis 134e26e778 Add command for configuring EKS IAM access for Discover (#36417)
* Add command for configuring EKS IAM access for Discover

* Remove redundant dot.

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

* Simplify test cases

* Fix typo.

* Fix imports

---------

Co-authored-by: Marco André Dinis <marco.dinis@goteleport.com>
2024-01-08 22:49:08 +00:00
Marco André DinisandLisa Kim 2cc0d62c03 AWS OIDC: DeployDatabaseService per VPC (#35899)
* AWS OIDC: Deploy Database Service to multiple VPCs

* Update lib/web/apiserver.go

Co-authored-by: Lisa Kim <lisa@goteleport.com>

* Update lib/web/ui/integration.go

Co-authored-by: Lisa Kim <lisa@goteleport.com>

---------

Co-authored-by: Lisa Kim <lisa@goteleport.com>
2024-01-08 16:46:35 +00:00
Zac Bergquist 44a6bb1933 Use pkg slices from the standard library (#35905)
Prefer the stdlib version of the experimental package.
Includes a depguard update to prevent future regressions,
as well as an e-ref update to appease depguard.

Generated with:

    $ gofmt -w -r '"golang.org/x/exp/slices" -> "slices"' . && \
        make fix-imports
2023-12-19 23:06:53 +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
Nic Klaassen a3318979ed External Audit Storage: rename from ExternalCloudAudit (part 1) (#34961)
* External Audit Storage: rename from ExternalCloudAudit (part 1)

* fix buf-breaking lint

* remove unused event
2023-11-27 19:02:52 +00:00
Nic Klaassen c92fe24f7a fix: correct IAM policies for BYOB (#34484)
This commit fixes the IAM policies generated by the oneoff
externalcloudaudit bootstrap command based on manual testing, and brings
them more in line with the original RFD
https://github.com/gravitational/cloud/blob/master/rfd/0077-Bring-your-own-bucket.md
2023-11-14 17:38:10 +00:00
Lisa Kim 6fce85e299 Web: Ease AWS integration with Discover Flow (#33777)
* Delete aws oidc old flow

* Account for http prefixes for proxy addr and print role arn value

* Clean up aws related rules

* Add new script endpoint and clean up naming

* Create configure iam perm component

* Extract common error and use ConfigureIamPerm comp

* Extract finish dialog, shown after creating integration

* Refactor aws integration enroll screen

* Clarify aws oidc integration uses

* Fix iam config test

* Add ec2:DescribeSecurityGroups to StatementForListRDSDatabases

* Address CR

* Remove region selector

* Fix test
2023-11-02 16:53:16 +00:00
Brian Joerger 2ed1538e40 Ignore shared aws config not found error (#33651)
* Ignore shared aws config not found error.

* Move error conversion to lib/cloud/aws/errors.go
2023-10-25 01:56:46 +00:00
Nic Klaassen 215f968842 feat: IAM permissions for BYOBucket (#33416)
This commit adds a one-off teleport command that configures the
necessary IAM permissions for the upcoming External Cloud Audit
(BYOBucket) feature.

An example command invocation looks like:
```
$ teleport integration configure externalcloudaudit-iam \
  --aws-region us-west-2 --role nic-byob-test --policy nic-byob \
  --session-recordings s3://nic-byob/sess-rec-v2 \
  --audit-events s3://nic-byob/events --athena-results s3://nic-byob/results \
  --athena-workgroup primary --glue-database nic_byob --glue-table nic_byob_table
```

In normal usage this command will be generated for the user so that they
can just copy a command from the Web UI and run it in AWS CloudShell.

The permissions generated here are based on
https://github.com/gravitational/cloud/blob/rfd/77-bring-your-own-bucket/rfd/0077-Bring-your-own-bucket.md,
but only include the permissions necessary for using the feature at
runtime and not any permissions necessary to bootstrap/create the
resources.
2023-10-17 19:42:41 +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
Marco André Dinis 4d9adbd75a AWS OIDC: command to configure IAM for listing databases (#31656)
* AWS OIDC: command to configure IAM for listing databases

Previously we were guiding users in a series of screens and copy/paste
so that the user could configure the AWS OIDC Integration.
This guide also included adding the first feature: enroll an RDS
Database.

We created a new command that sets up the OIDC IdP, but decoupled from
the enroll rds feature.

After updating the guide to use the new command and remove the guide, we
must provide a way for users to set up the required policy for Enrolling
RDS Databases.
This PR adds that command

* review pt1

* rename to ConfigureIAMListDatabasesRequest

* removed wrapper

* fix command description

* move aws client setup to common

* use logrus instead of log
2023-09-15 18:17:48 +00:00
Marco André Dinis 069cd24368 AWS OIDC: Set up integration with a single command (#31521)
* AWS OIDC: Set up integration with a single command

Creating an AWS OIDC Integration requires a lot of clicks, copy/paste,
navigation between tabs.

This PR adds a single teleport command that creates all the required
resources in AWS:
- AWS OIDC Identity Provider that uses Teleport as source
- AWS IAM Role that can be used by this Identity Provider

This role, will then have inline policies allowing multiple features in
Teleport.
Example: a policy must be added to this role that has
`rds:DescribeInstances` and `rds:DescribeClusters` so that the user can
use the integration to enroll RDS Databases.

* improve docs

* improve godoc
2023-09-13 07:21:00 +00:00
Marco André Dinis 630db38cff AWS OIDC - DeployService: add optional Security Groups (#30968)
When deploying a Teleport service using the AWS OIDC DeployService, we
can provide the SecurityGroups to be applied to the network
configuration of the service.

Using the default SG for the VPC (vpc is inferred from the used subnets)
might not always be the best one (it is usually locked down).

This PR adds an optional new field that clients can use to be explicit
about the SGs they want.

We also added a new permission when configuring the IAM Permissions for
the DeployService, to allow the usage of the ListSecurityGroups action.
Users can see the list of SG and then pick which ones they want.
2023-08-31 07:16:05 +00:00
Marco André Dinis 33185f953a AWS OIDC: Configure IAM for EC2 Instance Connect Endpoint (#30851)
* AWS OIDC: Configure IAM for EC2 Instance Connect Endpoint

This PR adds a new teleport command that sets up the required
permissions to use EC2 Instance Connect Endpoint to connect to an EC2
instance.

It also adds a oneoff script that runs this command.
The goal is to give a user a script for them to run, the script then
downloads teleport and calls AWS APIs to create the inline policy.

* add const and lowercase error

* use correct client
2023-08-24 11:33:56 +00:00
STeve (Xin) Huang e2320d7950 Fix AccessDenied not recognized for MemoryDB/RSSL API calls (#30226) 2023-08-10 13:04:47 +00:00
Marco André Dinis e32248c312 EC2 Instance Connect Endpoint: List EC2 Instances (#29366)
* EC2 Instance Connect Endpoint: List EC2 Instances

We must list the EC2 instances to the user, so they can pick one and
then add them as a Node.

This PR adds EC2 Instance Listing.
To do this, we convert the EC2 Instance into Teleport Server with a
special subkind: SubKindOpenSSHEC2InstanceConnectEndpointNode

This is similar to the ListDatabases endpoint.

* review pt1

* fix const and add test

* use any instead of interface{}
2023-08-10 11:26:10 +00:00
Marco André Dinis e043ac07ea AWS OIDC - DeployService: configure IAM (#28088)
* auto configure deployservice iam

* review pt1

* review pt2
2023-06-30 18:35:29 +00:00
Jakub Nyckowski 18a5327699 Remove most t.Log() from tests (#28453)
The t.Log() function calls have been removed from most tests. This is to keep our test logs cleaner and more focused on error messages. Logging every detail in tests makes it harder to spot actual errors and relevant information.
2023-06-29 15:14:09 +00:00
Krzysztof Skrzętnicki 1b69fbcbed OpenSearch AWS autodiscovery (#27537)
* OpenSearch AWS autodiscovery

* Normalize description, check err.

* Fix tests.
2023-06-16 12:56:53 +00:00
Alex McGrath 237954aa21 Add certificate rotation to teleport openssh join oneshot command (#24194)
* Add certificate rotation to `teleport openssh join`

Fix agentless test

Resolve comments

refactor to use existing rotation/backend

resolve comments

resolve comments

Use a comma separated additional-principals

resolve comments

resolve some comments

resolve comments

resolve comments

add sshd_test

remove openssh from config.Configure

just use current time for registerServer rotation

resolve comments

* resolve comments

* fix having to .Shutdown and .Close

* make check command configurable

* typo

* Add a timeout to shutdown
2023-05-22 12:22:37 +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
Gavin Frazar 8be84115f5 update aws configurator (#24362)
* fix iam statements for AWS assumed-role identity
  * configurator tries to convert assumed-role to role
* revert IAM semaphore to use identity name
* hide the unused --attach flag, fix typo
* godoc reminder for databases with IAM db users
* add AWS Keyspaces and DynamoDB to AWS configurator
* relax constraint on external id in fileconfig
  * add fileconf test for externalid w/o assume role
* check for actions before prompting to confirm
* fix teleport discovery bootstrap --confirm
2023-04-12 19:47:35 +00:00
STeve (Xin) Huang 5ee85bdf72 Add sts:AssumeRole to database boundary policy (#20215) 2023-01-17 14:56:39 +00:00
Marco André Dinis 6286488be3 Database: validate AWS Account ID (#19638)
When the AWS Account ID is provided, we must check that it is a valid
one.

AWS Account ID is a well documented field: 12-digit string

This check is meant to prevent typos when creating Databases mainly from
the Web UI in the context of Teleport Discover.
2022-12-28 12:42:39 +00:00
STeve (Xin) Huang 43529b2653 AWS Redshift Serverless auto-discovery (#18974) 2022-12-09 21:23:56 +00:00
STeve (Xin) Huang d8f4581606 Web API for getting database IAM policy (#17635) 2022-11-09 13:58:17 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Gabriel Corado 65c022893d Add Azure AD user managed identity authentication for SQL server (#17142) 2022-10-21 15:06:51 +00:00
Zac Bergquist 7cb27606cc Speed up TestEC2IsInstanceMetadataAvailable (#17353)
When testing the "not available" case, this test closed the server
and waited for the AWS SDK to make several attempts before finally
giving up.

Instead of shutting down the server, return an error. This triggers
the same error handling branches, but doesn't require multiple
attempts by the SDK.

Before:

$ go test -run TestEC2IsInstanceMetadataAvailable ./lib/cloud/aws -count=1
ok  	github.com/gravitational/teleport/lib/cloud/aws	4.272s

After:

$ go test -run TestEC2IsInstanceMetadataAvailable ./lib/cloud/aws -count=1
ok  	github.com/gravitational/teleport/lib/cloud/aws	0.262s
2022-10-13 16:55:35 +00:00
Andrew Burke ac257084a7 Automatically import Azure tags (#16218)
This change lets Teleport automatically import tags from the Azure instance it's running on.
2022-09-28 23:40:13 +00:00
d8c9b08001 Support China and GovCloud for database access (#15359)
Co-authored-by: waylen <waylen.guo@gmail.com>
Co-authored-by: Jianghui Guo <89057156+waylenguo@users.noreply.github.com>
Co-authored-by: STeve (Xin) Huang <huangin52@gmail.com>
2022-08-16 18:42:18 +00:00
STeve (Xin) Huang af2824fc9b Change IAM "UnmodifiableEntity" error to a debug log (#14594) 2022-07-27 16:58:23 +00:00
STeve (Xin) Huang 50dcd493df Manage ElastiCache Users (#12709) 2022-06-01 01:10:56 +00:00
Andrew Burke a8ed7bd1fd Automatically import EC2 tags (#12593)
This change allows Teleport to automatically import EC2 tags when running in an EC2 instance.
2022-05-31 23:19:16 +00:00
Gabriel Corado df44457b02 feat: aws database configurator (#9145) 2022-02-18 21:15:54 +00:00
Roman Tkachenko ce547953db Automatically import RDS databases (#8481) 2021-10-15 11:03:10 -07:00