-
Notifications
You must be signed in to change notification settings - Fork 34
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
External SPA applications allow origin #42
Comments
@t-book I agree .. having static CORS configuration is a limitation which could be improved by using Django based CORS configuration. It seems that the django-cors-header app is exactly for that. Funny enough, that it is a GeoNode dependency already. Perhaps we can remove the CORS configuration from the nginx config. @giohappy what is your take on this? |
Thanks for your reply @ridoo . I was puzzled if I oversee something and guessed for sure others have to deal with cors as well. django-cors-header would be a good option in my opinion. Something like
|
Well, in my opinion CORS should be configured at the application (geoserver is doing it this way too). However, there may have been reasons (did not investigate) to configure CORS for GeoNode at nginx. What I can see: django-cors-headers is already available, so we could just move the CORS config from nginx to a proper application config. Also, in a development setup you usually do not have nginx upfront. |
Good points @ridoo ! |
At the application level, we already have a configuration for it: CORS_ALLOW_ALL_ORIGINS. Of course, it has effects only if the HTTP server in front of the application relays the configuration of the headers to the application. We must also keep into account that certain requests are managed directly by Nginx (for example access to filesystem resources). If a deployment wants to block CORS for these requests it must be done at the Nginx level. I don't think there's a one fits all solution, and as @ridoo says GeoNode could also be employed without Nginx as its frontend server. For the typical deployment with Docker and Nginx, I'm in favor of adding a new variable to the Nginx conf as @t-book suggests. |
@giohappy AFAIK GeoServer CORS config is "Servlet Container only", i.e. there is no application check on GeoServer, right? Setting up CORS for GeoNode and GeoServer, I find it natural to configure it at a similar layer (behind nginx in this case) -- but this might be a personal preference.
Accessing those static resources can be considered to be safe as you'd do not state change on the server, right? If you really want to block access on those, CORS would not be enough as you always could do the request through a proxy. |
@giohappy well, actually I would say configuration at nginx is not necessary :-). CORS config at Django site is already possible and is more flexible even. You'd have to sync CORS config manually or by introducing more and more variables. However, I think that blocking static resources via CORS is not necessary at all (as they still can be accessed) and blowing up config for that reason makes no sense IMO. My current take is to remove the nginx CORS config in favor of configure it via django-cors-header only. |
@ridoo I think we're saying the same thing :) |
Ah .. you're completely right. Sorry for confusing the current status with the proposed one. |
@ridoo Thanks for your reply in the PR. I will continue the discussion here. I'm unsure if adding CORS_ALLOW_METHODS to nginx might in the end in conflict with settings from django … If things get confusing as the same settings can be set in different places. But sure I'm open to change the PR to add those as well. |
@t-book As far I can see, you could just set these in the |
thanks @ridoo in past my tests did not succeed without setting them explicitly in options config of ngix. But I will give it a try again! |
@t-book if it does not work as expected please let me know. Curious about the settings then. |
Hi,
we have some SPA apps that use oauth2 to auth against geonode. In past I've needed to update my local build
geonode-docker/docker/nginx/geonode.conf.envsubst
Lines 93 to 101 in 62a0d29
To not run into a CORS error. I wonder how other devs deal with ACAO. I do not see a way to set Access-Control-Allow-Origin dynamicully but would try to avoid using a forked version of this image.
Thanks,
Toni
The text was updated successfully, but these errors were encountered: