diff --git a/tests/test_configurer.py b/tests/test_configurer.py index 5f7ad2b..df4b69f 100644 --- a/tests/test_configurer.py +++ b/tests/test_configurer.py @@ -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': { diff --git a/tljh/configurer.py b/tljh/configurer.py index c4bd2f2..4863204 100644 --- a/tljh/configurer.py +++ b/tljh/configurer.py @@ -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,22 +63,12 @@ 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! - authenticator_class = auth['type'] - # When specifying fully qualified name, use classname as key for config - authenticator_configname = authenticator_class.split('.')[-1] + # 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