Skip to content

triauth for JupyterHubOIDC

Let your data team or your students open their notebooks with one approval on their own device, and no JupyterHub passwords.

  • Data science and education
  • Open source
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

  1. On the hub's server, install the package with pip install oauthenticator.

  2. Open oidc.triauth.org and enter your domain. Paste the hub's redirect address, https://hub.example.com/hub/oauth_callback with your own hub's address in place of hub.example.com, and click Connect app. The bridge gives you a client ID and a client secret.

  3. Add the settings below to jupyterhub_config.py and restart the hub. Replace example.com with your domain, hub.example.com with your hub's address, and the two placeholders with the client ID and the client secret from the bridge.

    python
    c.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 = True
  4. Open 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_all on, 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 in allowed_groups.
  • With manage_groups on, the hub mirrors those groups and can give admin rights to one of them through admin_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

SettingValue
Redirect addresshttps://<your-hub>/hub/oauth_callback
Where in JupyterHubjupyterhub_config.py, with the generic-oauth authenticator from OAuthenticator
Addressesthe 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
Groupsmanage_groups = True, auth_state_groups_key = "oauth_user.groups", then allowed_groups and admin_groups
Sessionswith 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

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.