Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] - Keycloak Group attributes to control JupyterLab profile access #1191

Closed
danlester opened this issue Mar 24, 2022 · 6 comments · Fixed by #1203
Closed

[ENH] - Keycloak Group attributes to control JupyterLab profile access #1191

danlester opened this issue Mar 24, 2022 · 6 comments · Fixed by #1203
Assignees
Labels
type: enhancement 💅🏼 New feature or request

Comments

@danlester
Copy link
Contributor

Feature description

This functionality has been dropped in the recent refactor.

If a Keycloak group had a profile attribute containing a list of JupyterLab profiles then members of that group would be able to access the profiles. This check only came into effect for profiles defined with groups: (which could be empty) in the qhub-config.yaml file. That choice was because profiles defined with no groups: (or users:) would be available to all users - i.e. no access control - so this ability to override dynamically by setting Keycloak group attributes is not wanted for those groups.

I would like to reinstate this functionality. It is possible that some usage of roles in keycloak would be better, but as a short term solution at least, this functionality can be easily reinstated by adding a mapper to the jupyterhub client as follows:

Screenshot 2022-03-24 at 12 33 13

We would also need to reinstate the code that checks for this in jupyterhub_config.py or similar.

I propose we change the attribute name from profiles to jupyterlabprofiles though.

Value and/or benefit

This allows profiles to be assigned to groups dynamically using Keycloak without a full redeploy.

Anything else?

No response

@danlester danlester added the type: enhancement 💅🏼 New feature or request label Mar 24, 2022
@costrouc
Copy link
Member

@danlester I think this is great functionality to have and we could control dask profiles the same way. I was able to get this working as a test but haven't actually implemented it.

Settings some group and user attributes

image

image

image

I've used profiles but I agree we should use a more specific name like jupyterlabprofiles.

Next set a mapper on the jupyterhub oauth client

image

Testing it within keycloak

image

@danlester
Copy link
Contributor Author

Yes, that's the same as the approach I was suggesting. But I think you need to specify lists like this:

profile1##profile2

In my tests, the mapper merged as hoped - just one long list of all profiles (not duplicated).

@costrouc
Copy link
Member

Oh awesome much better didn't know about that option https://stackoverflow.com/questions/61132928/keycloak-user-attributes-with-multiple-values-list

@costrouc
Copy link
Member

costrouc commented Mar 24, 2022

Also longer term I think this is the correct way we should encourage admins to manage profile access. I'd be in favor of dropping users and groups to make the qhub-config.yaml simpler. And not require redeploys for actions like this.

@danlester danlester self-assigned this Mar 25, 2022
@danlester
Copy link
Contributor Author

Actually, the behavior is getting very confusing once we mix all these ways to control permissions. I will add a field called access that can be one of [all (default), keycloak, yaml]

If access: all then every since user has access and groups and users must NOT exist in the profile definition in the yaml file.

If access: keycloak then again groups and users must NOT exist in the profile definition in the yaml file but access will instead be granted to any Keycloak user with jupyterlabprofiles attributes that include that profile name. This means that if no Keycloak attributes are created for any user/group then no-one has access to that profile.

If access: yaml then groups or users are each optional and access is granted to anyone who is a member of a group listed or who is listed in users directly. (Keycloak attributes of jupyterlabprofiles are ignored in this case.) If users and groups are both missing or empty then no-one has access to that profile.

@danlester
Copy link
Contributor Author

keycloak upgrade will have to work its way through this.

Basically if a profile has any groups or users field it should be turned to access: yaml. If it has neither field then it should become access: all.

@danlester danlester mentioned this issue Mar 25, 2022
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement 💅🏼 New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants