-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Adding support for partial wildcards for S3 CORS #10365
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
Adding support for partial wildcards for S3 CORS #10365
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
localstack-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome to LocalStack! Thanks for raising your first Pull Request and landing in your contributions. Our team will reach out with any reviews or feedbacks that we have shortly. We recommend joining our Slack Community and share your PR on the #community channel to share your contributions with us. Please make sure you are following our contributing guidelines and our Code of Conduct.
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
|
Should I merge those latest changes coming from #10366 that fix the build to trigger again all of those pipelines? |
|
@cloutierMat yes, you can try! Very sorry again that those build was red, it was a bit tricky to detect the fork was coming from an outside repo. You can merge/rebase on master and we will see if it works. |
bentsku
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Great change, quick and clean fix, and a nice set of tests validating it. You did a great job picking up the tools, thank you again for this fix!
| if "*" not in rule["AllowedOrigins"] and not any( | ||
| # Escapes any characters that needs escaping and replaces * with .+ | ||
| # Transforms http://*.localhost:1234 to http://.+\\.localhost:1234 | ||
| re.match(re.escape(allowed_origin).replace("\\*", ".+") + "$", origin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice escaping + adding the end of line terminator to avoid having bad origin like you tested! That's a clean fix 👌
| @markers.aws.validated | ||
| @markers.snapshot.skip_snapshot_verify( | ||
| paths=[ | ||
| "$..Body.Error.ResourceType", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see you've uncovered a parity issue we've missed earlier! I can see the reason why this is wrong, we always set it to OBJECT because we never tested it against the bucket only with no object key in the path. Good catch!
We could tackle this small issue in a follow-up PR one day. Great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, I should probably have left a TODO comment at this effect.
|
welcome to the list of contributors @cloutierMat ! |
Motivation
Fixing #10090 . AWS S3 CORS allows for partial wildcard
"http://*.example.com". The current changes will allowOPTIONSrequests to go through instead of returning a 403 errorChanges
*.Testing
As mentioned on the issues description running the following command targeting an S3 bucket. With CORS configured as follow.