mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Make authenticator class assigning code more generic
This commit is contained in:
@@ -64,12 +64,17 @@ def update_auth(c, config):
|
|||||||
"""
|
"""
|
||||||
auth = config.get('auth')
|
auth = config.get('auth')
|
||||||
|
|
||||||
if auth['type'] == 'dummy':
|
# Map value of 'auth.type' in config to a fully qualified name
|
||||||
c.JupyterHub.authenticator_class = 'dummyauthenticator.DummyAuthenticator'
|
authenticator_class_map = {
|
||||||
authenticator_parent = c.DummyAuthenticator
|
'dummy': 'dummyauthenticator.DummyAuthenticator',
|
||||||
elif auth['type'] == 'firstuse':
|
'firstuse': 'firstuseauthenticator.FirstUseAuthenticator'
|
||||||
c.JupyterHub.authenticator_class = 'firstuseauthenticator.FirstUseAuthenticator'
|
}
|
||||||
authenticator_parent = c.FirstUseAuthenticator
|
|
||||||
|
authenticator_classname = authenticator_class_map[auth['type']]
|
||||||
|
c.JupyterHub.authenticator_class = authenticator_classname
|
||||||
|
# Use just class name when setting config. If authenticator is dummyauthenticator.DummyAuthenticator,
|
||||||
|
# its config will be set under c.DummyAuthenticator
|
||||||
|
authenticator_parent = getattr(c, authenticator_classname.split('.')[-1])
|
||||||
|
|
||||||
for k, v in auth[auth['type']].items():
|
for k, v in auth[auth['type']].items():
|
||||||
set_if_not_none(authenticator_parent, k, v)
|
set_if_not_none(authenticator_parent, k, v)
|
||||||
|
|||||||
Reference in New Issue
Block a user