-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
CORS headers duplicated when connecting to standby server in HA mode #3485
Comments
Any chance you can build from the |
Wonderful - I will be able to test in our staging environment tomorrow to tell you for sure. |
we want to replace anything that might be there (e.g. for request forwarding and content-type). Hopefully fixes #3485
Note that I made a minor force push to the branch -- if you have checked it out before right now, please make sure to update. |
It appears the branch fixes our issue, awesome! |
Environment:
Vault Config File:
Startup Log Output:
Expected Behavior:
Making a vault API auth request to
/v1/auth/aws/login
within a browser using CORS with allowed origins set to * and the appropriate content types configured would allow the browser to authenticate.Actual Behavior:
The OPTIONS request is successful but the POST request to
/v1/auth/aws/login
returns duplicate headers from vault.These 3 headers are duplicated
access-control-allow-origin
,cache-control
,vary
.The duplicate
access-control-allow-origin
causes the browser to ignore the success request and give this error.Steps to Reproduce:
I believe this occurs because of the High Availability and request forwarding.
If you connect to a stand-by vault server while using CORS request headers this error occurs.
Whenever someone connects to the active server while using CORS the duplicate headers are not present.
Important Factoids:
You may notice that we connect to staging.vault.domain.com not staging-1a.vault.domain.com. We use a CNAME DNS entry to round robin between the nodes. We are changing our DNS strategy in the mean time to avoid the stand-by server.
Opinion
Forgive me as I am quite unfamiliar with GO and GO libs - but I believe that this line
https://github.com/hashicorp/vault/blob/master/http/handler.go#L87
Where it wraps the response in CORS headers may be the issue when the request was forwarded. I couldn't determine through code inspection alone but it appears as if the headers from the forwarded request would still contain the CORS headers and then the forwarding host will wrap the response with CORS headers again.
If I am correct my opinion is that the CORS headers from the remote host should be used and the forwarding host should not attempt to wrap the response on CORS headers.
The text was updated successfully, but these errors were encountered: