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:
Thomas Li Fredriksen
2021-07-23 14:32:44 +02:00
committed by Min RK
parent dcf21d53fd
commit 144abcb965
7 changed files with 88 additions and 0 deletions

View File

@@ -635,6 +635,30 @@ class Authenticator(LoggingConfigurable):
"""
self.allowed_users.discard(user.name)
manage_groups = Bool(
False,
config=True,
help="""Let authenticator manage user groups
Authenticator must implement get_user_groups for this to be useful.
""",
)
def load_user_groups(self, user, auth_state):
"""Hook called allowing authenticator to read user groups
Updates user group memberships
Args:
auth_state (dict): Proprietary dict returned by authenticator
user(User): the User object associated with the auth-state
Returns:
groups (list):
List of user group memberships
"""
return None
auto_login = Bool(
False,
config=True,