Hello @manics,
thanks very much for the changes you made to LDAP Authenticator. They are exactly what I need in my setup to let users access their home folder mounted via NFS.
I am having no luck with setting this up, so maybe you could have some hints.
I am running Jupyterhub 0.9.6 and deploying it with zero-to-jupyterhub-k8s.
Instead of embedding the change in the config file I am installing your fork of LDAP authenticator in the hub container environment. All good until this step.
In my jupyterhub config I embed the following to make sure the uid is propagated to the singleuser container:
class MyLDAPAuthenticator(LDAPAuthenticator):
@gen.coroutine
def pre_spawn_start(self, user, spawner):
auth_state = yield user.get_auth_state()
self.log.error('pre_spawn_start auth_state:%s' % auth_state)
if not auth_state:
return
# setup environment
spawner.environment['NB_UID'] = str(
auth_state['uidNumber'][0])
spawner.environment['NB_USER'] = auth_state['uid'][0]
and this to select the authentication method:
c.JupyterHub.authenticator_class = 'MyLDAPAuthenticator'
c.LDAPAuthenticator.server_address = get_config('auth.ldap.server.address')
c.LDAPAuthenticator.user_info_attributes = ['uid', 'uidNumber']
set_config_if_not_none(c.LDAPAuthenticator, 'server_port', 'auth.ldap.server.port')
set_config_if_not_none(c.LDAPAuthenticator, 'use_ssl', 'auth.ldap.server.ssl')
set_config_if_not_none(c.LDAPAuthenticator, 'allowed_groups', 'auth.ldap.allowed-groups')
c.LDAPAuthenticator.bind_dn_template = get_config('auth.ldap.dn.templates')
set_config_if_not_none(c.LDAPAuthenticator, 'lookup_dn', 'auth.ldap.dn.lookup')
set_config_if_not_none(c.LDAPAuthenticator, 'lookup_dn_search_filter', 'auth.ldap.dn.search.filter')
set_config_if_not_none(c.LDAPAuthenticator, 'lookup_dn_search_user', 'auth.ldap.dn.search.user')
set_config_if_not_none(c.LDAPAuthenticator, 'lookup_dn_search_password', 'auth.ldap.dn.search.password')
set_config_if_not_none(c.LDAPAuthenticator, 'lookup_dn_user_dn_attribute', 'auth.ldap.dn.user.dn-attribute')
set_config_if_not_none(c.LDAPAuthenticator, 'escape_userdn', 'auth.ldap.dn.user.escape')
set_config_if_not_none(c.LDAPAuthenticator, 'valid_username_regex', 'auth.ldap.dn.user.valid-regex')
set_config_if_not_none(c.LDAPAuthenticator, 'user_search_base', 'auth.ldap.dn.user.search-base')
set_config_if_not_none(c.LDAPAuthenticator, 'user_attribute', 'auth.ldap.dn.user.attribute')
However at hub startup I get the following error:
[C 2019-07-30 14:17:00.347 JupyterHub application:90] Bad config encountered during initialization:
[C 2019-07-30 14:17:00.347 JupyterHub application:91] The 'authenticator_class' trait of <jupyterhub.app.JupyterHub object at 0x3fffb082af98> instance must be a type, but 'MyLDAPAuthenticator' could not be imported
Any Idea why this is happening? I really can’t see why the MyLDAPAuthenticator cannot be found at hub instantiation time.
Any help or suggestion is highly appreciated.
Thanks in Advance,
Christian