Skip to content

BinderHub frontend redirects to non existing Jupyter server when a file path is given in the UI and JupyterHub is configured with allowNamedServers #2028

@EmmanuelKasper

Description

@EmmanuelKasper

Bug description

BinderHub frontend does not redirect to correct notebook of Jupyter server when JupyterHub is configured with allowNamedServers.
(https://jupyterhub.readthedocs.io/en/stable/howto/configuration/config-user-env.html#named-servers)

How to reproduce

  1. Install binder via helm chart and set allowNamedServers: true
  2. Open the binderhub start page in the browser
    1. In the GitHub repository name or URL field of bindehub enter binder-examples/requirements
    2. In the File to open (in JupyterLab) field of binderhub enter index.ipynb
  3. Click launch button
    This trigger a build of a container image, a Pod is spawned by the KubernetesSpawner and a browser redirect happens.

Expected behaviour

Ater spawning a running Jupyter server, the browser redirects us to https://mydomain.com/user/emmanuel.kasprzyk/hpc-datalab-dat-okbook-examples-9p5wfum2/lab/tree/index.ipynb

Actual behaviour

The browser redirects us to https://mydomain.com/user/emmanuel.kasprzyk/doc/workspaces/auto-P/tree/index.ipynb

Note that the wrong behaviour only appears when using the field "File to open (in Jupyter)" in the binder landing page.
Without specifying a file to open, the browser correclty redirects to
https://mydomain.com/user/emmanuel.kasprzyk/binder-examples-requirements-ep5m1ljf/lab

Your personal set up

Binder is installed using the binderhub helm chart from https://jupyterhub.github.io/helm-chart
in version 1.0.0-0.dev.git.3673.h040c9bbe.

Configuration

Relevant chart config:

{
  "allowNamedServers": true,
  "namedServerLimitPerUser": 10,
  "extraEnv": {
    "OAUTH_CLIENT_ID": {
      "valueFrom": {
        "secretKeyRef": {
          "name": "hub-oauth",
          "key": "client-id"
        }
      }
    },
    "OAUTH_CLIENT_SECRET": {
      "valueFrom": {
        "secretKeyRef": {
          "name": "hub-oauth",
          "key": "client-secret"
        }
      }
    }
  },
  "extraConfig": {
    "01-oauth-config": "c.GenericOAuthenticator.client_id = os.environ['OAUTH_CLIENT_ID']\nc.GenericOAuthenticator.client_secret = os.environ['OAUTH_CLIENT_SECRET']\n"
  },
  "config": {
    "Spawner": {
      "debug": true
    },
    "BinderSpawner": {
      "auth_enabled": true
    },
    "JupyterHub": {
      "redirect_to_server": true,
      "authenticator_class": "generic-oauth"
    },
    "GenericOAuthenticator": {
      "oauth_callback_url": "https://hub.cookbooks.mydomain.com/hub/oauth_callback",
      "authorize_url": "https://login.mydomain.com/application/o/authorize/",
      "token_url": "https://login.mydomain.com/application/o/token/",
      "userdata_url": "https://login.mydomain.com/application/o/userinfo/",
      "username_claim": "preferred_username",
      "allow_all": true,
      "auto_login_oauth2_authorize": true,
      "auth_state_groups_key": "oauth_user.groups",
      "manage_groups": true,
      "admin_groups": [
        "wheel"
      ]
    }
  },
  "services": {
    "binder": {
      "oauth_client_id": "service-BinderHub",
      "oauth_no_confirm": true,
      "oauth_redirect_uri": "https://binder.cookbooks.mydomain.com/oauth_callback"
    }
  },
  "loadRoles": {
    "user": {
      "scopes": [
        "self",
        "access:services!service=binder"
      ]
    }
  }
}
Logs Relevant logs from the binderhub pod:
D 251007 09:31:40 auth:1344] Allowing Hub user emmanuel.kasprzyk based on oauth scopes {'access:services!service=binder'}
[D 251007 09:31:40 base:74] No build token for gh/binder-examples/requirements/HEAD
[D 251007 09:31:40 repoproviders:1044] Fetching https://api.github.com/repos/binder-examples/requirements/commits/HEAD
[D 251007 09:31:41 repoproviders:1024] GitHub rate limit remaining 59/60. Reset in 0:59:59.
[D 251007 09:31:41 registry:239] Getting registry token from https://registry.mydomain.com/service/token?service=harbor-registry service=container_registry scope=repository:binderhub-staging/mybinder-binder-2dexamples-2drequirements-55ab5c:pull
[D 251007 09:31:41 registry:302] Getting image manifest from https://registry.mydomain.com/v2/binderhub-staging/mybinder-binder-2dexamples-2drequirements-55ab5c/manifests/bfb4f2602a3906795f6b23d6c43e22bf3326ef77
[I 251007 09:31:41 launcher:258] Starting server binder-examples-requirements-qgce3boh for user emmanuel.kasprzyk with image registry.mydomain.com/binderhub-staging/mybinder-binder-2dexamples-2drequirements-55ab5c:bfb4f2602a3906795f6b23d6c43e22bf3326ef77
[D 251007 09:31:41 launcher:312] Requesting progress for emmanuel.kasprzyk: users/emmanuel.kasprzyk/servers/binder-examples-requirements-qgce3boh/progress
[D 251007 09:31:41 auth:782] No user identified
[D 251007 09:31:43 auth:782] No user identified
[D 251007 09:31:43 auth:1308] Redirecting to login url: https://jupyter-binder.staging.jaas.mydomain.com/hub/api/oauth2/authorize?client_id=service-BinderHub&redirect_uri=https%3A%2F%2Fbinder-binder.staging.jaas.mydomain.com%2Foauth_callback&response_type=code
[D 251007 09:31:44 auth:782] No user identified
[D 251007 09:31:45 launcher:356] https://jupyter-binder.staging.jaas.mydomain.com/user/emmanuel.kasprzyk/binder-examples-requirements-qgce3boh
[I 251007 09:31:45 builder:774] Launched https://github.com/binder-examples/requirements in 5s
[D 251007 09:31:46 auth:782] No user identified
[D 251007 09:31:49 auth:782] No user identified
[D 251007 09:31:51 auth:782] No user identified
[D 251007 09:31:53 auth:782] No user identified
[D 251007 09:31:53 auth:1308] Redirecting to login url: https://jupyter-binder.staging.jaas.mydomain.com/hub/api/oauth2/authorize?client_id=service-BinderHub&redirect_uri=https%3A%2F%2Fbinder-binder.staging.jaas.mydomain.com%2Foauth_callback&response_type=code
[D 251007 09:31:54 auth:782] No user identified


Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions