Try generic oauth
This commit is contained in:
parent
275210a3d1
commit
73ec2cc584
2 changed files with 25 additions and 24 deletions
|
@ -7,7 +7,7 @@ spec:
|
||||||
project: default
|
project: default
|
||||||
source:
|
source:
|
||||||
repoURL: https://platform.sunet.se/streams/streams-manifests.git
|
repoURL: https://platform.sunet.se/streams/streams-manifests.git
|
||||||
targetRevision: streams-manifests-2025-02-03-v03
|
targetRevision: streams-manifests-2025-02-03-v05
|
||||||
path: jupyter/overlays/test
|
path: jupyter/overlays/test
|
||||||
destination:
|
destination:
|
||||||
server: https://kubernetes.default.svc
|
server: https://kubernetes.default.svc
|
||||||
|
|
|
@ -13,29 +13,30 @@ hub:
|
||||||
storageClassName: csi-sc-cinderplugin
|
storageClassName: csi-sc-cinderplugin
|
||||||
extraConfig:
|
extraConfig:
|
||||||
oauthCode: |
|
oauthCode: |
|
||||||
|
import os
|
||||||
from oauthenticator.generic import GenericOAuthenticator
|
from oauthenticator.generic import GenericOAuthenticator
|
||||||
|
|
||||||
class KeycloakOAuthenticator(GenericOAuthenticator):
|
keycloak_base = 'https://' + os.environ['OAUTH2_HOST'] + '/realms/' + os.environ['OAUTH2_REALM'] + '/protocol/openid-connect'
|
||||||
def __init__(self, *args, **kwargs):
|
os.environ['OAUTH2_TOKEN_URL'] = keycloak_base + '/token'
|
||||||
super().__init__(*args, **kwargs)
|
os.environ['OAUTH2_AUTHORIZE_URL'] = keycloak_base + '/auth'
|
||||||
self.user_dict = {}
|
|
||||||
|
|
||||||
keycloak_base = 'https://' + os.environ['KEYCLOAK_HOST'] + '/realms/' + os.environ['KEYCLOAK_REALM'] + '/protocol/openid-connect'
|
c.JupyterHub.authenticator_class = 'GenericOAuthenticator'
|
||||||
|
|
||||||
c.JupyterHub.authenticator_class = KeycloakOAuthenticator
|
c.OAuthenticator.client_id = os.environ['OAUTH2_CLIENT_ID']
|
||||||
c.KeycloakOAuthenticator.admin_users = ['kano', 'benedith']
|
c.OAuthenticator.client_secret = os.environ['OAUTH2_CLIENT_SECRET']
|
||||||
c.KeycloakOAuthenticator.allow_all = True
|
|
||||||
c.KeycloakOAuthenticator.authorize_url = keycloak_base + '/auth'
|
c.GenericOAuthenticator.token_url = os.environ['OAUTH2_TOKEN_URL']
|
||||||
c.KeycloakOAuthenticator.client_id = os.environ['KEYCLOAK_CLIENT_ID']
|
c.GenericOAuthenticator.userdata_url = keycloak_base + '/userinfo'
|
||||||
c.KeycloakOAuthenticator.client_secret = os.environ['KEYCLOAK_CLIENT_SECRET']
|
c.GenericOAuthenticator.userdata_method = 'GET'
|
||||||
c.KeycloakOAuthenticator.enable_auth_state = True
|
c.GenericOAuthenticator.userdata_params = {'state': 'state'}
|
||||||
c.KeycloakOAuthenticator.login_service = 'Keycloak'
|
c.GenericOAuthenticator.username_key = 'preferred_username'
|
||||||
c.KeycloakOAuthenticator.oauth_callback_url = 'https://' + os.environ['JUPYTER_HOST'] + '/hub/oauth_callback'
|
c.GenericOAuthenticator.admin_users = ['kano', 'benedith']
|
||||||
c.KeycloakOAuthenticator.refresh_pre_spawn = True
|
c.GenericOAuthenticator.allow_all = True
|
||||||
c.KeycloakOAuthenticator.token_url = keycloak_base + '/token'
|
c.GenericOAuthenticator.authorize_url = os.environ['OAUTH2_AUTHORIZE_URL']
|
||||||
c.KeycloakOAuthenticator.userdata_params = {'state': 'state'}
|
c.GenericOAuthenticator.enable_auth_state = True
|
||||||
c.KeycloakOAuthenticator.userdata_url = keycloak_base + '/userinfo'
|
c.GenericOAuthenticator.login_service = 'Keycloak'
|
||||||
c.KeycloakOAuthenticator.username_key = 'username'
|
c.GenericOAuthenticator.oauth_callback_url = 'https://' + os.environ['JUPYTER_HOST'] + '/hub/oauth_callback'
|
||||||
|
c.GenericOAuthenticator.refresh_pre_spawn = True
|
||||||
extraEnv:
|
extraEnv:
|
||||||
JUPYTER_HOST: jupyter-test.streams.sunet.se
|
JUPYTER_HOST: jupyter-test.streams.sunet.se
|
||||||
JUPYTERHUB_API_KEY:
|
JUPYTERHUB_API_KEY:
|
||||||
|
@ -48,18 +49,18 @@ hub:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: jupyterhub-secrets
|
name: jupyterhub-secrets
|
||||||
key: crypt-key
|
key: crypt-key
|
||||||
KEYCLOAK_CLIENT_ID:
|
OAUTH2_CLIENT_ID:
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: keycloak-oauth-secrets
|
name: keycloak-oauth-secrets
|
||||||
key: client-id
|
key: client-id
|
||||||
KEYCLOAK_CLIENT_SECRET:
|
OAUTH2_CLIENT_SECRET:
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: keycloak-oauth-secrets
|
name: keycloak-oauth-secrets
|
||||||
key: client-secret
|
key: client-secret
|
||||||
KEYCLOAK_HOST: keycloak-test.streams.sunet.se
|
OAUTH2_HOST: keycloak-test.streams.sunet.se
|
||||||
KEYCLOAK_REALM: streams
|
OAUTH2_REALM: streams
|
||||||
singleuser:
|
singleuser:
|
||||||
image:
|
image:
|
||||||
name: quay.io/jupyter/datascience-notebook
|
name: quay.io/jupyter/datascience-notebook
|
||||||
|
|
Loading…
Add table
Reference in a new issue