jupyterhub / oauthenticator

OAuth + JupyterHub Authenticator = OAuthenticator
https://oauthenticator.readthedocs.io
BSD 3-Clause "New" or "Revised" License
414 stars 366 forks source link

[All] add OAuthenticator.modify_auth_state_hook, allow get_user_groups / auth_state_groups_key to be async #751

Closed minrk closed 2 months ago

minrk commented 3 months ago

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 after token_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?

yuvipanda commented 3 months ago

ya, how about an augment_auth_state_hook that gets called after authenticate, and can put random stuff in auth_state? Then we can leave the existing group management stuff as is, and replace all the 'override authenticator, override authenticate just to put stuff in auth_state' with that one hook.

yuvipanda commented 3 months ago

It can take the authenticator instance and existing auth_state as params, and return the augmented auth_state

minrk commented 2 months ago

Added modify_auth_state_hook config, run after build_auth_state but before update_auth_model, so it can modify the inputs to get_user_groups.

I left the async allowance in get_user_groups, since I think that makes sense generally, but now 'the way to do this' would be to use the hook (user) / build_auth_state (subclass).

minrk commented 2 months ago

I don't see your question, did I miss something?

yuvipanda commented 2 months ago

oops, something ate it! I've asked again.

yuvipanda commented 2 months ago

Thanks, @minrk