I want to set uid, gid, groups and some id things inside the spawned notebook pod.
that is to say, when user logins into the notebook, he/she can see his name and uid with id
command in terminal.
I have followed the tutorial from @manics , however no one succeed in user switch.
My configuration is listed below, any one could help me? great thanks.
hub:
config:
Authenticator:
enable_auth_state: true
# JupyterHub:
# authenticator_class: ldapauthenticator.LDAPAuthenticator
LDAPAuthenticator:
server_address: ...
bind_dn_template:
- cn={username},...
use_ssl: true
auth_state_attributes: ["uid", "uidNumber", "gidNumber"]
extraConfig:
SpawnerCustomConfig: |
c.Spawner.cmd = ['start.sh','jupyterhub-singleuser','--allow-root']
c.KubeSpawner.args = ['--allow-root']
from ldapauthenticator import LDAPAuthenticator
class LDAPAuthenticatorExt(LDAPAuthenticator):
async def pre_spawn_start(self, user, spawner):
auth_state = await user.get_auth_state()
self.log.debug(f"pre_spawn_start auth_state: {auth_state}")
if not auth_state:
return
# setup environment
spawner.environment["NB_UID"] = str(auth_state["uidNumber"][0])
spawner.environment["NB_GID"] = str(auth_state["gidNumber"][0])
spawner.environment["NB_USER"] = auth_state["uid"][0]
self.log.debug(f"pre_spawn_start spawner.env: {spawner.environment}")
c.JupyterHub.authenticator_class = LDAPAuthenticatorExt
singleuser:
uid: 0
cmd: "start-notebook.sh" #jupyterhub-singleuser
I have checked spawner.environment
is setting to the correct NB_USER
and some other things.
However, inside the notebook, I still can only get uid=1000(jovyan) gid=100(users) groups=100(users)