Skip to content

Commit

Permalink
Mark claim_groups_key as deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed May 3, 2024
1 parent 7b8c29b commit 6dc6b06
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions oauthenticator/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ def _login_service_default(self):
[Unicode(os.environ.get('OAUTH2_GROUPS_KEY', 'groups')), Callable()],
config=True,
help="""
Userdata groups claim key from returned json for USERDATA_URL.
.. deprecated:: 16.4
Can be a string key name (use periods for nested keys), or a callable
that accepts the returned json (as a dict) and returns the groups list.
This configures how group membership in the upstream provider is determined
for use by `allowed_groups`, `admin_groups`, etc. If `manage_groups` is True,
this will also determine users' _JupyterHub_ group membership.
Use :attr:`auth_state_groups_key` instead.
""",
)

Expand All @@ -46,6 +41,12 @@ def _auth_state_groups_key_default(self):
# propagate any changes to claim_groups_key to auth_state_groups_key
@observe("claim_groups_key")
def _claim_groups_key_changed(self, change):
# Emit a deprecation warning directly, without using _deprecated_oauth_aliases,
# as it is not a direct replacement for this functionality
self.log.warning(
"{cls}.claim_groups_key is deprecated since OAuthenticatort 16.4, use {cls}.auth_state_groups_key instead",
cls=self.__class__.__name__
)
if callable(change.new):
# Automatically wrap the claim_gorups_key call so it gets what it thinks it should get
self.auth_state_groups_key = lambda auth_state: self.claim_groups_key(
Expand Down

0 comments on commit 6dc6b06

Please sign in to comment.