triauth for JupyterHubOIDC
Let your data team or your students open their notebooks with one approval on their own device, and no JupyterHub passwords.
- Sign-in through
- OpenID Connect bridge
- Available in
- Every JupyterHub, with the OAuthenticator package
- Set up in
jupyterhub_config.py
About JupyterHub
JupyterHub gives a group of people their own Jupyter notebook workspaces on a shared server, so data scientists, students, and researchers run Python or R notebooks in the browser without installing anything. Universities, labs, and data teams use it as a classroom or team computing environment.
Connect JupyterHub to triauth
JupyterHub signs people in through the triauth OpenID Connect bridge, with the OAuthenticator package from the JupyterHub team. Once connected, the hub's login page shows a Login with button carrying your domain's name. People click it, type their username, and approve on their own device. Nobody keeps a JupyterHub password, and when someone leaves, removing their identity records at your domain ends their access to the hub as well.
How it works
On the hub's server, install the package with
pip install oauthenticator.Open oidc.triauth.org and enter your domain. Paste the hub's redirect address,
https://hub.example.com/hub/oauth_callbackwith your own hub's address in place ofhub.example.com, and click Connect app. The bridge gives you a client ID and a client secret.Add the settings below to
jupyterhub_config.pyand restart the hub. Replaceexample.comwith your domain,hub.example.comwith your hub's address, and the two placeholders with the client ID and the client secret from the bridge.pythonc.JupyterHub.authenticator_class = "generic-oauth" c.GenericOAuthenticator.login_service = "example.com" c.GenericOAuthenticator.client_id = "<client ID from the bridge>" c.GenericOAuthenticator.client_secret = "<client secret from the bridge>" c.GenericOAuthenticator.oauth_callback_url = "https://hub.example.com/hub/oauth_callback" c.GenericOAuthenticator.authorize_url = "https://oidc.triauth.org/example.com/authorize" c.GenericOAuthenticator.token_url = "https://oidc.triauth.org/example.com/token" c.GenericOAuthenticator.userdata_url = "https://oidc.triauth.org/example.com/userinfo" c.GenericOAuthenticator.scope = ["openid", "email", "profile", "groups", "offline_access"] c.GenericOAuthenticator.username_claim = "email" c.GenericOAuthenticator.allow_all = TrueOpen the hub's login page and click Login with example.com.
Checkpoint
The hub's login page shows a Login with button with your domain's name. Choosing it opens a page from the bridge that asks for the username, and the person's authenticator asks them to approve.
Good to know
- With
allow_allon, everyone with an identity at your domain gets a workspace the first time they sign in. To let only one team in, limit the app to a group when you connect it, or list the groups published at your domain inallowed_groups. - With
manage_groupson, the hub mirrors those groups and can give admin rights to one of them throughadmin_groups. - A hub that was set up with another sign-in keeps its users when their hub username equals the identifier, which is what
username_claim = "email"gives.
For the person who connects the app
| Setting | Value |
|---|---|
| Redirect address | https://<your-hub>/hub/oauth_callback |
| Where in JupyterHub | jupyterhub_config.py, with the generic-oauth authenticator from OAuthenticator |
| Addresses | the authorization, token, and userinfo addresses go in one by one, as above. The next OAuthenticator release adds an oidc authenticator that reads them from the issuer |
| Groups | manage_groups = True, auth_state_groups_key = "oauth_user.groups", then allowed_groups and admin_groups |
| Sessions | with c.Authenticator.enable_auth_state = True and a JUPYTERHUB_CRYPT_KEY, the hub re-reads the groups at the interval in auth_refresh_age, usually five minutes, and renews the sign-in through the bridge when its token expires. A failed renewal means a new sign-in, so a removed identity is out at the next renewal. Left off, the hub's own cookie decides, usually two weeks |
OAuthenticator keeps the client secret, so leave This app can't keep a secret unticked when you connect it on the bridge. OAuthenticator's generic provider guide and its reference explain every setting.
Next steps
- Read the OpenID Connect bridge page for what every connected app gets and what the bridge keeps private.
- Read Roll out to your team to give everyone in your organization an identifier at your domain.
- Read Groups to publish teams and let the hub mirror them.
- Read OAuthenticator's generic provider guide for every setting it offers.
All logos and trademarks belong to their respective owners and do not imply affiliation or endorsement of the organization or product by triauth, nor vice versa. The content provided on this page may include information from third-party sources. We do not assume any responsibility for the completeness, correctness, or applicability of the information. You should independently verify any details before relying on them.