Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

local-binder-local-hub: easier testing of auth and non-standard Docker #1851

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions testing/local-binder-local-hub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ Run JupyterHub in one terminal

BinderHub will be running as a managed JupyterHub service, go to http://localhost:8000
and you should be redirected to BinderHub.

If you want to test BinderHub with dummy authentication:

export AUTHENTICATOR=dummy
jupyterhub --config=jupyterhub_config.py
3 changes: 3 additions & 0 deletions testing/local-binder-local-hub/binderhub_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@
# JUPYTERHUB_BASE_URL may not include the host
# c.BinderHub.hub_url = os.getenv('JUPYTERHUB_BASE_URL')
c.BinderHub.hub_url = os.getenv("JUPYTERHUB_EXTERNAL_URL") or f"http://{hostip}:8000"

if os.getenv("AUTH_ENABLED") == "1":
c.BinderHub.auth_enabled = True
19 changes: 17 additions & 2 deletions testing/local-binder-local-hub/jupyterhub_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,20 @@ class LocalContainerSpawner(BinderSpawnerMixin, DockerSpawner):

c.Application.log_level = "DEBUG"
c.Spawner.debug = True
c.JupyterHub.authenticator_class = "null"
c.JupyterHub.authenticator_class = os.getenv("AUTHENTICATOR", "null")

auth_enabled = c.JupyterHub.authenticator_class != "null"
if auth_enabled:
c.JupyterHub.load_roles = [
{
"name": "user",
"description": "Standard user privileges",
"scopes": [
"self",
"access:services!service=binder",
],
}
]

c.JupyterHub.hub_ip = "0.0.0.0"
c.JupyterHub.hub_connect_ip = hostip
Expand All @@ -39,9 +52,11 @@ class LocalContainerSpawner(BinderSpawnerMixin, DockerSpawner):
binderhub_config = os.path.join(os.path.dirname(__file__), "binderhub_config.py")

binderhub_environment = {}
for env_var in ["JUPYTERHUB_EXTERNAL_URL", "GITHUB_ACCESS_TOKEN"]:
for env_var in ["JUPYTERHUB_EXTERNAL_URL", "GITHUB_ACCESS_TOKEN", "DOCKER_HOST"]:
if os.getenv(env_var) is not None:
binderhub_environment[env_var] = os.getenv(env_var)
if auth_enabled:
binderhub_environment["AUTH_ENABLED"] = "1"
c.JupyterHub.services = [
{
"name": binderhub_service_name,
Expand Down
Loading