jupyterhub / ldapauthenticator

LDAP Authenticator Plugin for Jupyter
BSD 3-Clause "New" or "Revised" License
206 stars 178 forks source link

Fix duplicated bind operation, only one is needed #270

Closed consideRatio closed 2 months ago

consideRatio commented 2 months ago

To bind is to authenticate as a user against the user, where the user is specified by a DN (Distinguished Name). This operation can prompt inputting one time passwords on a mobile device etc, so its relevant to not do twice in a row.

When we create the connection object, we automatically bind as part of doing so in all cases. Due to that, its not relevant to first acquire the connection and then do conn.bind().

In this PR you'll see how I move logic to get_connection and letting it handle raised errors failing on failing to bind by emitting a warning and returning None. Using get_connection can then be reduced to calling it and checking the return value. Any connectivity or encryption issues will still be raised and not handled by get_connection.

minrk commented 2 months ago

Thanks! Go ahead and merge