Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication #58

Open
davidcaron opened this issue Nov 2, 2018 · 5 comments
Open

Authentication #58

davidcaron opened this issue Nov 2, 2018 · 5 comments
Assignees
Labels
enhancement ESGF Earth System Grid Federation
Milestone

Comments

@davidcaron
Copy link
Collaborator

davidcaron commented Nov 2, 2018

Description

Regarding authentication, right now owslib passes username and password directly to the requests library, which uses basic auth.

What would be nice is if owslib could accept an authorization object that was passed directly to requests (see: http://docs.python-requests.org/en/master/user/advanced/#custom-authentication)

I'm opening this issue because I wanted to get your opinion on adding authorization helpers for some providers (that wouldn't mean modifying owslib).

Right now, I would only be interested in Magpie:

def magpie_auth(url, user_name, password):
    response = requests.post(
        url,
        data={
            "user_name": user_name,
            "password": password,
            "provider_name": "ziggurat",
        },
    )
    response.raise_for_status()
    return {"Cookie": "auth_tkt={}".format(response.cookies["auth_tkt"])}

And we could use it like this:

headers = birdy.auth.magpie_auth("your_url", "your_username", "your_password")
import_wps("wps_url", headers=headers)
@huard
Copy link
Contributor

huard commented Nov 2, 2018

Sounds good. How hard would it be to have this work with OAuth2 ? This is what is used by ESGF WPS services ? See https://aims2.llnl.gov/wps/home and https://github.com/ESGF/esgf-compute-api for examples of another user interface to WPS processes.

Note that for scientists, the word "headers" does not carry the same meaning as for a programmer. I would suggest using "auth" instead or something along these lines.

@cehbrecht
Copy link
Member

You can pass headers to OWSLib which are send by requests. See the birdy command line how it is used for tokens and client certificates:

headers = {'Access-Token': ctx.obj['token']}

@davidcaron
Copy link
Collaborator Author

You can pass headers to OWSLib which are send by requests. See the birdy command line how it is used for tokens and client certificates:

headers = {'Access-Token': ctx.obj['token']}

Maybe we could replace these 3 parameters username password and headers with a single one named auth and implement some provider specific classes. So the user would do something like:

auth = birdy.auth.magpie_auth("your_url", "your_username", "your_password")
import_wps("wps_url", auth=auth)

and internally we would set the correct headers and cookies depending on the auth implementation. It's not very far from what requests does: http://docs.python-requests.org/en/master/user/advanced/#custom-authentication

Regarding Oauth2, I've found this: https://github.com/jupyterhub/oauthenticator
I'll try to test it next week.

But basically the user would do something like:

auth = birdy.auth.OAuth2Implementation()  # trigger a login in the default browser?
import_wps("wps_url", auth=auth)

and before each request we would set the Authorization bearer token.

@cehbrecht cehbrecht added this to the 0.5.0 milestone Nov 12, 2018
@huard
Copy link
Contributor

huard commented Nov 30, 2018

@huard
Copy link
Contributor

huard commented Nov 30, 2018

Note that at the moment, if I try to access PAVICS services behind twitcher, I can hit GetCapabilities and DescribeProcess, but for Execute I get an uninformative error message (ie it's not picked up by our try statement in _execute). Once I open a session on the PAVICS frontend and rerun WPSClient, then I can execute requests.

@cehbrecht cehbrecht modified the milestones: 0.5.0, 0.6.0 Dec 3, 2018
@huard huard added the ESGF Earth System Grid Federation label Jan 29, 2019
@cehbrecht cehbrecht modified the milestones: 0.6.0, 0.7.0 Apr 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ESGF Earth System Grid Federation
Projects
None yet
Development

No branches or pull requests

3 participants