Skip to content

Instantly share code, notes, and snippets.

@minrk
Created January 19, 2024 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minrk/f0edc56bd55cf5c4706658cc15e0883c to your computer and use it in GitHub Desktop.
Save minrk/f0edc56bd55cf5c4706658cc15e0883c to your computer and use it in GitHub Desktop.
def default_url(handler):
user = handler.current_user
if not user:
# not logged in, send to login, no ?next
# that way, default_url will be called again after successful login
return handler.get_login_url()
if "admin-ui" in handler.expanded_scopes:
# has permission to view the admin page
return handler.base_url + "hub/admin"
else:
# regular user, send to spawn page
# (which redirects to running user if it's running)
# this is the default default URL
return handler.base_url + "hub/spawn"
c.JupyterHub.default_url = default_url
c.Authenticator.allowed_users = {"admin", "testuser"}
c.JupyterHub.load_roles = [
{
"name": "admin-users",
"users": ["admin"],
"scopes": [
"admin-ui",
"admin:users",
"servers",
],
},
]
# example boilerplate
c.JupyterHub.authenticator_class = "dummy"
c.JupyterHub.spawner_class = "simple"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment