GeoNode / QGISGeoNodePlugin

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

Loading of dataset fails if domain contains geoserver #259

Open t-book opened 1 year ago

t-book commented 1 year ago

Hi.

in case the domain includes geoserver like https://geoserver.example.org and a User is using basic auth the loading fails with:

2023-03-22 01 37 26 PM

Unable to load layer RC_Samshvilde_2022_09_14_I_PL_9_Ortho_0_001_COG: Datenanbieter ist ungültig (Anbieter wms, URI: crs=EPSG:4326&url=https://geoserver.example.org/gs.example.org/geoserver/ows&format=image/png&layers=geonode:RC_Samshvilde_2022_09_14_I_PL_9_Ortho_0_001_COG&styles=&version=auto&authcfg=h9fd8v1

@giohappy @ricardogsilva I would suggest this change to make the code more independent:

diff --git a/src/qgis_geonode/apiclient/geonode_v3.py b/src/qgis_geonode/apiclient/geonode_v3.py
index 0acc7b7..f889d8a 100644
--- a/src/qgis_geonode/apiclient/geonode_v3.py
+++ b/src/qgis_geonode/apiclient/geonode_v3.py
@@ -358,8 +358,8 @@ class GeonodeApiClientVersion_3_4_0(GeonodeApiClientVersion_3_x):
         if auth_provider_name == "basic":
             for service_type, retrieved_url in result.items():
                 try:
-                    prefix, suffix = retrieved_url.partition("geoserver")[::2]
-                    result[service_type] = f"{self.base_url}/gs{suffix}"
+                    prefix, suffix = retrieved_url.partition("/geoserver/")[::2]
+                    result[service_type] = f"{self.base_url}/gs/{suffix}"
                     log(f"result[service_type]: {self.base_url}/gs{suffix}")
                 except AttributeError:
                     pass

what do you think?

Best,

Toni

giohappy commented 1 year ago

Nice catch @t-book.

Actually we should configure Geoserver for GeoNode with Basic auth backed by authentication service. It's been implemented but it wasn't ported as a standard configuration.

By the way, yes, for the moment your fix should work.

t-book commented 1 year ago

Ok, great @giohappy thanks for your quick reply. I will prepare a PR.