Skip to content

User authentication using OpenID Connect protocol #4474

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

Merged
merged 165 commits into from
Apr 11, 2018

Conversation

VJalili
Copy link
Member

@VJalili VJalili commented Aug 21, 2017

A Galaxy user should be authenticated using a trusted identity provider (e.g., Google, Microsoft, Amazon) when a verifiable identity over a standard protocol is required (e.g., access cloud-based resources such as Amazon S3).

Currently Galaxy can authenticate a user using OpenID (2.0) protocol; however, this protocol is outdated as neither major identity providers nor resource providers support it (e.g., Google suspended OpenID 2.0 support in 2016). A newer authentication protocol is called OpenID Connect which is a thin layer on top of the authorization protocol, OAuth2.0. Our initial plan was to make Galaxy an OpenID Connect-trusted identity provider. However, due to technical issues of being an identity provider, we decided to leverage third-party identity providers. In other words, we decided to act as a OpenID Connect Relying Party.

This PR implements logics of authenticating a Galaxy user leveraging authorization code flow of OpenID Connect protocol.

This implementation persists only the safe-to-store information, which are:

  • refresh token, which is valid/usable by only the Galaxy instance for which the token is issued.
  • temporary access token.
  • temporary identity token.
  • expiration date of identity and access tokens.
  • an anti-forgery ID issued for each authenticated Galaxy user.

To setup Galaxy for using this PR, please consider this documentation, and after you set it up, here is how you can use it.

VJalili added 26 commits August 7, 2017 15:36
Removed white spaces between parenthesis and arguments.
…-after-rebase

# Conflicts:
#	lib/galaxy/config.py
#	lib/galaxy/dependencies/pinned-requirements.txt
#	lib/galaxy/model/__init__.py
#	lib/galaxy/model/mapping.py
@galaxybot galaxybot added this to the 17.09 milestone Aug 22, 2017
@martenson
Copy link
Member

the requirements handling in Galaxy's repo changed, I have a WIP for this branch to fix it but I need to know which of the requirements are used directly in this code:

oauthlib
pyjwkest
PyJWT
python-openid
requests-oauthlib
social_auth_core

@VJalili
Copy link
Member Author

VJalili commented Mar 30, 2018

Yes, these are the requirements for this PR.

@martenson
Copy link
Member

@VJalili That was not my question. I am asking which ones are used directly - as opposed to deps of deps. It seems that answer is only the social_auth_core.

@martenson martenson mentioned this pull request Mar 30, 2018
12 tasks
@VJalili
Copy link
Member Author

VJalili commented Mar 30, 2018

Yes, that is correct, at the moment only social_auth_core, and I might need pyjwkest and PyJWT in future.

model = cls.user_model()
instance = model(*args, **kwargs)
instance.set_password_cleartext(
''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(16)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now have 2 different places in Galaxy code that generate random passwords, slightly differently. Perhaps should unify under single method.

One uses random.sample, this uses random.choice. Using .choice method is arguably better as it allows character reuse. A potential issue with SystemRandom() is 'Not available on all systems.'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed SystemRandom().choice to sample.

def create_user(cls, *args, **kwargs):
model = cls.user_model()
instance = model(*args, **kwargs)
instance.set_password_cleartext(''.join(random.sample(string.ascii_letters + string.digits, 16)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, maybe I wasn't clear. I was saying that using choice was more secure than sample, since it can reuse characters, the search space would be larger. So I was suggesting to use .choice, but to make a single e.g. .set_password_random() method that gets called from each place.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My misunderstanding! I created set_random_password function. I think it would be better if change other random password creations (e.g., this) to leverage this function in subsequent PRs.

@@ -1 +0,0 @@
pipfiles/default/pinned-requirements.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a merge problem.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I reading it correct? it deleted one line and added a new line with the same content as the original line?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure, but it looks a bit strange.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some odd reasons, this is actually replacing a symlink with a text file containing path to the originally linked file. I fixed it; and thanks @natefoo for identifying the issue.

@@ -105,6 +110,7 @@ rfc3986==1.1.0
routes==2.4.1
simplejson==3.13.2
six==1.11.0
social_auth_core==1.5.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new way to add dependencies is to add only the ones you directly use (which I think is just social_auth_core) to lib/galaxy/dependencies/pipfiles/default/Pipfile (without specifying a version unless needed) and run make update-dependencies to update this file (pipenv needs to be installed).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it. Now I'm getting the following error, any thoughts?

Invalid requirement: 'pipfiles/default/pinned-requirements.txt'
It looks like a path. Does it exist ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does that happen?
I'd check that lib/galaxy/dependencies/pinned-requirements.txt is a symlink to pipfiles/default/pinned-requirements.txt . You can recreate it with:

cd lib/galaxy/dependencies/
rm -f pinned-requirements.txt
ln -s pipfiles/default/pinned-requirements.txt

@martenson
Copy link
Member

Thank you for your work @VJalili, I think this PR is in a very good shape.

@martenson martenson merged commit 484f5f6 into galaxyproject:dev Apr 11, 2018
@martenson
Copy link
Member

followup issue xref: #5817

@VJalili
Copy link
Member Author

VJalili commented Apr 11, 2018

@martenson Thanks!

@VJalili VJalili deleted the oauth2-after-rebase branch April 11, 2018 00:17
nsoranzo added a commit to nsoranzo/galaxy that referenced this pull request Sep 19, 2018
nsoranzo added a commit to nsoranzo/galaxy that referenced this pull request Sep 19, 2018
hexylena pushed a commit to usegalaxy-eu/galaxy that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants