Commit Graph
32 Commits
Author SHA1 Message Date
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
STeve (Xin) Huang 2da838fca1 Support AWS external id (#14086) 2022-07-26 14:47:12 +00:00
STeve (Xin) Huang 7a23fe80f9 Implement "tsh proxy aws" (#10025) 2022-06-03 19:14:34 +00:00
Trent Clarke 1cf5a5464a Use buildbox images from quay.io (#10179)
The use of a re-badged buildbox image (rebadging quay.io/gravitational/teleport-buildbox to us-docker.pkg.dev/ci-account/teleport/buildbox-root) is holdover from when CI builds required separate "root user" and "non-root user" images to execute tests under different contexts.

This requirement has since been lifted by using a Go-based build script in CI, and the having to manually invoke a process to re-badge the buildboxes is, tedious, confusing and causing stoppages.

This patch restores the use of buildboxes from quay.io in CI.
2022-02-09 20:56:55 +11:00
Nic Klaassen e00ff42cb8 IAM Join Method (backend implementation) (#10085) 2022-02-08 18:48:13 +00:00