mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 06:52:59 +00:00
Added authenticator hook for synchronizing user groups
- Added hook function stub to authenticator base class - Added new config option `manage_groups` to base `Authenticator` class - Call authenticator hook from `refresh_auth`-function in `Base` handler class - Added example
This commit is contained in:

committed by
Min RK

parent
dcf21d53fd
commit
144abcb965
@@ -253,6 +253,19 @@ class User:
|
||||
def spawner_class(self):
|
||||
return self.settings.get('spawner_class', LocalProcessSpawner)
|
||||
|
||||
def sync_groups(self, user_groups):
|
||||
"""Syncronize groups with database"""
|
||||
|
||||
if user_groups:
|
||||
groups = (
|
||||
self.db.query(orm.Group).filter(orm.Group.name.in_(user_groups)).all()
|
||||
)
|
||||
groups = {g.name: g for g in groups}
|
||||
|
||||
self.groups = [groups.get(g, orm.Group(name=g)) for g in user_groups]
|
||||
else:
|
||||
self.groups = []
|
||||
|
||||
async def save_auth_state(self, auth_state):
|
||||
"""Encrypt and store auth_state"""
|
||||
if auth_state is None:
|
||||
|
Reference in New Issue
Block a user