diff --git a/testing/local-binder-local-hub/README.md b/testing/local-binder-local-hub/README.md index 03762d7e8..0ac496895 100644 --- a/testing/local-binder-local-hub/README.md +++ b/testing/local-binder-local-hub/README.md @@ -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 diff --git a/testing/local-binder-local-hub/binderhub_config.py b/testing/local-binder-local-hub/binderhub_config.py index a2fe71bae..99efd1ee4 100644 --- a/testing/local-binder-local-hub/binderhub_config.py +++ b/testing/local-binder-local-hub/binderhub_config.py @@ -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 diff --git a/testing/local-binder-local-hub/jupyterhub_config.py b/testing/local-binder-local-hub/jupyterhub_config.py index 695b0cb40..02fd3f0d6 100644 --- a/testing/local-binder-local-hub/jupyterhub_config.py +++ b/testing/local-binder-local-hub/jupyterhub_config.py @@ -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 @@ -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,