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

fix(event_handler): disable allow-credentials header when origin allow_origin is * #4638

Merged
merged 9 commits into from
Jul 5, 2024

Conversation

sthulb
Copy link
Contributor

@sthulb sthulb commented Jun 27, 2024

Issue number: #4589

Summary

Ensures CORS behaviour is correct.

Changes

Please provide a summary of what's being changed

Scenario Old Behaviour New Behaviour
Default/Empty CORSConfig Sets Origin header as ACA-Origin regardless Returns *, disables ACA-Credentials
CORSConfig has allowed_origins Sets Origin header as ACA-Origin regardless Returns correct origin for ACA-Origin
CORSConfig is set with domains and * in allowed_origins Sets Origin header as ACA-Origin regardless If no matching Origin is found, it will return * and disables ACA-Credentials

The disabling of Access-Control-Allow-Credentials to prevent server-side credentials being returned to non-named origins.

User experience

Please share what the user experience looks like before and after this change

Checklist

If your change doesn't seem to apply, please leave them unchecked.

Is this a breaking change?

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@sthulb sthulb requested a review from a team as a code owner June 27, 2024 10:31
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 27, 2024
@github-actions github-actions bot added the bug Something isn't working label Jun 27, 2024
@heitorlessa heitorlessa changed the title bug(event_handler): Fix bug with CORS Access-Control-Allow-Origin not returning * fix(event_handler): CORS Access-Control-Allow-Origin not returning * Jun 27, 2024
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 28, 2024
@sthulb sthulb changed the title fix(event_handler): CORS Access-Control-Allow-Origin not returning * fix(event_handler): CORS Behaviour changes Jul 1, 2024
@leandrodamascena
Copy link
Contributor

Starting the review.

Copy link

codecov bot commented Jul 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.42%. Comparing base (46fe028) to head (2756d09).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4638      +/-   ##
===========================================
- Coverage    96.46%   96.42%   -0.04%     
===========================================
  Files          223      223              
  Lines        10735    10744       +9     
  Branches      1998     2001       +3     
===========================================
+ Hits         10355    10360       +5     
- Misses         268      270       +2     
- Partials       112      114       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@leandrodamascena leandrodamascena linked an issue Jul 4, 2024 that may be closed by this pull request
@leandrodamascena leandrodamascena self-requested a review July 4, 2024 09:55
Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

Hi @sthulb! Thanks for working on this.
I'm doing some exploratory tests with different scenarios to see if we're not missing anything. I just left a comment for your review, please see if you agree or not.

aws_lambda_powertools/event_handler/api_gateway.py Outdated Show resolved Hide resolved
Copy link

sonarqubecloud bot commented Jul 5, 2024

@sthulb sthulb requested a review from leandrodamascena July 5, 2024 20:50
Copy link
Contributor

@leandrodamascena leandrodamascena left a comment

Choose a reason for hiding this comment

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

I tested with several scenarios and all the resolvers and everything worked perfectly! Thanks so much for another great work @sthulb!

btw, I don't think we need e2e tests, functional are covering what we need to test.

@leandrodamascena leandrodamascena changed the title fix(event_handler): CORS Behaviour changes fix(event_handler): disable allow-credentials headers when origin is any Jul 5, 2024
@leandrodamascena leandrodamascena changed the title fix(event_handler): disable allow-credentials headers when origin is any fix(event_handler): disable allow-credentials header when origin is any Jul 5, 2024
@leandrodamascena leandrodamascena changed the title fix(event_handler): disable allow-credentials header when origin is any fix(event_handler): disable allow-credentials header when origin allow_origin is * Jul 5, 2024
@leandrodamascena leandrodamascena merged commit 32456d6 into develop Jul 5, 2024
19 of 20 checks passed
@leandrodamascena leandrodamascena deleted the bug-cors branch July 5, 2024 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working event_handlers size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Event handler + cors + headers
2 participants