We have managed to setup our jupyterhub environment (z2jh) to use Keycloak as an authentication server and users are given a enter password screen when they try and access the jupyterhub website. The configuration used for this is below.
The question we have is how do we auto sign in users to the jupyterhub server from another website. We are not using keycloak to authenticate on the other website. So the login process we assume would be along the following lines
- User logs into primary website (no keycloak)
- The user goes to a webpage where we should a link to the jupyterhub notebook
- We generate a JWT token using a post request to keycloak server.
- We somehow use the token to sign the user into the jupyterhub server.
We have managed to successfully create a web token using postman to make a post request using the client_id, secret, username and password.
Our question is how do we use this token to log the user in?
We can see during the manual login process the call back but we are unsure how to we generate the 'state'. We assume something has been set in the my-jhub cookie but any feedback or links to guide us would be much appreciated.
auth:
type: custom
className: oauthenticator.generic.GenericOAuthenticator
config:
login_service: 'keycloak'
client_id: 'kubernetes-cluster-dev'
client_secret: 'yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy'
token_url: https://keycloak.xxx.net/auth/realms/test_realm/protocol/openid-connect/token
userdata_url: https://keycloak.xxx.net/auth/realms/test_realm/protocol/openid-connect/userinfo
userdata_method: GET
userdata_params: {‘state’: ‘state’}
username_key: preferred_username
hub
extraEnv:
OAUTH2_AUTHORIZE_URL: https://keycloak.xxx.net/auth/realms/test_realm/protocol/openid-connect/auth
OAUTH2_TOKEN_URL: https://keycloak.xxx.net/auth/realms/test_realm/protocol/openid-connect/token
OAUTH_CALLBACK_URL: http://my-jhub.xxx.net/hub/oauth_callback