GeoNode / QGISGeoNodePlugin

A QGIS plugin that provides integration with GeoNode
https://geonode.org/QGISGeoNodePlugin/
GNU General Public License v3.0
12 stars 16 forks source link

Asking credentials during the WFS loading process, for non-authenticated users #295

Closed Gpetrak closed 7 hours ago

Gpetrak commented 5 days ago

When the user tries to load a layer through WFS, the plugin retrieves the SLD from GeoNode in order to display it as in GeoNode. This is a great feature, but when the user is not authenticated (logged in) with the corresponding GeoServer, the plugin asks the user for the GeoServer credentials during the WFS loading process (in order to retrieve the SLD), or it crashes. I think that we have to handle this behavior, either by disabling the WFS button or by loading the layer without the SLD, when the user is not authenticated. The second case needs further investigation because it can break the logic of SLD / layer upload / reload functionalities.

Screenshot from 2024-11-22 15-15-51

giohappy commented 2 days ago

@Gpetrak the REST API is closed to anonymous users. We might decide to change it in the future, and give access to anonymous for the styles (with a security rule like /rest/workspaces/*/styles/*;GET=IS_AUTHENTICATED_ANONYMOUSLY), but for the moment I agree we should use the default style and avoid retrieving the style returned by the API.

I don't see why it should break other functionality, since an anonymous user is not able to modify or upload things.

Gpetrak commented 1 day ago

@giohappy thank you for the information. I followed the second approach and the issue was solved. So now, if the user is not authenticated, the plugin loads the layer through WFS without requesting the SLD from GeoNode. In this case, the widget Layer style and the corresponding buttons in the dialog Layer properties >> GeoNode are disabled. I pushed these changes in the PR #296 because the changes are related with the execution or not of the SLD request.