-
-
Notifications
You must be signed in to change notification settings - Fork 367
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 whitelist #679
Comments
The MDN documentation states
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin This would imply that we should have some way of iterating through that list. I could imagine it being provided in the constructor as a comma separated list, or providing an anonymous method that allows the list to be interrogated when the OnBeforeRouting is being called so the Origin header can be checked and the correct response header added. |
Does overriding OnBeforeAction in the Controller to handle the request meet your requirements? |
I'd need to add it to all of the controllers, so I think a change to the middleware would be a better solution. |
I'd imagine using it like this in the web module
|
Also just reading through the MDN docs, there is a recommendation to omit the Access-Control-Allow-Credentials header if it is not true So either Access-Control-Allow-Credentials: true |
Yes, you are right. |
dfe3943 should implement all the necessary to solve the problem. Let me know. There is also a new example in the folder 'samples\middleware_cors' (launch the project middleware_cors then launch simplewebserver and click the button in the resultant webbrowser). |
Almost, The constructor is missing the assignment of the (split) AllowedOriginalURLs to the private field.
|
In the meantime I did some refactoring and some additions. Can you check if it is OK from your side? |
All good, although remove unused private field on line 70. Thanks |
We have a requirement where we want to have a whitelist of origins that the CORS headers can be accepted.
For example we have three external application providers we work with that have web based applications. These will be something like:
How do we add the CORS middlware to the server with a whitelist of allowed domains, when we have to specify the allowed host in the constructor ?
At the point this code is run (TWebMod.WebModuleCreate) we do not have access to the WebContext to check if the request is coming from one of the allowed domains.
I was thinking we could subclass the CORS middleware and override the OnBeforeRouting method, except it is not declared as virtual.
The text was updated successfully, but these errors were encountered: