Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests - refresh tokens of AWS Clients #1607

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

dlpzx
Copy link
Contributor

@dlpzx dlpzx commented Oct 3, 2024

Feature or Bugfix

  • Feature

Detail

The new integration tests take quite some time (>1h) to get executed. For this reason the AWS clients passed as fixtures to perform different actions (e.g. create S3 Buckets) have expired STS tokens when we reach the teardown operations (e.g. delete S3 Buckets).

This PR implements some logic similar to the one proposed in https://github.com/benkehoe/aws-assume-role-lib which was referenced by the boto3 maintainers in the GitHub issue for this topic.

Relates

Security

Please answer the questions below briefly where applicable, or write N/A. Based on
OWASP 10.

  • Does this PR introduce or modify any input fields or queries - this includes
    fetching data from storage outside the application (e.g. a database, an S3 bucket)?
    • Is the input sanitized?
    • What precautions are you taking before deserializing the data you consume?
    • Is injection prevented by parametrizing queries?
    • Have you ensured no eval or similar functions are used?
  • Does this PR introduce any functionality or component that requires authorization?
    • How have you ensured it respects the existing AuthN/AuthZ mechanisms?
    • Are you logging failed auth attempts?
  • Are you using or adding any cryptographic features?
    • Do you use a standard proven implementations?
    • Are the used keys controlled by the customer? Where are they stored?
  • Are you introducing any new policies/roles/users?
    • Have you used the least-privilege principle? How?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dlpzx dlpzx requested a review from petrkalos October 3, 2024 11:05
@dlpzx dlpzx changed the title STSClient with refreshable token - refactor previous StsClient Integration tests - refresh tokens of AWS Clients Oct 3, 2024
params = {
'RoleArn': self.role_arn,
'RoleSessionName': self.session_name,
'DurationSeconds': SESSION_EXPIRATION_TIME_IN_SECONDS,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this hardcoded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not a parameter we expose, so I left the default value that we currently use

@dlpzx dlpzx self-assigned this Oct 3, 2024
@dlpzx dlpzx marked this pull request as ready for review October 8, 2024 08:32
@dlpzx
Copy link
Contributor Author

dlpzx commented Oct 8, 2024

🧪 Tested in AWS - executed the dataset tests with sleep in-between so that they would take longer than 1h to execute. The client for creation and deletion of S3 Buckets uses the refresh token client and is able to delete the buckets 1h after the client is defined.

@SofiaSazonova SofiaSazonova merged commit 3f97f9a into main Oct 8, 2024
9 checks passed
dlpzx added a commit that referenced this pull request Oct 9, 2024
### Feature or Bugfix
- Bugfix

### Detail
This PR fixes a mismatch between the #1607 and #1603 where
get_environment_aws_session is no longer used. In this PR we obtain the
session from the new STSClient refreshable token functions introduced in
#1607

### Relates
- #1603 
- #1607 

### Security
Please answer the questions below briefly where applicable, or write
`N/A`. Based on
[OWASP 10](https://owasp.org/Top10/en/).

- Does this PR introduce or modify any input fields or queries - this
includes
fetching data from storage outside the application (e.g. a database, an
S3 bucket)?
  - Is the input sanitized?
- What precautions are you taking before deserializing the data you
consume?
  - Is injection prevented by parametrizing queries?
  - Have you ensured no `eval` or similar functions are used?
- Does this PR introduce any functionality or component that requires
authorization?
- How have you ensured it respects the existing AuthN/AuthZ mechanisms?
  - Are you logging failed auth attempts?
- Are you using or adding any cryptographic features?
  - Do you use a standard proven implementations?
  - Are the used keys controlled by the customer? Where are they stored?
- Are you introducing any new policies/roles/users?
  - Have you used the least-privilege principle? How?


By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
@dlpzx dlpzx deleted the fix/integration-tests-sts-token branch October 25, 2024 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants