LDAP login with username#75
Conversation
|
+1 from me,
again, untested, but LGTM. |
There was a problem hiding this comment.
Why is this changing? Also the condition does not correspond with the return message.
Note that TS has 3 and Galaxy 4 char username min length limit.
There was a problem hiding this comment.
see comments in PR, our LDAP allows 3 character usernames (as do many others), and if my memory is correct (we've since changed a few things) REMOTE_USER forced esrinto the database despite Galaxy not explicity permitting it. I don't remember my public-name ending with a -.
There was a problem hiding this comment.
Makes sense. In that case the message should also state 3 though.
There was a problem hiding this comment.
If 3 is ok then doesn't need separate logic for tool shed and I'll tidy that. Was in a rush to push a PR to get some initial comments on direction as have had to switch to a different project for a bit. Will do some tidying at home. Thanks.
There was a problem hiding this comment.
Good point. I would not rush into lowering the requirements of 4 char min as others might chime in with different insights though.
|
Overall this looks like a great start and awesome contribution! Thank you.
I will happily help you with these and others in the start of the next week. |
There was a problem hiding this comment.
This first() is troublesome. I suspect it is a remnant of inconsistent DB on Main back when we did not enforce email to be unique nor valid. Username uniqueness is DB-enforced so it should not change anything but we might want to think about how to do this right. I like using .one() and catching exceptions from sqlalchemy (as in https://github.com/galaxyproject/galaxy/blob/dev/lib/galaxy/managers/libraries.py#L39)
Other ideas?
There was a problem hiding this comment.
I never really think .one() should be used if it's okay a record doesn't exist, and that leads onto valid code. Not a fan of using exceptions for flow-control logic like that.
In this particular case it's perfectly okay for a user record not to exist - as we then go into the auto registration code. Not really an exception, just flow control logic.
What about doing a .count() and throwing an exception if >1 records match, doing the auto reg if 0 etc.. ?
There was a problem hiding this comment.
Regarding one/first, http://alextechrants.blogspot.com/2013/11/10-common-stumbling-blocks-for.html has a decent description of the correct usage. When I asked for a little more info in the sqlalchemy IRC channel, the gist was: one() only when the record should exist barring some error; first() is to be used when the record may or may not exist and either one of those outcomes is ok. Verifying that there aren't multiple user emails (or whatever other field) should be enforced within the DB by unique constraints on the email column, and should not require a separate query each time we want to look something up.
There was a problem hiding this comment.
I guess you can do .all() and check len() in Python to prevent second query.
Assuming 3 character username is okay, update the info and registration forms. NB - username regex in register.mako already allowed 3 char. In info.mako was 4 char.
|
@martenson Assuming 3 character username is okay, updated the info and registration |
|
Changing the minimum to 3 characters seems totally fine to me. Nice work here, @dctrud! |
|
We have some 3 character usernames in usegalaxy.org, so it shouldn't cause an issue. |
|
I have tested login/registration/update basics of this PR and did not find a problem. I tried try to test this with some fake-ldap-provider tool but nothing worked well for me (not fail of this code). Also I do not think you have to solve our This looks ready to me. |
lib/galaxy/auth/providers/ldap_ad.py
Outdated
There was a problem hiding this comment.
LDAPAD is fine for a class/plugin name but I would prefer if it were just LDAP. Can we just make this ldap and the class LDAP?
Then toward the bottom of the file define
class ActiveDirectory(LDAP):
""" Effectively just an alias for LDAP auth, but may contain active directory specific
logic in the future. """
plugin_type = 'activedirectory'
__all__ = ['LDAP', 'ActiveDirectory']
There was a problem hiding this comment.
Sounds reasonable to me. Keep the module as ldap_ad.py to avoid clash with the python-ldap ldap module?
There was a problem hiding this comment.
Sure - sounds like a good plan.
|
+1 |
Suggested and supplied by @jmchilton
|
Removing WIP in hope that this can be merged now if useful. Won't be able to work on other things I mentioned on the trello card for a while. |
|
Thanks for the update, looks good! |
|
I'll add my 👍 to the chorus - thanks @dctrud - this is awesome! |
|
Guess follow up is to ensure Wiki is updated, and reflects these additional changes? Do I need to contribute on that? |
|
I added a checklist for documentation to the trello card. We need to streamline the scattered information into one authentication wiki page/hub. Your contributions are welcomed but not required. |
There was a problem hiding this comment.
Presently the type in this example should be ldap.
|
I just noticed that this broke the I'll try to work on a fix next week. |
… revert changes in auth_conf.xml syntax. After galaxyproject#75 , the <filter> tag of config/auth_conf.xml is broken, see galaxyproject#75 (comment) . I don't think that there is a meaningful way to filter on usernames, so I changed it to filter on email instead of login. Also: - fix AuthManager.check_registration_allowed to use both email and username since which is used for login depends on the AuthProvider used; - move ldap <authenticator> example to config/auth_conf.xml.sample .
… revert changes in auth_conf.xml syntax. After galaxyproject#75 , the <filter> tag of config/auth_conf.xml is broken, see galaxyproject#75 (comment) . I don't think that there is a meaningful way to filter on usernames, so I changed it to filter on email instead of login. Also: - fix AuthManager.check_registration_allowed to use both email and username since which is used for login depends on the AuthProvider used; - move ldap <authenticator> example to config/auth_conf.xml.sample .
… revert changes in auth_conf.xml syntax. After galaxyproject#75 , the <filter> tag of config/auth_conf.xml is broken, see galaxyproject#75 (comment) . I don't think that there is a meaningful way to filter on usernames, so I changed it to filter on email instead of login. Also: - fix AuthManager.check_registration_allowed to use both email and username since which is used for login depends on the AuthProvider used; - move ldap <authenticator> example to config/auth_conf.xml.sample .
Preparation for new Tool class in BioBlend.objects
…ello_sbKLjewQ Ugly hack of track vs same track bug
Fixes for askomics IT
Askomics GxIT: fix crash when no input selected
This is my first attempt at messing up the galaxy auth to do what I want ;-) Looking for any kind of early comments so that I might eventually end up with a reasonable PR that would be useful to others. Am attempting to implement more generic auth support, particularly for use with LDAP. Per discussion on trello card https://trello.com/c/sxz9SM2R
Things I've messed with so far...
activedirectoryauth plugin to a more genericldap_adand add username auth functionality.authenticatemethods now have to return email and username.Am sure there are better ways to do most of these things, and I'll keep trying to find them and tidy up - but it seems to work for our need to auth against our LDAP using usernames.
Config Example
The option login-use-username in auth_conf.xml for the ldap_ad provider will use usernames instead of email for auth. For auto registration, both email and username sources must now be specified. E.g.