Commit Graph
54 Commits
Author SHA1 Message Date
Gabriel Corado 1db489562b Remove unused AWS SDK v1 references (#53537)
* refactor(aws): remove unused sdk v1 references

* refactor(aws): drop unused migration package

* chore: go mod tidy
2025-03-29 02:25:01 +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
8f02eb11df Add tctl plugins install awsic (#51239)
* Adds `tctl plugins install awsic`

Adds a comand-line installation tool for the AWS Identity Center integration.

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

* Apply suggestions from code review

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

---------

Co-authored-by: Trent Clatke <trent@goteleport.com>
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2025-02-19 22:29:29 +00:00
Trent Clarke 1364c35d24 Move Identity Center validation tools to OSS (#52239)
In order to provide better validation when installing the IC integration via `tctl`,
this patch moves some IC-specific validation tools from `teleport.e` to
into the OSS repository.
2025-02-19 02:48:35 +00:00
Alan Parra e374c243d4 Move IsFIPSDisabledByEnv to lib/utils/aws/awsfips (#52123) 2025-02-14 12:25:47 +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
Gavin Frazar b69d49b2a2 Simplify lib/utils/aws (#51627)
This eliminates the SigningService in favor of a free function
SignRequest, which eliminates AWS credential loading and simplifies the
AWS utils package.
In the process of doing this refactor, the AWS app handler has been
changed to use AWS SDK v2 to load its credentials as well.
2025-01-30 20:14:45 +00:00
Gabriel CoradoandSTeve Huang ad2774d6c5 Migrate AWS OpenSearch requests signing credential generation to AWS SDK V2 (#51149)
* refactor(opensearch): use aws config provider for signing service

* test(opensearch): cleanup unused code

* fix: accept a base role on the signing service

* feat(aws): provide a way to use different external id for role

* add external ID

---------

Co-authored-by: STeve Huang <xin.huang@goteleport.com>
2025-01-28 19:17:13 +00:00
Zac Bergquist d71293f964 Replace usages of x/exp/maps with stdlib maps package (#51448) 2025-01-28 14:54:40 +00:00
Gavin Frazar cf294752b6 Fix AWS SigV4 parsing (#50973)
* Fix AWS SigV4 parsing

Parsing the AWS SigV4 Authorization header no longer requires spaces
between the components - only the comma delimiter is required.

* add test case for empty signed header list
2025-01-14 19:21:05 +00:00
rosstimothy 05be924ae0 Convert lib/utils to slog (#50340)
This only converts the places in the utils package that were
logging with logrus, but it does not fully remove the logrus
package as a dependency. The package is home to the logrus text
formatter which needs to exist until slog is the only logging
mechanism in use.
2024-12-19 15:08:04 +00:00
Gavin Frazar 518d4e787b migrate lib/srv/alpnproxy to AWS SDK v2 (#49973) 2024-12-11 22:23:21 +00:00
Gavin Frazar 3208c3d338 migrate tsh common to aws sdk v2 (#49449)
* add AWS SDK v2 migration utils package

* migrate tool/tsh/common to AWS SDK v2

* adapt AWSAccessMiddleware to AWS SDK v2
2024-12-09 17:42:23 +00:00
rosstimothy a9c7978ad2 Prevent using custom enpoints if one is not defined (#49107)
The AWS endpoint sanititazion was inadvertantly being applied all
the time, causing configurations not using custom endpoints to be
forced into using a custom endpoint instead of AWS.
2024-11-16 01:32:32 +00:00
rosstimothy b439b03b04 Sanitize aws service custom endpoints (#48992)
There is a slight behavior change in aws-sdk-go-v2 regarding custom
endpoints. The new sdk requires the endpoints to be a valid URI, and
the legacy sdk would allow a hostname only enpoint and automatically
apply a scheme. To prevent breaking existing configurations when
upgrading to v17, we now have to apply the same logic to endpoints
manually that the legacy sdk used to apply for us.

Closes https://github.com/gravitational/teleport/issues/48760.
2024-11-14 19:26:37 +00:00
rosstimothy f84405d5d3 Resolve and log endpoints of AWS services (#48710)
Includes the AWS endpoints in log output to allow easier
inspection of which URIs are being hit based on configuration.

Closes https://github.com/gravitational/customer-sensitive-requests/issues/333.
2024-11-13 16:30:19 +00:00
rosstimothy 56d85facba Restore S3 FIPS and custom endpoint capabilities (#48684)
When migrating the S3 events handler to use aws-sdk-go-v2 applying
the FIPS settings and custom endpoint were inadvertently dropped.
This restores the functionality, while also adding tests to ensure
that they are always respected going forward.

A similar test was added to the dynamodb events handler as well to
prevent any regressions with FIPS settings there.
2024-11-12 16:45:53 +00:00
Gavin Frazar 9694550f5e migrate aws configurator to sdk v2 (#46367)
* migrate aws configurator to sdk v2

* rename package imports with lowercase

* export iam client interface

* mock loading aws config

* remove underscore from test name

* remove loop var reassignment
2024-09-09 21:17:30 +00:00
b09748be4f [buddy] Truncate AssumeRole session name to API limits (#45202)
* 44833 Truncate AssumeRole session name to API limits

* Link reference

Co-authored-by: STeve (Xin) Huang <huangin52@gmail.com>

* Hash the username and add audit log

* review comments

* remove audit

---------

Co-authored-by: Joao Ubaldo <3534309+joaoubaldo@users.noreply.github.com>
2024-08-20 15:50:36 +00:00
Alan Parra 435a21badc chore: Bump AWS modules (#42316)
* chore: Bump AWS modules

* Tidy all modules

* Accept the "eu-isoe-west-1" AWS region as valid
2024-06-03 19:05:30 +00:00
Marco André DinisandRafał Cieślak 774b54ae5c Add AWS AccountID to IAM Roles in AWS App Access (#40657)
* Add AWS AccountID to IAM Roles in AWS App Access

* add story

* Use named export

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
2024-04-25 07:33:59 +00:00
Marco André Dinis db726c0025 Allow dynamic AWS Session provider (#40553)
* Allow dynamic AWS Session provider

Up until now, all the AWS Sessions were generated using the ambient
credentials.

This PRs changes this and allows for custom AWS Session Providers.
This will allow the Session to be created from an Integration.

Another PR will be created where this is used to allow AWS OIDC to be
used as an AWS Session Provider.

* typo
2024-04-22 09:36:02 +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
Reed Loden 23c67d4c16 Re-enable AWS IMDSv1 fallback (#39363)
It was discovered that some customers' EKS clusters did not have their IMDSv2 hop limits
set correctly, causing requests for key functionality to attempt IMDSv1 fallback and failing.

For now, re-enable IMDSv1 fallback by way of removing the explicit disabling of
`EC2MetadataEnableFallback` until better documentation, error handling, and other work
can be done to inform customers that they need to correctly set their IMDSv2 hop limits.
2024-03-14 18:12:50 +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
Gabriel Corado 0f2641e8d4 Add STS session tags support for DynamoDB access (#35376)
* feat: dynamodb database access configuration for adding sts tags

* refactor: apply code review suggestions

* feat(configurators): add TagSession boundary permission dynamo

* feat(config): session tags omitempty
2023-12-21 20:15:38 +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
Reed Loden b72d4e1032 Disable AWS IMDSv1 fallback and enforce use of FIPS endpoints (#34170)
Two changes to AWS SDK usage:

Teleport should never use AWS IMDSv1 for requests, so disable the
ability to fallback to it, as it could be a malicious attempt to
downgrade security.

Teleport generally prefers FIPS endpoints when in FIPS mode, but
there were a few places that were not selecting the FIPS endpoints.
Ensure that the FIPS endpoints if BoringCrypto is being used.
2023-11-09 21:53:25 +00:00
Marco André Dinis 44209ce8dc DiscoveryMatchers: move checkandset to types package (#32857)
* DiscoveryMatchers: move checkandset to types package

* add opensearch to iamrole as users
2023-10-04 13:48:09 +00:00
STeve (Xin) Huang 76e5747baf Validate unknown AWS regions from discovery matchers (#31533)
* Validate unknown AWS regions from discovery matchers

* move and simply regex check
2023-09-13 15:54:41 +00:00
STeve (Xin) Huang 96a8fbd33d Improve AWS CLI Access performance by caching AWS session credentials (#30922)
* Improve AWS CLI Access performance by caching AWS session credentials

* Signing service to use cachedCredentialsGetter by default
2023-08-24 13:42:45 +00:00
Zac Bergquist 33d0b5f659 upload completer: suppress stack trace for access denied errors (#29023)
If the upload completer fails due to a permissions error, emit a
warning indicating that the upload completer will not function
properly, but suppress the stack trace.

Closes #28999
2023-07-13 18:15:57 +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
Tobiasz Heller c33b6041aa Replace xitongsys/parquet-go with segment-io lib (#28442) 2023-06-29 14:59:04 +00:00
Mike Jensen 3f6e26ae07 Fuzzing test improvements (#28066)
* Remove lib/fuzz

These fuzz targets are already configured elsewhere.  oss-fuzz targets are configured in `fuzz/oss-fuzz-build.sh`

* aws_test.go: Add FuzzParseSigV4

This adds (and enables in oss-fuzz) a new fuzz test case (and seed) for aws.go's ParseSigV4

* api/types/fuzz_test.go: Add fuzzing seeds

* api/utils/aws/fuzz_test.go: Add basic seeds to get broad coverage

* api/utils/azure/fuzz_test.go: Add seeds and enable in oss-fuzz

* lib/utils/parse/fuzz_test.go: Add fuzzing seeds

* Add opensearch fuzzing to oss-fuzz

* lib/srv/db/redis/connection/fuzz_test.go: Add fuzzing seeds

* lib/kube/proxy/fuzz_test.go: Add fuzzing seeds

* lib/srv/regular/fuzz_test.go: Add Fuzzing Seeds

* lib/utils/fuzz_test.go: Add fuzzing seeds
2023-06-20 16:14:15 +00:00
Gabriel Corado a200271ac5 Support authenticating with AWS IAM role for MongoDB Atlas (#26439)
* feat: support authenticating with AWS IAM for MongoDB Atlas

* chore(lint): fix errors

* test(tsh): add missing database field

* refactor(mongodb): check for error on each authenticator branch

* refactor(mongodb): update log messages and atlas check

* refactor(auth): use IsRoleARN helper instead of IsARN

* chore(db): remove unused line

* chore(mongodb): split authenticator func

* refactor(db): rename get atlas token function

* tests(db): reuse already existent auth property

* chore(mongodb): add docs reference

* refactor(db): support role chaining

* feat(types): "require" iam role for atlas users

* refactor(db): use external id only on the first session

* refactor(services): add new database matcher for regular users and aws

* chore(db): rename functions to be more assertive

* chore(types): fix lint

* test(db): remove duplicated test

The test being removed here is covered by `TestMongoDBAtlas`
(lib/srv/db/auth_test.go).
2023-06-06 14:57:27 +00:00
Gavin Frazar 0edc5c819c check for empty name part in role arn (#26315) 2023-05-16 17:04:34 +00:00
Tobiasz Heller e93c6a975c athena audit logs - sqs receive (#24038) 2023-04-25 10:16:15 +00:00
Gavin Frazar 3f0ef9f0ed improve aws utils and database validation (#23157)
* log a warning when an invalid AWS IAM role ARN is filtered out
* add tests for nested role arn path and remove superfluous test parallelism
* add extra godoc info for BuildRoleARN
* improve mock IAM error messages
  - Failing tests' error messages were not specific enough to know what
    happened.
* refactor code to call GetAWS() once
  - Avoids constantly fetching a full copy of the AWS metadata.
  - Reduces verbosity of code.
* reuse MetadataFromRedshiftCluster in meta fetcher
  - Avoids repeating the same logic inside the fetcher.
* improve database-access DynamoDB config checking
  - Don't early return from database CheckAndSetDefaults so AWS account ID
    is checked properly, and any other future checks added will apply to
    DynamoDB as well.
* add aws utils for parsing AWS IAM roles
  - ParseRoleARN will parse an AWS ARN and verify that it is a valid
    AWS IAM Role resource
  - CheckARNPartitionAndAccount is a helper that verifies an ARN partition
    and account ID matches the caller's expectations.
* use cmp.Diff instead of require.Equal in db tests
  - require.Equal spams a lot of protobuf noise.
  - cmp.Diff yields a precise, readable diff on test failure.
2023-03-17 00:45:25 +00:00
STeve (Xin) Huang 704a514742 AWS IAM role matching for database users (#20610)
* Add database user matching logic for databases require AWS IAM role

* Fix UT

* fix lint/typo

* fix typo in error message

* reduce bool return
2023-02-03 18:33:56 +00:00
STeve (Xin) Huang 315f731978 Fix AWS app access for Java SDK v1 (#20142)
* Fix AWS app access for Java SDK v1

* revert --keystore flag
2023-02-02 14:43:51 +00:00
STeve (Xin) Huang 2111f51441 Support assumed roles for "tsh proxy aws" (#20568)
* Support assumed roles for "tsh proxy aws"

* fix typo for RenameHeader

* add error handler

* review comments

* enhance bad parameter

* fix typo

* Forbit requests by assumed role in endpoint url mode.

* fix host check
2023-01-30 21:21:43 +00:00
STeve (Xin) Huang 286b8108b1 AWS Athena ODBC driver support for App Access (#19649) 2023-01-10 18:24:49 +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
Gavin Frazar eccfd9342e Refactor app access (#19387)
* Move logic out of RoundTrip and into ServeHTTP as a middleware before handing off to oxy forwarder
* Move AWS signing service code into lib/utils/aws/signing.go
* use app server close context for audit event emitting
* add go doc comments.
* refactor request rewriting to make the copy in a more robust way.
* pass status code as uint32 rather than casting in audit emitter
* clone request instead of making a new request, and rewrite url to force https
* update header handling
* Set oxy forwarder to PassHostHeader=false to ensure the host header is
  the URL being sought.
* Remove code that deleted forwarding headers previously, we should keep
  those (X-Forwarded-*).
* Audit log the AWS Host sought rather than the incoming request Host
  header (prior behavior maintained, we just rewrite the request
  differently using Clone).
* Remove obsolete header copying helper func
2022-12-23 00:56:27 +00:00
Gavin FrazarandTobiasz Heller d9b80fb2a7 Emit new event for DynamoDB requests via app access (#17595)
* protobuf update

* Update proto to use dynamodb request event specific to app-access

We will include a similar event for dynamodb via database-access.
We split the events so that app and database access events are not coupled.
This way we do not have to include optional database/app metadata in one event too.

* Update protos

* Update oneof

* Move AppMetaData up with the other metadata and add a 'target' field

* Remove operation plane

* Fix typo

* Configure signing service with transport instead of http client

* Protect from resource exhaustion attacks

* Add IsDynamoDB to types.Application

* Add new event and code for dynamodb requests

* Add async emitter to app access

* Add audit.go to unify app access auditing

* Refactor auditing in app access

* Use the new audit's onSessionChunk/onRequest methods
* Put the session context in the session chunk
* Use a TeeStreamer to send AppSessionDynamoDBRequest directly to audit log as well as session file
* Change streamWriter to streamCloser in sessionChunk to clarify that it should only be used for closing

* Update handler test to test dynamodb events

* Update test to use streamCloser

* Update sever test

* Add doc strings

* Return error from audit interface methods so callers can choose what do to with it

* Move app session start/end into audit interface

* Configure tcpServer to use the server's emitter instead of auth
  client, as an Audit interface.
* Have tcpServer call onSessionStart/End instead of emitting events
  itself.

* Remove unneeded check type

* Rename Transport -> RoundTripper

* Fix test after renaming field

* Rename drainBody and defer body closing

* Fix subtle named return mistake

* Update lib/service/service.go

Co-authored-by: Tobiasz Heller <14020794+tobiaszheller@users.noreply.github.com>

* Update lib/service/service.go

Co-authored-by: Tobiasz Heller <14020794+tobiaszheller@users.noreply.github.com>

* Rename ok->shouldSkipCleanup to make the purpose of it more clear

* Refactor request body decoding into aws utils

* Use request instead of signed request for audit event

* Determine if req is for a dynamo endpoint instead of checking app uri

* Remove obsolete app func IsDynamoDB

* Update handler test

* Use generic console app uri to test that we differentiate request by endpoint instead of app uri
* Use a dynamodb request which has a body to test that we include the body in the audit event
* Test for expected body JSON

* fix lint

* Fixup merge

Co-authored-by: Tobiasz Heller <14020794+tobiaszheller@users.noreply.github.com>
2022-11-15 22:58:15 +00:00
STeve (Xin) Huang fac43c5925 Fix an issue tsh aws s3 fails when using path with special characters (#15784) 2022-08-24 18:33:32 +00:00