dominodeorg / dominode

Development of the Dominica SDI
0 stars 7 forks source link

No need to go through GeoNode OAuth in order to perform GeoServer bootstrapping #73

Closed ricardogsilva closed 4 years ago

ricardogsilva commented 4 years ago

Contrary to what is currently being used for the GeoServer bootstrapping process, it is possible to use the default GeoServer admin user to access the REST API endpoints by leveraging this user's access credentials directly.

This means we do not need to use GeoNode's OAuth authentication mechanism to perform bootstrapping of GeoServer. This makes the overall process simpler and also means we do not need to add any customized OAuth application to the GeoNode docker image.

Example usage, with URLs and creds for local dev:

>>> import httpx
>>> response = httpx.get(
...     'http://localhost/geoserver/rest/geofence/adminrules/', 
...     headers={'Accept': 'application/json'}, 
...     auth=('admin', 'geoserver')
... )
>>> response.status_code
200
>>> response.json()
{'count': 2,
 'rules': [{'id': 4,
   'priority': 0,
   'userName': None,
   'roleName': 'ROLE_LSD-EDITORS',
   'addressRange': None,
   'workspace': 'lsd',
   'access': 'ADMIN'},
  {'id': 3,
   'priority': 1,
   'userName': None,
   'roleName': 'ROLE_PPD-EDITORS',
   'addressRange': None,
   'workspace': 'ppd',
   'access': 'ADMIN'}]}

Related to #55

ricardogsilva commented 4 years ago

@Samweli

Be sure to implement the bootstrapping of GeoServer commands using this authentication approach instead of the one I implemented yesterday, which uses the GeoNode OAuth access tokens

ricardogsilva commented 4 years ago

Closing this, as the current PR #79 is already using it