jupyterHub /hub/oauth_login 404 not found

Generic OAuthenticator setups for various identity providers but the interface /hub/oauth_login can not found

the part of the jupyterhub_config.py

JUPYTER_HOST = os.getenv("JUPYTER_HOST")
QCCP_HOST = os.getenv("QCCP_HOST")
c.JupyterHub.log_level = "INFO"
c.JupyterHub.base_url = "/jupyter"

class MyOAuthenticator(LocalAuthenticator, GenericOAuthenticator):
    pass

c.JupyterHub.authenticator_class = MyOAuthenticator
c.LocalGenericOAuthenticator.create_system_users = True

c.LocalGenericOAuthenticator.delete_invalid_users = True
# OAuth2 application info
# -----------------------
c.GenericOAuthenticator.client_id = "some-client-id"
c.GenericOAuthenticator.client_secret = "some-often-long-client-secret"

# Identity provider info
# ----------------------
c.GenericOAuthenticator.authorize_url = f"{QCCP_HOST}/qccp-auth/oauth2/authorize"
c.GenericOAuthenticator.token_url = f"{QCCP_HOST}/qccp-auth/oauth2/token"
c.GenericOAuthenticator.userdata_url = f"{QCCP_HOST}/qccp-auth/oauth2/get_user"
c.GenericOAuthenticator.oauth_callback_url =  f"{JUPYTER_HOST}/jupyter/hub/oauth_callback"

c.GenericOAuthenticator.scope = ["openid", "username", "groups"]
c.GenericOAuthenticator.username_claim = "username"

c.GenericOAuthenticator.manage_groups = True
c.GenericOAuthenticator.auth_state_groups_key = "groups"

c.GenericOAuthenticator.admin_users = {"adiminuser"}
c.GenericOAuthenticator.admin_groups = {"administrator"}


c.GenericOAuthenticator.allow_all = True

c.GenericOAuthenticator.allowed_users = set()
c.GenericOAuthenticator.allowed_groups = set()

The error content is as follows:

404 GET /jupyter/hub/oauth_login?next=/jupyter/hub/ (@192.168.1.39) 16.35ms

The Pip environment of hub container:

Package                          Version
-------------------------------- -----------
aiohappyeyeballs                 2.3.2
aiohttp                          3.10.0
aiosignal                        1.3.1
alembic                          1.13.2
async-generator                  1.10
attrs                            23.2.0
bcrypt                           4.2.0
certifi                          2024.7.4
certipy                          0.1.3
cffi                             1.16.0
charset-normalizer               3.3.2
cryptography                     43.0.0
escapism                         1.0.1
frozenlist                       1.4.1
greenlet                         3.0.3
idna                             3.7
Jinja2                           3.1.4
jsonschema                       4.23.0
jsonschema-specifications        2023.12.1
jupyter-telemetry                0.1.0
jupyterhub                       4.1.6
jupyterhub-firstuseauthenticator 1.0.0
jupyterhub-hmacauthenticator     1.0
jupyterhub-idle-culler           1.3.1
jupyterhub-kubespawner           6.2.0
jupyterhub-ldapauthenticator     1.3.2
jupyterhub-ltiauthenticator      1.6.2
jupyterhub-nativeauthenticator   1.2.0
jupyterhub-tmpauthenticator      1.0.0
kubernetes_asyncio               30.1.1
ldap3                            2.9.1
Mako                             1.3.5
MarkupSafe                       2.1.5
multidict                        6.0.5
mwoauth                          0.4.0
nullauthenticator                1.0.0
oauthenticator                   16.3.1
oauthlib                         3.2.2
onetimepass                      1.0.1
packaging                        24.1
pamela                           1.1.0
pip                              24.0
prometheus_client                0.20.0
psycopg2                         2.9.9
py-spy                           0.3.14
pyasn1                           0.6.0
pycparser                        2.22
pycurl                           7.45.3
PyJWT                            2.8.0
PyMySQL                          1.1.1
pyOpenSSL                        24.2.1
python-dateutil                  2.9.0.post0
python-json-logger               2.0.7
python-slugify                   8.0.4
PyYAML                           6.0.1
referencing                      0.35.1
requests                         2.32.3
requests-oauthlib                2.0.0
rpds-py                          0.19.1
ruamel.yaml                      0.18.6
ruamel.yaml.clib                 0.2.8
setuptools                       65.5.1
six                              1.16.0
SQLAlchemy                       2.0.31
sqlalchemy-cockroachdb           2.0.2
statsd                           4.0.1
text-unidecode                   1.3
tornado                          6.4.1
traitlets                        5.14.3
typing_extensions                4.12.2
urllib3                          2.2.2
wheel                            0.43.0
yarl                             1.9.4

we can see the oauthenticator 16.3.1,so Why does this interface ‘/oauth_dagin’ return 404?
Does anyone have any suggestions or modification methods for this issue?Thanks a lot!

Z2JH configures some components outside of the main JupyterHub process, so you should use hub.baseUrl instead of the JupyterHub only configuration

Thank you for your reply and suggestions, but our modifications were still not work.
we delete this configuration

c.JupyterHub.base_url = "/jupyter"

and use helm upgrade again

the config.yaml

# This file can update the JupyterHub Helm chart's default configuration values.
#
# For reference see the configuration reference and default values, but make
# sure to refer to the Helm chart version of interest to you!
#
# Introduction to YAML:     https://www.youtube.com/watch?v=cdLNKUoMc6c
# Chart config reference:   https://zero-to-jupyterhub.readthedocs.io/en/stable/resources/reference.html
# Chart default values:     https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/52b03e2bf123e091eace1ea92dcf2e7b414b38c8/jupyterhub/values.yaml
# Available chart versions: https://hub.jupyter.org/helm-chart/
#
singleuser:
  storage:
    dynamic:
      storageClass: managed-nfs-storage
  defaultUrl: "/lab"
  extraEnv:
    JUPYTERHUB_SINGLEUSER_APP: "jupyter_server.serverapp.ServerApp"
  image:
    # This image is customized by ourselves
    name: tele/notebook
    tag: "1.0"
  cmd: null
  startTimeout: 3600
hub:
  db:
    type: sqlite-memory
  baseUrl: "/jupyter"
  extraEnv:
    JUPYTER_HOST: "http://********"
    QCCP_HOST: "http://*********"

helm commands

helm upgrade --cleanup-on-fail \
  --install jhub jupyterhub/jupyterhub \
  --namespace jhub \
  --create-namespace \
  --version=3.3.8 \
  --values config.yaml

by the way,we find some configurations in our jupyterhub_config.py,These configurations should be written to the configuration file during helm initialization

# c.JupyterHub configuration from Helm chart's configmap
for trait, cfg_key in (
    ("concurrent_spawn_limit", None),
    ("active_server_limit", None),
    ("base_url", None),
    ("allow_named_servers", None),
    ("named_server_limit_per_user", None),
    ("authenticate_prometheus", None),
    ("redirect_to_server", None),
    ("shutdown_on_logout", None),
    ("template_paths", None),
    ("template_vars", None),
):
    if cfg_key is None:
        cfg_key = camelCaseify(trait)
    set_config_if_not_none(c.JupyterHub, trait, "hub." + cfg_key)

Is it its influence that caused us to fail? Or any other questions,We look forward to your reply,Thanks a lot!

Have you modified jupyterhub_config.py directly? That’s not supported.

You should be able to set everything you need using

Which version of Z2JH are you using? Can you try deploying your chart using only the configuration file (please share your latest config file after you update it), turn on debug logging, and show us your logs?

1 Like

it worked!cool!
we use helm → config.yaml → hub.config to configure all the parameters,and upgrade again!the interface /hub/oauth_login Appeared!
The version:

docker:20.10.8
kubectl, kubeadm, kubectl:1.23.6
kubernetes:1.24.1
helm:3.3.8

the config.yaml, Some parameters may need further adjustment.

# This file can update the JupyterHub Helm chart's default configuration values.
#
# For reference see the configuration reference and default values, but make
# sure to refer to the Helm chart version of interest to you!
#
# Introduction to YAML:     https://www.youtube.com/watch?v=cdLNKUoMc6c
# Chart config reference:   https://zero-to-jupyterhub.readthedocs.io/en/stable/resources/reference.html
# Chart default values:     https://github.com/jupyterhub/zero-to-jupyterhub-k8s/blob/e2dfd47e7ebcd52af19d191aec5bd93038bac90a/jupyterhub/values.yaml
# Available chart versions: https://hub.jupyter.org/helm-chart/
#
singleuser:
  storage:
    dynamic:
      storageClass: managed-nfs-storage
  defaultUrl: "/lab"
  extraEnv:
    JUPYTERHUB_SINGLEUSER_APP: "jupyter_server.serverapp.ServerApp"
  image:
    # This image is customized by ourselves
    name: tele/notebook
    tag: "1.0"
  cmd: null
  startTimeout: 3600
hub:
  baseUrl: "/jupyter"
  db:
    type: sqlite-memory
  config:
    JupyterHub:
      authenticator_class: "generic-oauth"
      admin_access: true
    LocalGenericOAuthenticator:
      create_system_users: true
      delete_invalid_users: true
    GenericOAuthenticator:
      client_id: "******"
      client_secret: "******"
      authorize_url: 'http://******/oauth2/authorize'
      token_url: "http://******/oauth2/token"
      userdata_url: "http://******/oauth2/get_user"
      oauth_callback_url: "http://******/jupyter/hub/oauth_callback"
      scope:
        - openid
        - username
        - groups
      username_claim: "username"
      manage_groups: true
      auth_state_groups_key: "groups"
      admin_users:
        - adiminuser
      admin_groups:
        - administrator
      allow_all: true
  extraConfig:
    jupyterhub_config: |
      c.Spawner.args = ['--NotebookApp.allow_origin=*']
debug:
  enabled: true

Thank you very much, it has been a great help!

1 Like