feat(sharing): default user-role share scopes and Keycloak group sync - #189
feat(sharing): default user-role share scopes and Keycloak group sync#189tylerpotts wants to merge 2 commits into
Conversation
jhub-apps builds the 'Individuals and group access' dropdown from (other hub users + hub groups) filtered by the requesting user's token scopes. Stock deployments of this chart shipped neither half: JupyterHub's default user role is self-only (so even admins resolve an empty visible-users list), and nothing mirrors Keycloak groups into JupyterHub, so the group list is always empty. Net effect: the sharing feature was dead on every deployment. - hub.loadRoles.user: extend the user role with read:users:name, read:groups:name, shares!user - the scopes jhub-apps' reference jupyterhub_config.py prescribes. Deployers opt out by overriding the role to scopes: [self] (read:users:name implies username enumeration, inherent to sharing by name; documented in the values comment). - hub.config.KeyCloakOAuthenticator.manage_groups: true - standard oauthenticator trait, inert under the dummy authenticator; the pack's KeyCloakOAuthenticator.update_auth_model defers to super() so the groups claim flows through untouched. Fixes #188
install_jhub_apps appends its own 'user' role to load_roles, and z2jh's hub.loadRoles loop runs before config.d - the values route produces two roles named user and JupyterHub aborts startup with 'Role user multiply defined' (caught on a live deployment). Extend the existing role's scopes right after install_jhub_apps instead, the pattern jhub-apps' reference config uses, gated on custom.sharing-scopes-enabled (default true).
|
Heads-up for reviewers: the first commit's The fix now extends the existing role's scopes in place right after |
Fixes #188.
Problem
The jhub-apps "Individuals and group access" dropdown is empty for every user — admins included — on stock deployments of this chart. jhub-apps computes the dropdown as (other hub users + hub groups) filtered by the requesting user's token scopes (
read:users:name!user=X/read:groups:name!group=G); verified on a live deployment by expanding real tokens, even admin's token is self-scoped. And/hub/api/groupsis always[]because nothing syncs Keycloak groups into JupyterHub. Full diagnosis in #188.Change (values-only)
hub.loadRoles.user— extends theuserrole withread:users:name,read:groups:name,shares!user, exactly what jhub-apps' referencejupyterhub_config.pyprescribes for sharing.selfis repeated because naming a role inload_rolesreplaces its default definition. Deployers opt out by overriding the role toscopes: [self]— the values comment documents thatread:users:nameimplies username enumeration, which is inherent to sharing by name.hub.config.KeyCloakOAuthenticator.manage_groups: true— standard oauthenticator trait mirroring each user's Keycloak groups into JupyterHub groups at login. Inert under the default dummy authenticator; the pack'sKeyCloakOAuthenticator.update_auth_modeldefers tosuper()first, so the groups claim flows through untouched. A group becomes a share target once one of its members has logged in.Both are plain z2jh values, so deployer overrides merge naturally — no new toggle machinery.
Verification
helm template+ decoding the rendered hub Secret confirms both settings land in z2jh'svalues.yaml(loadRolesfeeds the chart'shub.loadRolesloop;manage_groupslands underhub.config).helm lintpasses.Note for reviewers
After upgrade, users must log in again once — scopes attach to tokens minted at login, and group membership syncs at login.