generated from geoadmin/template-service-flask
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BGDIINF_SB-2420: Fixed browser origin validation and CORS - #patch
The browser doesn't add the origin header when the request is made from the same origin. However it does always send the 'Sec-Fetch-Site' header telling if the request is from the same origin, cross origin or from user. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Sec-Fetch-Site. Unfortunately this 'Sec-Fetch-Site' header is not supported by Safari ! Moreover we cannot hack the web application to always set the Origin header as most browser don't allow it. So we need to check 2 headers: Sec-Fetch-Site and Origin with a fallback to the Referer for Safari. Although this is usually not an issue for shortlink as it is always used from a different origin, the code has been corrected for completeness and consistency with other services. Also to have the correct CORS header in case of same origin we need to add the correct allowed origin in CORS header which is the same as the request. In case of cross-site then we use the Origin header as allowed origin in CORS. In case where the Origin header is not allowed, we use the request domain as Access-Control-Allow-Origin header. In case of redirect, the `Access-Control-Allow-Origin` header was not set if the origin was not from the allowed origin. Now this header in case of redirect is always set to `*` which tell the client that all origins are allowed for the redirect request.
- Loading branch information
Showing
5 changed files
with
93 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters