Add IAM based auth for S3 policy repo - #691
Open
kiesenverseist wants to merge 11 commits into
Open
Conversation
I can't seem to figure out how non-prefixed vars should be read from when using confi.
✅ Deploy Preview for opal-docs canceled.
|
izzywdev
suggested changes
Dec 24, 2024
izzywdev
left a comment
There was a problem hiding this comment.
@kiesenverseist very nice. I would add tests for that either using some mocks, or given credentials it would test agains specified aws account.
| and token is not None | ||
| and self.token_id is not None | ||
| ): | ||
| logger.info("Using provided token to log in to AWS_S3") |
There was a problem hiding this comment.
@kiesenverseist hi, you don't really need elif here, right as there is a return from each case before moving to the next. so you could just have the if's one after the other starting from line 221.
| ): | ||
| logger.info("Using provided token to log in to AWS_S3") | ||
|
|
||
| split_url = urlparse(self.remote_source_url) |
There was a problem hiding this comment.
@kiesenverseist this is duplicate with the code below, I would refactor the section of both cases of S3 to use common code. right?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed
This pull request introduces an additional method for retrieving credentials to access an s3 bucket. When using Amazon's EKS it is possible to create a service account that corresponds to an IAM role. That role ARN and a web identity token file are injected into running pods and can be used with STS to generate temporary credentials.
This PR makes the following changes to accommodate this:
OPAL_prefix, which is why the default for those fields directly reads from the environment. I'm not sure if this is the best way to do this.build_auth_headersfunction. I've added an extra branch where if the ARN and token file are present, it will attempt to use that. I have also made that function async as it now has to read a file, and make requests. I've also added additional logging to indicate which authentication method is being used.get_temporary_sts_credentialsfunction. This handles the reading of the token file, and sending the request to STS. It also parses the response. This makes use of a time based cache decorator so that the temporary credentials are refreshed on a timer.build_aws_rest_auth_headersfunction to include an optional session token. Temporary credentials also include a session token which needs to be included in auth headers when they are used.Check List (Check all the applicable boxes)
Note to reviewers