-
-
Notifications
You must be signed in to change notification settings - Fork 158
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: CORS: security routes and origin handling #1478
Conversation
Now that the configured origin list check works we have another problem: if you configure any CORS origin and don't explicitly configure the one where Admin UI is being used this will block admin UI save functionalities. How to deal with this? At the moment my idea is to add something to the UI that will include the host where admin UI is being used by default but optionally in the list of allowed CORS origins, like |
Also some font and style requests from the Admin UI get blocked, because they have origin explicitly for some reason. |
This seeems a reasonable approach. |
CORS handling was not working in any of the paths related to authentication, because cors middleware was added after security path handlers were added. This changes the order so that CORS works with these paths also.
CORS origin check was broken in two ways: - the first configured allowed origin was not allowed - any other origin would be allowed access This fixes the check and changes logging denied requests to debug only.
Ignore whitespace and trailing slash.
Add special handling for Admin UI CORS origin and a brief explanation of the mechanism in the security configuration form.
CORS was previously not enabled for any of the security related routes, specifically `/signalk/v1/auth/login. This PR changes the order in server setup so that CORS middleware is activated before security routes. Fixes #1479.
Without any origins configured the server allows CORS requests from any host.
However when configured the origin list was not working correctly:
undefined
that is same hostThis PR fixes the origin checking logic so that it actually works.
In addition this PR adds special handling for the Admin UI origin: the origin that the security configuration form that is used to set CORS origin field to non empty value is automatically added to the list of allowed CORS origins. Otherwise Admin UI itself will stop working, blocked by CORS.
Now the security configuration form also includes a short description of how CORS works.