Skip to content

Commit

Permalink
Set defaults correctly for auth_model_groups_key
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvipanda committed May 1, 2024
1 parent 178675f commit 9ac94e9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions oauthenticator/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ def _login_service_default(self):
""",
)

# Initialize value of auth_model_groups_key based on what is in claim_groups_key
@default('auth_model_groups_key')
def _auth_model_groups_key_default(self):
if callable(self.claim_groups_key):
# Automatically wrap the claim_gorups_key call so it gets what it thinks it should get
return lambda auth_model: self.claim_groups_key(
auth_model["auth_state"][self.user_auth_state_key]
)
else:
return f"auth_state.{self.user_auth_state_key}.{self.claim_groups_key}"


# propagate any changes to claim_groups_key to auth_model_groups_key
@observe("claim_groups_key")
def _claim_groups_key_changed(self, change):
if callable(change.new):
Expand Down

0 comments on commit 9ac94e9

Please sign in to comment.