Skip to content

feat(config): add hub.allowedOrigins and notebook.allowedOrigins for origin policy#47

Merged
KerwinTsaiii merged 2 commits intodevelopfrom
feat/allowed-origins-config
Mar 25, 2026
Merged

feat(config): add hub.allowedOrigins and notebook.allowedOrigins for origin policy#47
KerwinTsaiii merged 2 commits intodevelopfrom
feat/allowed-origins-config

Conversation

@MioYuuIH
Copy link
Copy Markdown
Contributor

@MioYuuIH MioYuuIH commented Mar 25, 2026

Summary

Add native YAML configuration for controlling allowed origins on Hub and notebook servers separately, replacing the need for raw Python in hub.extraConfig.

  • custom.hub.allowedOrigins: sets Access-Control-Allow-Origin on Hub HTTP responses via JupyterHub.tornado_settings
  • custom.notebook.allowedOrigins: injected into each notebook server's startup args via --ServerApp.allow_origin_pat, for kernel WebSocket connections behind a reverse proxy
  • Named notebook (not singleuser) to avoid confusion with the z2jh top-level singleuser section
  • Schema updated in values.schema.yaml and regenerated values.schema.json

Usage

custom:
  # Hub HTTP responses (e.g. API accessed cross-origin)
  hub:
    allowedOrigins: ["https://mylab.example.com"]

  # Notebook server kernel WebSocket (e.g. behind Cloudflare or campus proxy)
  notebook:
    allowedOrigins: ["*"]

Test plan

  • helm upgrade --dry-run passes with no errors or warnings
  • Deploy with notebook.allowedOrigins: ["*"] and verify kernel WebSocket works through reverse proxy
  • Deploy with hub.allowedOrigins: ["*"] and verify Access-Control-Allow-Origin header appears on Hub responses
  • Deploy with empty lists (default) and verify no args injected, no headers added

…ocket origins

Add a native YAML-based configuration field `custom.allowedOrigins` to control
allowed origins for notebook server WebSocket connections, replacing the need
for raw Python injection via `hub.extraConfig`.

- ParsedConfig: add `allowedOrigins: list[str]` field
- HubConfig: expose `allowed_origins` property
- RemoteLabKubeSpawner: inject `--ServerApp.allow_origin_pat` (and
  `--ServerApp.allow_origin=*` when wildcard is set) into notebook server
  startup args at spawn time
- chart/values.yaml: document new field under `custom`
- chart/values.schema.yaml + values.schema.json: add schema definition
- runtime/values.yaml: add commented usage examples
@MioYuuIH MioYuuIH requested a review from KerwinTsaiii as a code owner March 25, 2026 03:56
Replace the flat `custom.allowedOrigins` field with two clearly scoped fields:

- `custom.hub.allowedOrigins`: sets Access-Control-Allow-Origin on Hub HTTP
  responses via JupyterHub tornado_settings
- `custom.notebook.allowedOrigins`: injected into each notebook server's startup
  args via --ServerApp.allow_origin_pat, targeting kernel WebSocket connections

Naming avoids confusion with the z2jh top-level `singleuser` section.
Schema updated in values.schema.yaml and values.schema.json.
@MioYuuIH MioYuuIH changed the title feat(config): add allowedOrigins YAML config for notebook server WebSocket origins feat(config): add hub.allowedOrigins and notebook.allowedOrigins for origin policy Mar 25, 2026
Copy link
Copy Markdown
Collaborator

@KerwinTsaiii KerwinTsaiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@KerwinTsaiii KerwinTsaiii merged commit f851f94 into develop Mar 25, 2026
9 checks passed
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.

2 participants