Skip to content

PLAT-973 + PLAT-974: parameterize Keycloak host, add Python 3.12 IDE variant#54

Open
ttngu207 wants to merge 1 commit into
masterfrom
plat-973-974-djlabhub-hardening
Open

PLAT-973 + PLAT-974: parameterize Keycloak host, add Python 3.12 IDE variant#54
ttngu207 wants to merge 1 commit into
masterfrom
plat-973-974-djlabhub-hardening

Conversation

@ttngu207

@ttngu207 ttngu207 commented May 18, 2026

Copy link
Copy Markdown

Summary

Two djlabhub-docker hardening items for PLAT-590:

  • PLAT-973: the hub image's jupyterhub_config.py hardcoded keycloak-qa.datajoint.io and the localhost OAuth callback. Replaced with required env vars KEYCLOAK_HOST and OAUTH_CALLBACK_URL. The container fails to start if either is unset.
  • PLAT-974: release-image-ide workflow now uses a matrix to build both Python 3.11 and 3.12 IDE images.

Why now

DJ IDE phase-2 production deployment (PLAT-590) needs the hub image to work outside QA. The hardcoded Keycloak host was a blocker for any non-QA deployment of this image. Python 3.12 proves the multi-version build pattern without committing to a full matrix.

Note on PLAT-973 scope

The ticket originally referenced dj-gitops/.../codebook/config/jupyterhub_config.py — that file no longer has the hardcoding (cleaned up by the recent ArgoCD migration; all OAuth URLs now live in env-specific values-{env}.yaml). The remaining hardcoding is in this repo (djlabhub-docker), matching the architecture-doc gap #7 wording. Retargeted accordingly.

Out of scope

  • verify=False on OAuth callback — deferred until a real cert is available.
  • jupyter_codeserver_proxy-1.0b3 beta pin — deferred until upstream GA.
  • Full Python version matrix (3.8–3.10 for IDE) — no demand today.

Test plan

  • Docker build (local): docker build --build-arg JUPYTERHUB_VERSION=4.0.2 -t djlabhub-hub-smoke -f hub/Dockerfile hub/ — succeeded.
  • Config import (happy path): ran the config inside the built image with all four env vars set (OAUTH2_CLIENT_ID, OAUTH2_CLIENT_SECRET, KEYCLOAK_HOST=keycloak.example.com, OAUTH_CALLBACK_URL=https://codebook.example.com/hub/oauth_callback). Verified the constructed URLs:
    • authorize_url = https://keycloak.example.com/realms/datajoint/protocol/openid-connect/auth
    • logout_redirect_url = https://keycloak.example.com/realms/datajoint/protocol/openid-connect/logout
    • oauth_callback_url = https://codebook.example.com/hub/oauth_callback
  • Fail-fast (missing env vars): confirmed that running with KEYCLOAK_HOST unset raises KeyError: 'KEYCLOAK_HOST' at import; running with no env vars at all raises KeyError: 'OAUTH2_CLIENT_ID'. Container would fail to start, as designed.
  • Workflow lint: ran rhysd/actionlint against .github/workflows/singleuser-release.yaml. No new errors. Only diagnostics are pre-existing docker/login-action@v2 "runner too old" warnings on lines 43 and 72 — out of scope for this PR.
  • No naked-python validation — djlabhub-docker has no Python dependency manager (Docker-build-only repo); all validation was via the built hub image.

Deployment

When this image is pulled into a JupyterHub deployment (dj-gitops codebook), the Helm values must set KEYCLOAK_HOST and OAUTH_CALLBACK_URL in hub.extraEnv. Update needed in dj-gitops/applications/k8s/argocd/apps-values/codebook/values-{env}.yaml if/when this image starts being used in a path where these are not already set elsewhere.

… variant

PLAT-973: read KEYCLOAK_HOST and OAUTH_CALLBACK_URL from environment instead
of hardcoding keycloak-qa.datajoint.io and the localhost callback. This makes
the hub image reusable across environments (QA, prod, new-qa).

PLAT-974: add Python 3.12 to the release-image-ide matrix alongside the
existing 3.11 build. Existing-version build path unchanged.

Residual risks (out of scope per PLAT-973):
- verify=False on OAuth callback still in effect (deferred until a real cert)
- jupyter_codeserver_proxy still on 1.0b3 beta pin (deferred until upstream GA)
@ttngu207 ttngu207 force-pushed the plat-973-974-djlabhub-hardening branch from 3d15492 to e058e36 Compare May 19, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant