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

Fixed handling of origin when allow_credentials enabled #985

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TiARETiK
Copy link

@TiARETiK TiARETiK commented Jan 16, 2025

There are to things to start with:

  • OPTIONS requests are not expected to have Origin header.
  • OPTIONS responses are not expected to have an Access-Control-Allow-Credentials headers.
  • No response may have both Access-Control-Allow-Credentials=true and Access-Control-Allow-Origin=*. (source)

Currently, the master brunch's response to OPTIONS request contains an Access-Control-Allow-Origin= , which is interpreted incorrectly by most browsers. We can't fix it by simply checking for the presence of an Origin header in the request, due to the possibility of sending out both Access-Control-Allow-Credentials=true and Access-Control-Allow-Origin=*. The simple yet correct way to fix that behavior is to specifically check that the request being answered is not an OPTIONS one. Such a check is implemented in this pull request. There is also a test added that checks for incorrect Origins-Credentials behavior.

@TiARETiK TiARETiK marked this pull request as draft January 16, 2025 10:33
@TiARETiK TiARETiK force-pushed the origin-handling-fix branch 4 times, most recently from 7d12d5e to f333d40 Compare January 16, 2025 14:01
@TiARETiK TiARETiK force-pushed the origin-handling-fix branch from f333d40 to aa79927 Compare January 16, 2025 14:47
@TiARETiK TiARETiK marked this pull request as ready for review January 16, 2025 14:50
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.

1 participant