Support arbitrary authenticators

- Removes all need for special casing authenticators.
- Install them in hub environment, directly start using them.
- Consider if we should special case any *at all*
This commit is contained in:
yuvipanda
2018-07-16 12:03:45 -07:00
parent 66de7bb038
commit 2c7f99b57c
2 changed files with 31 additions and 4 deletions

View File

@@ -70,13 +70,22 @@ def update_auth(c, config):
'firstuse': 'firstuseauthenticator.FirstUseAuthenticator'
}
authenticator_classname = authenticator_class_map[auth['type']]
c.JupyterHub.authenticator_class = authenticator_classname
if auth['type'] in authenticator_class_map:
authenticator_class = authenticator_class_map[auth['type']]
authenticator_configname = auth['type']
else:
# FIXME: Make sure this is something importable.
# FIXME: SECURITY: Class must inherit from Authenticator, to prevent us being
# used to set arbitrary properties on arbitrary types of objects!
authenticator_class = auth['type']
# When specifying fully qualified name, use classname as key for config
authenticator_configname = authenticator_class.split('.')[-1]
c.JupyterHub.authenticator_class = authenticator_class
# 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])
authenticator_parent = getattr(c, authenticator_class.split('.')[-1])
for k, v in auth[auth['type']].items():
for k, v in auth.get(authenticator_configname, {}).items():
set_if_not_none(authenticator_parent, k, v)