Commit Graph
197 Commits
Author SHA1 Message Date
Noah StrideandMarco Dinis 0586278cde Migrate GetClusterName to gRPC (#53164)
* Adjust GetClusterName method signature to include context.Context

* Start hacking on gRPC GetClusterName impl

* Fix test mocks to match signature

* Fix integration tests

* Fix integrations tests

* Missing ctx

* New GetClusterName RPC implementatin

* Add fallback cluster name

* Correct godoc comment

* Remove unused method

* Remove unused import

* Fix E2E test

* Fix tests

* Fix deferred context cancel in test conflicting with parallel subtests

* Fix import

* Fix imports

* Update lib/auth/auth_with_roles.go

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

---------

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>
2025-03-20 10:07:02 +00:00
Gabriel Corado bcf1625f9a Remove AWS SDK V1 references (#52990)
* refactor: remove references to aws sdk v1

* refactor(aws): remove legacy error conversion for s3

* refactor(awsoidc): remove unused clientv1

* refactor: code review suggestions

* refactor: move xml helper functions into alpnproxy package

* chore(gomod): move into lambda direct dep

* chore: fix import order
2025-03-18 15:43:12 +00:00
Alan Parra d3025b2a28 Apply the _DISABLE_AWS_FIPS setting to iam and stscreds (#52065)
* Add the iamutils package

* Add stsutils.NewCredentialsV1()

* Use iamutils.NewFromConfig()

* Use stsutils.NewCredentialsV1()

* Add forbidigo rules
2025-02-12 20:12:44 +00:00
Alan Parra 7f0c4e93bd feat: Allow non-FIPS endpoints on FIPS binaries (#51924)
* Add the dynamodbutils and stsutils packages

* Use stsutils.NewFromConfig()

* Use stsutils.NewV1()

* Use dynamodbutils.IsFIPSEnabled()

* Add forbidigo rules

* Appease linter
2025-02-11 22:45:04 +00:00
rosstimothy 2cced62805 Fix violations of non-constant format strings linter (#51812)
Depends on https://github.com/gravitational/teleport.e/pull/6006.
Now that we are compliant, the ignore rule was removed from the
golangci-lint config to prevent future regressions.
2025-02-04 16:43:35 +00:00
Steven Martin 79b11308ca Fix spelling for error message and logging (#51727) 2025-01-31 22:39:53 +00:00
Gavin Frazar ee119ea6d6 Remove remaining db and discovery AWS SDK imports (#51628)
This eliminates all remaining references to AWS SDK v1 in the
lib/srv/db/... and lib/srv/discovery/... packages.
Most of the changes are simply to remove dead code.
2025-01-30 23:06:09 +00:00
Marco Dinis 1a256cc155 Fix Integration Stats API when IAM permissions are missing (#51508) 2025-01-28 14:10:09 +00:00
rosstimothy 1e3266705c Tweaks to various sloglint overrides (#51522)
This aims to either alter logs to avoid the linter override, or at
minimum prevent formatting of messages if the log level is not
enabled.
2025-01-28 13:12:19 +00:00
Gavin Frazar cf15fa349c Migrate IAM in lib/cloud/clients to SDK v2 (#51145) 2025-01-17 18:22:28 +00:00
Marco Dinis b748f903bc Fix HTTPS thumbprint lookup test (#51152)
Go 1.23.5 changed the certificate (added another host), and the
thumbprint is now different.
Instead of updating the thumbprint, we now rely on the presented
certificate by the TLS Server.

This should ensure the test doesn't break again if the test certificate
is changed again.
2025-01-17 11:47:58 +00:00
Marco Dinis 8f99076d4c Remove EICE dead code (#51107)
* Remove EICE dead code

Accessing EC2 instances using EC2 Instance Connect Endpoint was
developed some releases ago.
However, due to strict quotas put in place by amazon, we decide to
remove this feature.

Since a couple of releases ago we hide this feature from the UI.
This PR removes dead code:
- removes the UI bits used during the Discovery flow
- removes the `teleport integrationn configure eice-iam` command
- removes API endpoinst that are no longer used
- deprecates the unused gRPC calls

The following parts were kept, to ensure we don't break existing set
ups:
- auto discovery of ec2 instances using the EICE method
- accessing Servers which have the ec2-ice subkind
- kubernetes operator and terraform provider EICE resource management

We might remove those in the future, but for now, they will be kept.

* add delete version notice
2025-01-16 18:36:39 +00:00
Paul Gottschling 70d70a2d60 Fix outdated docs URLs (#50923)
- Web UI source
- README
- lib
- api

Do not touch docs URLs in test case names or test data where we don't
expect users to navigate to the URLs.
2025-01-16 18:17:35 +00:00
Matt Brock b22f342680 Azure integration command (#47541)
* Initial command to create the managed identity and role

* Adding permissions and applying command params

* Adding graph permissions to the MSI

* Updating parameters

* Adding some details and cleaning up comments

* Fixing go.sum

* Linting

* License

* PR feedback

* Decoupling sync config with an interface for testing

* Tweaks to test mocking

* PR feedback

* Rebase adjustments

* PR feedback

* Switch to empty struct maps instead of bool maps for set representation

* Godocs

* Adding user agent to Azure SDK requests

* Linting
2025-01-16 17:43:20 +00:00
Guillaume J. Charmes 84956a8c8f Migrate eks discovery to aws sdk v2 (#50603)
* Remove all references to EKS sdk v1.

* Address PR comments.
2025-01-10 18:48:39 +00:00
Marco Dinis 4b2a0da91d Fix AWS ListDeployedDatabaseServices when there's no ECS Cluster (#50843)
Calling the AWS API `ecs:ListServices` with a non-existent ECS Cluster
name will return a 400 w/ ClusterNotFoundException.

The existing code was not handling that error and a raw error was
returned.

This PR changes the logic to ensure that case is handled and that the
ListDeployedDatabaseServices returns an empty list.

An alternative would be to call the ListClusters beforehand, but that
would increase the number of API calls we do to external services.
2025-01-09 09:45:41 +00:00
Gavin Frazar 20828a217d Simplify awsconfig loading (#50809)
This replaces awsconfig.WithIntegrationCredentialProvider option with the
awsconfig.WithOIDCIntegrationClient option.
This solves a chicken/egg problem with AWS config loading - callers no
longer need to load AWS config (to create a credential provider) to load
AWS config.
The OIDCIntegrationClient interface is also much simpler to implement.

This also adds default option overrides when creating an awsconfig.Cache.
For now, this is used to add an OIDCIntegrationClient when creating the
cache so that dependent callers don't have to.
2025-01-08 18:19:09 +00:00
Forrest c6ad9b221e add emptiness testutils (#50655)
* add emtiness testutils

* move golden to testutils
2025-01-07 16:36:01 +00:00
Nic Klaassen c5b4101d55 fix: allow CredentialCache.Retrieve to return before initialization (#50748)
* fix: allow CredentialCache.Retrieve to return before initialization

Fixes #50747

This PR adds an option to allow CredentialsCache.Retrieve to return with
an error before CredentialsCache.SetGenerateOIDCTokenFn has been called.
We have been relying on this behaviour for Auth service startup, because
the credential cache is a dependency for the audit storage, which is a
dependency for the auth server, which is a dependency for the credential
cache's GenerateOIDCTokenFn.
Some non-critical checks during auth startup must fail instead of
hanging on blocking the process from successfully starting.

* use default io timeout

* synchronize access to generateOIDCTokenFn
2025-01-06 18:49:45 +00:00
Tiago Silva 4d3e7d3ec9 fix: access graph fails to fetch s3 bucket details (#50758)
* fix: access graph fails to fetch s3 bucket details

With SDK V1, AWS get bucket details such as policies, acls, status...
didn't require the specification of the target s3 bucket location. With
the recent changes to support newer versions of the AWS SDK, the get
bucket details started to fail with the following error:

```
BucketRegionError: incorrect region, the bucket is not in 'ap-south-1' region at endpoint '', bucket is in 'eu-central-1' region
status code: 301, request id: QS5C24H12ZV3VNM4, host id: mzVDk4010MPTCFdxyE/XwERX9W35MSge85PG+h5Jvwyvi7MhxdXLaysb2PTZCMY9r1ngBi6Gv6g=, failed to fetch bucket "cyz" acls polic
```

This PR uses `HeadBucket` to retrieve the location of the s3 bucket and
then uses the bucket location client to retrieve the s3 bucket details.

Fixes #50757

* fix tests

* handle review comments
2025-01-06 12:20:52 +00:00
rosstimothy 8890e3e9bb Convert lib/integrations to use slog (#50484) 2024-12-21 02:06:23 +00:00
Marco Dinis dae0e0d478 AWS OIDC: List Deployed Database Services HTTP API (#49352)
* AWS OIDC: List Deployed Database Services HTTP API

This PR adds a new endpoint which returns the deployed database
services.

Calling the ECS APIs requires a region, so we had to iterate over the
following resources to collect the relevant regions:
- databases
- database services
- discovery configs

* extract loops

* improve config parse and moved endpoint to a GET

* revert http verb for listing

* remove pointer
2024-12-20 09:25:58 +00:00
Marco Dinis 475753f326 AWS OIDC: List Deployed Database Services - implementation (#49331)
* AWS OIDC: List Deployed Database Services - implementation

This PR implements the List Deployed Database Services.

This will be used to let the user know which deployed database services
were deployed during the Enroll New Resource / RDS flows.

* validate region for dashboard url
2024-12-18 09:16:59 +00:00
Marco Dinis d37da511c9 UserTasks for Discover EKS: create tasks when auto enrolling fails (#50024)
* UserTasks for Discover EKS: create tasks when auto enrolling fails

This PRs changes the DiscoveryService to ensure it creates UserTasks
when EKS Clusters fail to auto-enroll.

* simplify types
2024-12-13 11:47:12 +00:00
Marco Dinis 0e1f1bc45e Discover EKS: allow custom labels for Kube Server (#49420)
This PR allows the UI to send extra labels for setting up the EKS
cluster.
2024-12-11 10:05:14 +00:00
Marco Dinis f708a58854 Enroll EKS Cluster from Discover: wait for access entry (#49467)
After running this flow a couple more times, we discovered that some
times it takes longer than 25s.
From multiple tests we found out that it can take up to 30s.
Instead of setting that as the wait time, we add a little more to ensure
we are more resilient.
2024-11-26 17:24:15 +00:00
Tiago Silva 903c1ad6f4 [entraid] set all optional claims to avoid weird behavior (#48957)
Entra sometimes sends the OptionClaims when retrieving a certain application if only SAML2Token is set, other times it doesn't return them.

This PR fills all id and access token values so entra doesn't fail to send the optional token value.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2024-11-14 13:13:15 +00:00
Marek Smoliński 0634037966 AWSOIDC integration: Align CreateAWSConfigForIntegration (#48812) 2024-11-14 11:56:49 +00:00
Alan Parra 51b0e374ac chore: Bump golangci-lint to v1.62.0 (#48748)
* chore: Bump golangci-lint to v1.62.0

* Use require.NoError instead of require.Empty
2024-11-11 15:13:48 +00:00
Marco Dinis 3aa6f3c5cf EKS Auto Enroll: wait for agent to be installed (#48706)
After doing this flow a couple of times, it seems that 6 seconds is not
enough.

It should not take longer than 20 seconds.
2024-11-11 09:31:06 +00:00
Marco Dinis 29568bdf64 Fix EKS Discover flow fields (#48665)
At a previous PR we added two new fields in the UI and backend, but
failed to add them to the layers in between (grpc service).

This PR adds them and also fixes a typo on the EndpointPublicAccess
field name.
2024-11-08 15:33:38 +00:00
Sakshyam Shah c6c62beeac add sso:ListPermissionSetsProvisionedToAccount to StatementForAWSIdentityCenterAccess (#48496) 2024-11-06 14:20:53 +00:00
Alan Parra 93110cae64 chore: Bump AWS modules (#48322)
* chore: Bump api/ modules

* Tidy other modules

* chore: Bump AWS SDKv2 modules

* chore: Bump github.com/awslabs/amazon-ecr-credential-helper/ecr-login

* Tidy integrations/ modules

* Replace usages of s3types.LifecycleRuleFilterMemberPrefix
2024-11-02 14:28:13 +00:00
Marco Dinis a6395129b9 Discover EKS: handle invalid Auth Mode and Private only endpoint (#48060)
During the EKS Enrollment in the Discover wizard, when listing clusters,
check for pre-reqs when showing available clusters.

1. When in Cloud, only allow enrollment if the cluster has a Public
   Endpoint for configuration.

1. Only show clusters which have the API authentication mode enabled
   (either API only or API_AND_CONFIG_MAP).
2024-11-01 15:37:15 +00:00
Marco Dinis 2be4c3924f Discover EKS: handle 'CONFIG_MAP' authentication mode gracefully (#47960)
* Discover EKS: handle 'CONFIG_MAP' authentication mode gracefully

EKS Cluster Access Config's Authentication mode can be set to one of:
- API
- API_AND_CONFIG_MAP
- CONFIG_MAP

Teleport requires either API or API_AND_CONFIG_MAP to install the helm
chart.

This PR checks this value before trying to install the helm chart.
This way the user is presented with a better error message.

* use vars coming from ekstypes
2024-11-01 14:45:15 +00:00
Sakshyam ShahandMarek Smoliński 75d27b4f86 Dependency for Identity Center SDK (#48192)
* AWS IC SDK

* awsoidc credprovider package

* go mod tidy on integrations

* place aws-sdk-v2 imports together

---------

Co-authored-by: Marek Smoliński <marek@goteleport.com>
2024-10-31 22:18:25 +00:00
Tiago SilvaandMarco Dinis 768a0bd684 [entraid] add setup script for offline clusters. (#47863)
* [entraid] add setup script for offline clusters.

This PR adds a cli configuration for Entra ID where it's possible to default to system credentials instead of relying on OIDC for authentication in EntraID. OIDC is not always a possibility specially when the cluster is private and not internet acessible.

The UX is the following:

```text

Step 1: Run the Setup Script

1. Open **Azure Cloud Shell** (Bash) using **Google Chrome** or **Safari** for the best compatibility.
2. Upload the setup script using the **Upload** button in the Cloud Shell toolbar.
3. Once uploaded, execute the script by running the following command:
   $ bash entraid.sh

**Important Considerations**:
- You must have **Azure privileged administrator permissions** to complete the integration.
- Ensure you're using the **Bash** environment in Cloud Shell.
- During the script execution, you'll be prompted to run 'az login' to authenticate with Azure. **Teleport** does not store or persist your credentials.
- **Mozilla Firefox** users may experience connectivity issues in Azure Cloud Shell; using Chrome or Safari is recommended.

Once the script completes, type 'continue' to proceed, 'exit' to quit: continue

Step 2: Input Tenant ID and Client ID

With the output of Step 1, please copy and paste the following information:
Enter the Tenant ID: 1056b571-0390-4b08-86c8-2edba8d9ae79
Enter the Client ID: 1056b571-0390-4b08-86c8-2edba8d9ae79

Successfully created EntraID plugin "name".
```

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

* move function to api

* handle code review comments

* Apply suggestions from code review

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

* fix url

* enable group claims

* add godoc

* handle code review comments

* fix gomod

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>
2024-10-29 17:51:58 +00:00
Lisa KimandMarco Dinis 02354f880c Allow passing an optional ARN when health checking an AWSOIDC integration (#46935)
* AWS OIDC Ping: allow custom ARN

This PR changes the Ping method to accept a custom ARN.

This is meant to be used by WebUI to do a health check for the
integration:
- when creating
- when editing
- when selecting during Discover flows

If the Ping method receives an ARN, it will use that value instead of
using the one stored in the backend.

* rename arn to roleArn

* rename arn to role_arn

---------

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>
2024-10-28 17:08:58 +00:00
Trent ClarkeandMarek Smoliński eda3671595 Moves and exposes the AWS OIDC credentials cache (#47840)
* Moves and exposes the AWS OIDC credentials cache

The IdentityCenter integration users OIDC to authenticate with AWS, and so
will re-use the existing OIDC credential caching code used by the external
audit storage package.

This change

- extracts the credential cache from the `externalauditstorage` package,
- moves it to the `awsoidc` package to indicate that is generally useful, not
  just for storage access), and
- makes it public.

This patch also copies the applicable cache tests from `externalauditstorage`. The
credential cache tests in `externalauditstorage` have been preserved because they
also test backwards compatibility with AWS SDK v1 credential provider, which the
new tests do not.

* Test fixup

* Linter fixups

* Remove ttlValuer

* Apply suggestions from code review

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

---------

Co-authored-by: Marek Smoliński <marek@goteleport.com>
2024-10-23 13:27:56 +00:00
Nic Klaassen 0a0d4137db eliminate rsa.GenerateKey and lib/auth/native (#47768) 2024-10-21 20:55:22 +00:00
Gavin Frazar 48fa24208b aws oidc skip aurora clusters without instances (#47529)
Instead of returning an error, just skip the cluster that have no
instances.
2024-10-15 23:02:12 +00:00
Gavin Frazar 4eb416d503 propagate proxy upgrade channel config to aws oidc updater (#47476) 2024-10-15 20:11:01 +00:00
Gavin Frazar d88e549070 use pre-release cdn and image repo for aws integration flows (#47474) 2024-10-11 22:05:24 +00:00
Brendan O'Halloran baad15f502 EAS: use default retry attempts for STS client (#47447) 2024-10-10 17:33:24 +00:00
Gavin Frazar 7812202fff recommend security groups in RDS enrollment wizard (#47245)
* recommend security groups in RDS enrollment wizard

* make terraform-resources-up-to-date
2024-10-08 22:04:14 +00:00
Sakshyam Shah 3eaab34ff2 feat: AWS OIDC integration role policy-preset for identity center integration (#47164)
* feat: adds a new 'policy-preset' flag to 'integration configure awsoidc-idp' command

* adapt to new awsactions

* output formatting and golden test

* run ui prettier, fix getAwsOidcConfigureIdpScriptUrl test

* comments cleanup, mend TestBuildAWSOIDCIdPConfigureScript test

* address review:
- use AwsOidcPolicyPreset in UrlAwsOidcConfigureIdp
- use NoSuchEntityException instead of EntityAlreadyExistsException in PutRolePolicy mock
- fix typo

* use empty string as unspecified value

* add optional field comment

* Merge branch 'master' of github.com:gravitational/teleport into sshah/aws-oidc-preset-policy

* Revert "Merge branch 'master' of github.com:gravitational/teleport into sshah/aws-oidc-preset-policy"

This reverts commit ad2a0904e9.
2024-10-08 15:13:40 +00:00
Noah Stride b266c2858a Workload Identity: JWT SVID OIDC compatability (#47079)
* Start working on OIDC compatability of JWT SVIds

* Refactor existing oidc helpers

* Add tests for endpoints

* omitempty

* Add field required by AWS
2024-10-08 07:25:38 +00:00
Gavin Frazar c74835d219 integration configure commands prompt for changes (#47224)
* integration configure commands prompt for changes

This applies to the following "teleport integration configure" subcommands:
* deployservice-iam
* eice-iam
* ec2-ssm-iam
* aws-app-access-iam
* eks-iam
* access-graph
* listdatabases-iam

These commands will now describe the actions they will take, the
resources that will be created/configured, and will by default prompt
the user to confirm the changes.

Confirmation prompt can be skipped by passing the new --confirm flag.

The confirmation prompt is enabled by default because the most common
case, if not the only case, where a user runs these commands is via an
opaque "bash -c $(curl ...)" script generated by a web UI enrollment
wizard.

* address feedback

* fix test

* pluralize only when there are multiple actions

* remove leading newline from func body

* remove extra newline in ec2 iam configure request

* improve --confirm flag description

* fix test

* remove extraneous else

* dont display escaped ssm doc for op plan
2024-10-08 00:20:14 +00:00
Gavin Frazar d1645dedc6 display security group id rules (#47152) 2024-10-05 00:54:54 +00:00
Gavin Frazar a3e1316260 make configure awsoidc-idp actions transparent (#46747)
Applies to the integration command that the web UI discover flows tell
users to run in AWS CloudShell to setup the AWS OIDC identity provider:
    teleport integration configure awsoidc-idp

The command describes itself, its actions, and the desired state after
it runs. It then prompts the user (by default) to confirm the action
plan before proceeding.
The confirmation prompt can be overridden with cli flag --confirm
if desired.

The IAM role it configures is no longer required to have the "ownership"
tags that teleport applies if it's created by teleport, since the user is
now prompted for confirmation before making changes.
This allows a user to configure an existing IAM role without tagging the
role for configuration by teleport.
The command will still attempt to ensure the IAM role it configures has
teleport tags, but failing to do so is only a warning.
2024-10-03 20:50:02 +00:00