Skip to content

Commit

Permalink
Issue #9 - Fix auth header setting for WMS Probes (#276)
Browse files Browse the repository at this point in the history
* update all translation files plus doc HOWTO translations

* #268 drop de_DE translations ('de' only now)

* #9 add auth headers for WMS OWSLib calls
  • Loading branch information
justb4 committed Sep 12, 2019
1 parent fff4f8d commit 7108870
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions GeoHealthCheck/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ def get_probe_edit_form(probe_class, resource_identifier=None):
if resource_identifier:
resource = views.get_resource_by_id(resource_identifier)
if resource:
probe_obj._resource = resource
probe_obj.expand_params(resource)

probe_info = probe_obj.get_plugin_vars()
Expand Down
3 changes: 2 additions & 1 deletion GeoHealthCheck/plugins/probe/wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ def get_metadata(self, resource, version='1.1.1'):
:param version:
:return: Metadata object
"""
return WebMapService(resource.url, version=version)
return WebMapService(resource.url, version=version,
headers=self.get_request_headers())

# Overridden: expand param-ranges from WMS metadata
def expand_params(self, resource):
Expand Down
3 changes: 3 additions & 0 deletions GeoHealthCheck/probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class Probe(Plugin):

def __init__(self):
Plugin.__init__(self)
self._resource = None

#
# Lifecycle : optionally expand params from Resource metadata
Expand Down Expand Up @@ -228,6 +229,8 @@ def after_request(self):
pass

def get_request_headers(self):
if not self._resource:
return dict()
return self._resource.add_auth_header(self.REQUEST_HEADERS)

def perform_request(self):
Expand Down
3 changes: 2 additions & 1 deletion GeoHealthCheck/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,11 @@ def get_probes_avail(resource_type=None, resource=None):
if probe:
if resource:
try:
probe._resource = resource
probe.expand_params(resource)
except Exception as err:
msg = 'Cannot expand plugin vars for %s err=%s' \
% (probe_class, str(err))
% (probe_class, repr(err))
LOGGER.warning(msg)

result[probe_class] = probe.get_plugin_vars()
Expand Down

0 comments on commit 7108870

Please sign in to comment.