mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Do not special case *any* authenticator
No two ways to set authenticator options - just one way. It's slightly 'ugly' because of the mixing of camel case & snake case, but is worth the massive reductions in complexity!
This commit is contained in:
@@ -101,8 +101,8 @@ def test_auth_dummy():
|
||||
"""
|
||||
c = apply_mock_config({
|
||||
'auth': {
|
||||
'type': 'dummy',
|
||||
'dummy': {
|
||||
'type': 'dummyauthenticator.DummyAuthenticator',
|
||||
'DummyAuthenticator': {
|
||||
'password': 'test'
|
||||
}
|
||||
}
|
||||
@@ -117,8 +117,8 @@ def test_auth_firstuse():
|
||||
"""
|
||||
c = apply_mock_config({
|
||||
'auth': {
|
||||
'type': 'firstuse',
|
||||
'firstuse': {
|
||||
'type': 'firstuseauthenticator.FirstUseAuthenticator',
|
||||
'FirstUseAuthenticator': {
|
||||
'create_users': True
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ def test_auth_firstuse():
|
||||
|
||||
def test_auth_github():
|
||||
"""
|
||||
Test using GitHub authenticator, which is not explicitly special cased.
|
||||
Test using GitHub authenticator
|
||||
"""
|
||||
c = apply_mock_config({
|
||||
'auth': {
|
||||
|
||||
@@ -11,9 +11,8 @@ FIXME: A strong feeling that JSON Schema should be involved somehow.
|
||||
# User provided config is merged into this
|
||||
default = {
|
||||
'auth': {
|
||||
'type': 'firstuse',
|
||||
'dummy': {},
|
||||
'firstuse': {
|
||||
'type': 'firstuseauthenticator.FirstUseAuthenticator',
|
||||
'FirstUseAuthenticator': {
|
||||
'create_users': False
|
||||
}
|
||||
},
|
||||
@@ -64,16 +63,6 @@ def update_auth(c, config):
|
||||
"""
|
||||
auth = config.get('auth')
|
||||
|
||||
# Map value of 'auth.type' in config to a fully qualified name
|
||||
authenticator_class_map = {
|
||||
'dummy': 'dummyauthenticator.DummyAuthenticator',
|
||||
'firstuse': 'firstuseauthenticator.FirstUseAuthenticator'
|
||||
}
|
||||
|
||||
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!
|
||||
|
||||
Reference in New Issue
Block a user