Skip to content

fix(logout): drive portal-host prefix from required SMB_NAME env#11

Closed
awais786 wants to merge 1 commit into
foss-mainfrom
fix/logout-smb-name
Closed

fix(logout): drive portal-host prefix from required SMB_NAME env#11
awais786 wants to merge 1 commit into
foss-mainfrom
fix/logout-smb-name

Conversation

@awais786
Copy link
Copy Markdown

@awais786 awais786 commented May 1, 2026

Summary

  • Logout currently hardcodes "moneta." as the portal-host prefix at surfsense_web/lib/auth-utils.ts:244 (PR use moneta instead of foss in logout #10 was the first cutover from "foss."). Both forms silently break the next domain move.
  • Source the prefix from the required SMB_NAME env var (no default — docker-entrypoint.js exits non-zero at startup if NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE=SSO and SMB_NAME is unset).
  • Plumbed via the same Pattern B2 mechanism as every other NEXT_PUBLIC_* var: Dockerfile bakes the __NEXT_PUBLIC_SMB_NAME__ placeholder; docker-entrypoint.js substitutes process.env.SMB_NAME at startup.

Why

Hardcoded prefixes silently break domain cutovers. Container env name (SMB_NAME) is uniform across every devstack app behind ForwardAuth — see sso-rules RULES.md §1 Logout.

Files changed

  • surfsense_web/DockerfileARG / ENV for NEXT_PUBLIC_SMB_NAME=__NEXT_PUBLIC_SMB_NAME__
  • surfsense_web/docker-entrypoint.js — fail-fast SSO check + substitution
  • surfsense_web/lib/auth-utils.ts — read process.env.NEXT_PUBLIC_SMB_NAME!.trim() at logout
  • surfsense_web/.env.example — document the var

Test plan

  • Build with --build-arg NEXT_PUBLIC_SMB_NAME=__NEXT_PUBLIC_SMB_NAME__ (default); deploy with SMB_NAME=moneta + NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE=SSO; verify logout lands on moneta.<domain>
  • Omit SMB_NAME with SSO; verify the container fails to start with a clear error message
  • Omit SMB_NAME without SSO; verify startup still succeeds (logout path not exercised)

🤖 Generated with Claude Code

The logout redirect hardcoded "moneta." as the portal-host prefix in
auth-utils.ts (PR #10's quick fix for the foss → moneta cutover).
Both "foss." and "moneta." silently break the next domain move.

Make the prefix env-driven via a required SMB_NAME var (no default —
docker-entrypoint.js exits non-zero at startup if the backend AUTH_TYPE
is SSO and SMB_NAME is unset, instead of silently rendering the wrong
portal host at logout).

Plumbed via the same Pattern B2 mechanism as every other
NEXT_PUBLIC_* var:
- Dockerfile: ARG/ENV NEXT_PUBLIC_SMB_NAME=__NEXT_PUBLIC_SMB_NAME__
- docker-entrypoint.js: substitutes from process.env.SMB_NAME
- auth-utils.ts: reads process.env.NEXT_PUBLIC_SMB_NAME!.trim()

Container env name (SMB_NAME) is uniform across every devstack app
behind ForwardAuth. See sso-rules RULES.md section 1 Logout.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@awais786 awais786 closed this May 1, 2026
@awais786 awais786 mentioned this pull request May 1, 2026
16 tasks
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