Fix HTTPS OIDC callback behind the reverse proxy #8

Merged
exler merged 1 commit from fix/oidc-proxy-https into main 2026-10-16 20:25:58 +02:00
Collaborator

Root cause

The public https://dome.marut.network/oidc/authenticate/ currently emits redirect_uri=http://dome.marut.network/oidc/callback/ (confirmed from its actual 302 Location). The provider error combines unknown client and mismatched callback into the same message. Dome missed the trusted-proxy setting present in Mado, so Django sees the internal HTTP transport instead of external HTTPS.

Fix

Set SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https"), matching Mado. No client ID changes, HTTP production callback registration, manual callback override or mode flag. Document that the trusted proxy must overwrite the header and block direct untrusted access to the application port.

Verification

  • Parent independently reran 129 tests: OK (expected failures=1). The expected failure is pre-existing.
  • Actual OIDC init regression: forwarded HTTPS produces HTTPS callback and secure request; absent/header HTTP preserves local HTTP behavior. Same-origin CSRF logout succeeds and foreign Referer is rejected.
  • Regression tests failed before the setting was added and passed after it.
  • Focused Ruff and git diff --check pass. Independent read-only review passed.
  • No rendered UI changes. No production changes or complete sign-in with real user credentials performed.

Rollout

Deploy this commit using the existing trusted TLS-terminating proxy. Ensure the registered callback remains https://dome.marut.network/oidc/callback/. The live deployment still emits HTTP until updated. Rollback is reverting the single setting; no schema changes.

## Root cause The public `https://dome.marut.network/oidc/authenticate/` currently emits `redirect_uri=http://dome.marut.network/oidc/callback/` (confirmed from its actual 302 Location). The provider error combines unknown client and mismatched callback into the same message. Dome missed the trusted-proxy setting present in Mado, so Django sees the internal HTTP transport instead of external HTTPS. ## Fix Set `SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")`, matching Mado. No client ID changes, HTTP production callback registration, manual callback override or mode flag. Document that the trusted proxy must overwrite the header and block direct untrusted access to the application port. ## Verification - Parent independently reran **129 tests: OK (expected failures=1)**. The expected failure is pre-existing. - Actual OIDC init regression: forwarded HTTPS produces HTTPS callback and secure request; absent/header HTTP preserves local HTTP behavior. Same-origin CSRF logout succeeds and foreign Referer is rejected. - Regression tests failed before the setting was added and passed after it. - Focused Ruff and `git diff --check` pass. Independent read-only review passed. - No rendered UI changes. No production changes or complete sign-in with real user credentials performed. ## Rollout Deploy this commit using the existing trusted TLS-terminating proxy. Ensure the registered callback remains `https://dome.marut.network/oidc/callback/`. The live deployment still emits HTTP until updated. Rollback is reverting the single setting; no schema changes.
fix(auth): trust reverse proxy X-Forwarded-Proto for HTTPS OIDC callback
All checks were successful
Push Docker Image / push (push) Successful in -1m20s
0167bd20a4
TLS ends at the reverse proxy, so Django saw HTTP and sent the provider
redirect_uri=http://dome.marut.network/oidc/callback/, which the provider
rejects. Match Mado's SECURE_PROXY_SSL_HEADER so request.is_secure() and
build_absolute_uri() follow the proxy, and CSRF Referer checks apply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
exler merged commit 0167bd20a4 into main 2026-10-16 20:25:58 +02:00
exler deleted branch fix/oidc-proxy-https 2026-10-16 20:25:58 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
exler/dome!8
No description provided.