ObsPy FDSNWS client and HTTP Basic Authentication

Hi all,

is there a way to use the FDSNWS client to consume fdsnws-dataselect services that are hidden behind HTTP basic authentication? The user and password arguments seem only to work with the Digest Authentication and the /queryauth method as described in the standard. I have a use case in which /queryauth would be overkill, the service should just not be accessible without credentials. No problem to consume this via curl/wget, but it would be nice to be able to use the ObsPy client.

Regards,

Fabian

Hi Fabian,

Out of curiosity can you describe why you believe /queryauth with HTTP Digest Authentication is overkill compared to HTTP Basic Authentication? Most HTTP frameworks, client and server, support both with about the same amount of complexity.

thanks,
Chad

Hi Chad,

(this is getting slightly off-topic on the obspy-users list, sorry for that…)

Out of curiosity can you describe why you believe /queryauth with HTTP

Digest Authentication is overkill compared to HTTP Basic Authentication?

Most HTTP frameworks, client and server, support both with about the same

amount of complexity.

My problem is not with Digest Authentication per se. Configuring /queryauth in the SeisComP3 implementation of fdsnws-dataselect just adds some complexity which I would like to avoid. I don’t need fine-grained access permissions per user, I just need a general “open sesame”.

Cheers,

Fabian

Hi Fabian,

currently not as its not defined in the standard.

But you could subclass the Client and manually add an HTTPBasicAuthHandler, e.g. (untested and Py3 only):

class MyClient(Client):

def init(self, *args, **kwargs):

super().init(*args, **kwargs)

handlers = [] password_mgr = urllib_request.HTTPPasswordMgrWithDefaultRealm() password_mgr.add_password(None, base_url, user, password) handlers.append(urllib_request.HTTPBasicAuthHandler(password_mgr)) # Don’t install globally to not mess with other codes. self._url_opener = urllib_request.build_opener(*handlers)

Cheers!

Lion