Skip to content

Commit

Permalink
Merge pull request #5225 from minrk/health-manage-groups
Browse files Browse the repository at this point in the history
jupyter-health: enable login via managed groups
  • Loading branch information
minrk authored Dec 4, 2024
2 parents 021da43 + 222c986 commit 5c396da
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions config/clusters/jupyter-health/staging.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jupyterhub:
# requires logging into this hub. But since Jupyter Health team members have access to this
# repo, this is acceptable
authenticator_class: generic-oauth
# set cookie max age to 1
# while we don't have refresh tokens enabled
cookie_max_age_days: 1
GenericOAuthenticator:
client_id: Ima7rx8D6eko0PzlU1jK28WBUT2ZweZj7mqVG2wm
oauth_callback_url: https://staging.jupyter-health.2i2c.cloud/hub/oauth_callback
Expand All @@ -33,16 +36,33 @@ jupyterhub:
admin_users:
- [email protected]
- [email protected]
allowed_users:
# TODO: implement allow based on organization membership,
# so we don't have to add users one at a time
# this is the test user account
- [email protected]
- [email protected]
- [email protected]
manage_groups: true
auth_state_groups_key: "organizations"
allowed_groups:
- "20013" # BIDS (~all users are here)
- "20014" # 2i2c
- "20008" # Yaffe Lab
- "20005" # Moslehi Lab
- "20006" # Olgin Lab
extraConfig:
# add access tokens via auth state
auth_state_env.py: |
# get organization membership for allowed_groups
async def auth_state_hook(authenticator, auth_state):
if not auth_state:
return auth_state
access_token = auth_state["access_token"]
org_url = "https://jhe.fly.dev/api/v1/users/organizations"
organizations = await authenticator.httpfetch(
org_url,
headers={"Authorization": f"Bearer {access_token}"}
)
# use string ids for now
auth_state["organizations"] = [str(org['id']) for org in organizations]
return auth_state
c.OAuthenticator.modify_auth_state_hook = auth_state_hook
def auth_state_env(spawner, auth_state):
if not auth_state:
spawner.log.warning(f"Missing auth state for user {spawner.user.name}")
Expand Down

0 comments on commit 5c396da

Please sign in to comment.