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

update: adding session tokens for temporary credentials for AWS S3 #6

Merged
merged 7 commits into from
May 9, 2022

Conversation

shinitiandrei
Copy link
Contributor

@shinitiandrei shinitiandrei commented May 5, 2022

Hi there,
Sorry for opening a PR like this, but it would be nice to get a review on this :).
A bit of a background: my current scenario doesn't allow me to use user keys in AWS. We are using AWS roles (OIDC) and without the session token the authentication doesn't work, so I added it to this PR.
I've built a new image, and it's working like a charm.

Adding Session tokens when using temporary credentials in AWS. README updated and minio/mc image was updated to latest.

@shinitiandrei shinitiandrei changed the title update: adding session tokens for temporary credentials in amazon update: adding session tokens for temporary credentials for AWS S3 May 5, 2022
@shinitiandrei
Copy link
Contributor Author

image

Copy link
Owner

@peter-evans peter-evans left a comment

Choose a reason for hiding this comment

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

Hi @shinitiandrei

Thank you for contributing! 🏅

Left some comments but overall I'm happy to include this functionality.

entrypoint.sh Outdated
Comment on lines 17 to 18
# Execute mc mirror
mc mirror $* "$MIRROR_SOURCE" "$STORAGE_SERVICE_ALIAS/$MIRROR_TARGET"
Copy link
Owner

Choose a reason for hiding this comment

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

These two lines are duplicated in both paths of the if block. I think you can just extract this out after the if block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure I'll remove the duplicate
I did this in a bit of a rush and that's why I opened the PR to check on my code.

entrypoint.sh Outdated
# Execute mc mirror
mc mirror $* "$MIRROR_SOURCE" "$STORAGE_SERVICE_ALIAS/$MIRROR_TARGET"
else
export MC_HOST_${STORAGE_SERVICE_ALIAS}=https://${ACCESS_KEY_ID}:${SECRET_ACCESS_KEY}:${SESSION_TOKEN}@s3.${REGION}.amazonaws.com
Copy link
Owner

Choose a reason for hiding this comment

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

This hard codes the SESSION_TOKEN functionality to AWS S3 only. It looks like MinIO server also supports session tokens. Ideally it would be nice to support any S3 compatible backend.

I think there are two options here:

  1. Support any S3 backend that has session token functionality.
  2. Only support AWS S3 and make that clear in the action interface.

For option 1, we should use STORAGE_SERVICE_URL instead of hard coding to @s3.${REGION}.amazonaws.com. i.e. Parse the URL and split at https://. Add the key, secret, session and @ symbol.

For option 2, I think we should change the name of SESSION_TOKEN and REGION to AWS_SESSION_TOKEN and AWS_REGION to make it clear they only work for AWS S3.

I'm happy with either option. We can always improve it to cover option 1 in the future if you don't want to try and make it work now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy with option 2 for now, at least we make it visible that it's AWS exclusive.
Option 1 would require a little bit more code and testing, but happy to do it when I get a bit more time.

@shinitiandrei
Copy link
Contributor Author

shinitiandrei commented May 6, 2022

Changes pushed, please let me know what you think. Thank you for the review! :D

@peter-evans peter-evans merged commit 4f39c7d into peter-evans:master May 9, 2022
@peter-evans
Copy link
Owner

peter-evans commented May 9, 2022

Released as v1.1.0 / v1.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants