Closed minrk closed 2 months ago
One test that's still failing is the
search_filter
test. This test passes if I setallow_all = True
, but it's unclear to me ifsearch_filter
should be considered allow config or not.
search_filter
is discussed in #265, I think it belongs to check_blocked, but this PR is an incremental improvement making allowed_user
function as it should alongside allowed_groups
which is great.
breaking change that's technically avoidable: I moved the
user_attr
down a level so it is its own dict in auth_state, so it'sauth_state["user_attrs"]
. I could just as easily addldap_groups
within that dict, but it seems that the attributes dict has a specific meaning, so I thought it better to move it so it doesn't get any extra keys.
:+1:, this seems cleaner and better long term for everyone.
The search_filter docstring:
LDAP3 Search Filter whose results are allowed access
suggests that this is explicit allow config, so should result in passing check_allowed
. Right now, the behavior if both search_filter
and allowed_groups
are configured, access is permitted if both conditions are met. Typically, allow config is considered additive, but given how this works, search_filter
is exclusive. So the choice is:
allowed_groups
strictly narrows allowed users from search_filter
search_filter
works (no user info is retrieved if search filter is not matched). So the situation of matching allowed_groups
but not search_filter
is unreachable.allowed_groups
has no effect. Could error on ignored config)
- keep current behavior:
allowed_groups
strictly narrows allowed users fromsearch_filter
I frame the current behavior as: search_filter
strictly narrows what users are allowed when lookup_dn
is specified, no matter if they are allowed via allowed_users
, admin_users
, or allowed_groups
.
OK, then shall I remove the interpretation of search_filter as allow config at all? That seems to make the most sense, based on what you've said.
I agree. Intuitively search_filter
provides a subset of users that the rest of our allowed/blocked config modifies. I don't think filtering strictly translates into our existing terminology.
Can we also update the documentation/readme for auth_state_attributes
, since the breaking change here means the attributes are moved under user_attrs
. If it's helpful here's an example of how it can be used:
https://github.com/manics/zero-to-jupyterhub-k8s-examples/blob/b460cb8958bc43a68e20f225f338a59f0bc7b5a6/ldap-singleuser/jupyterhub.yml#L37
I think filtering maps reasonably onto "block unless" in our terminology, but we could perhaps have a better way to say that
ok, tests are now passing with updated descriptions. I needed to add a bit of logic to handle the default behavior for check_allowed()
changing from jupyterhub 4 to 5, so the default behavior is consistent with jupyterhub itself in both versions.
We also have a choice on how allow_all
should behave on JupyterHub 4. We can:
allow_all
in this package (as is done in OAuthenticator) so LDAPAuthenticator behaves consistently, regardless of JupyterHub versionAny preference? I can't really decide which one is more likely to be surprising. 2 is a bigger, more breaking change, but it breaks in the safer, less permissive direction. 1. keeps current default behavior, consistent with JupyterHub itself.
We are currently having option 1, right? I think that is sufficient and allows us to move onwards.
@minrk a third approach is to remove support for JupyterHub 4 in this authenticator, which would be fine in my mind.
In order of preference, I think 3 > 1 > 2, but we could go with anything.
Yes, this PR implements option 1 at the moment.
It seems quite early to drop support for JupyterHub 4, which was the latest version just a few months ago.
From mobile on a walk with a stroller, i figure we should merge now but a final review detail: is title/description still updated to reflect the PR?
updated title
Wieee!!
avoids relying on allow_all in jupyterhub 5.
The group is populated in
authenticate
and checked incheck_allowed
breaking change that's technically avoidable: I moved the
user_attr
down a level so it is its own dict in auth_state, so it'sauth_state["user_attrs"]
. I could just as easily addldap_groups
within that dict, but it seems that the attributes dict has a specific meaning, so I thought it better to move it so it doesn't get any extra keys.One test that's still failing is the
search_filter
test. This test passes if I setallow_all = True
, but it's unclear to me ifsearch_filter
should be considered allow config or not.closes #246
EDIT:
auth_state
is no longer the location for user attributes, they are put inauth_state["user_attributes"]