-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[All] add OAuthenticator.modify_auth_state_hook, allow get_user_groups / auth_state_groups_key to be async #751
Conversation
ya, how about an |
It can take the authenticator instance and existing auth_state as params, and return the augmented auth_state |
for populating additional fields in auth_state
add versionchanged notes
Added I left the async allowance in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good, one specific question about exception handling mechanism.
I don't see your question, did I miss something? |
oauthenticator/oauth2.py
Outdated
self.log.error(f"Error in modify_auth_state_hook: {e}") | ||
raise | ||
if isawaitable(auth_state): | ||
auth_state = await auth_state |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the exception be thrown here on the await
than earlier? Wouldn't that require us to be inside the try
? I could be wrong...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're 100% right, yes! Fixed.
oops, something ate it! I've asked again. |
Thanks, @minrk |
closes #750
it feels a little weird to have
auth_state_groups_key
be a callable that actually fetches external info purely based on the config name, but it's what we have. Is there a better arrangement for adding more fields to the user model? e.g. something aftertoken_to_user
? I noted in #750 that extending token_to_user would work. Should we have a hook after token_to_user to allow additional modifications to the user model before things like groups get added, or is making this method/hook async enough?