Skip to content

fix(logout): make SMB_NAME required, drop "moneta" defaults (layered on #12)#13

Closed
awais786 wants to merge 2 commits into
jawad/logout-url-fixfrom
fix/logout-smb-name-required
Closed

fix(logout): make SMB_NAME required, drop "moneta" defaults (layered on #12)#13
awais786 wants to merge 2 commits into
jawad/logout-url-fixfrom
fix/logout-smb-name-required

Conversation

@awais786
Copy link
Copy Markdown

@awais786 awais786 commented May 1, 2026

Stacks on top of #12 — base branch is jawad/logout-url-fix, not foss-main. Merge #12 first, then this. Or squash-merge both together.

Why

The "moneta" defaults scattered across auth-utils.ts, docker-entrypoint.js, both .env.example files, and both compose files re-introduce the bug class the env var is meant to close: a hardcoded literal that breaks silently the next time the deployment moves domains. Same failure mode as the original "foss." bug, one layer back.

Aligns SurfSense with:

Without this, SurfSense becomes the one app that silently rewrites to the wrong host on misconfig — and future devs reading the code will treat SurfSense as the template.

Changes

  • surfsense_web/lib/auth-utils.ts — drop || "moneta" fallback. Use process.env.NEXT_PUBLIC_SMB_NAME!.trim(). Rename smbLabelsmbName to match every other app's logout file. Drop the dead 3-line fallback comment.
  • surfsense_web/docker-entrypoint.js — add fail-fast SSO check before the replacements array. Drop the (... || "moneta").trim() || "moneta" double-fallback; substitute process.env.SMB_NAME directly.
  • surfsense_web/.env.example + docker/.env.example — drop =moneta default. Document as required under SSO with sso-rules cross-reference.
  • docker/docker-compose.yml — drop :-moneta. Use ${SMB_NAME:?...} so docker compose up fails immediately with a clear message if unset.
  • docker/docker-compose.dev.yml — drop the ${SMB_NAME:-${NEXT_PUBLIC_SMB_NAME:-moneta}} chain in favor of ${SMB_NAME:?...}.

Test plan

  • SMB_NAME=moneta docker compose up (prod): SPA logout lands on moneta.<domain>
  • docker compose up with SMB_NAME unset: container exits at startup with the entrypoint error
  • SMB_NAME=moneta docker compose -f docker-compose.dev.yml up: dev image builds, logout works
  • docker compose -f docker-compose.dev.yml up with SMB_NAME unset: compose-up fails at the build step with the :? error
  • Local next dev with NEXT_PUBLIC_SMB_NAME=moneta in .env: works
  • Local next dev with no NEXT_PUBLIC_SMB_NAME: SPA crashes at logout (expected — verifies the fail-loud shape)

🤖 Generated with Claude Code

awais786 and others added 2 commits May 1, 2026 23:10
Layered on top of #12. The "moneta" defaults scattered across
auth-utils.ts, docker-entrypoint.js, both .env.example files, and
both compose files re-introduce the bug class the env var is meant
to close: a hardcoded literal that breaks silently the next time
the deployment moves domains.

Aligns SurfSense with the sso-rules invariant merged in
awais786/sso-rules#1 (required env, no default, fail loudly) and
the sibling PRs in Outline #10, Penpot #11, Twenty #2 (all fail-fast).

Changes
-------
- auth-utils.ts: drop `|| "moneta"` fallback. Use
  process.env.NEXT_PUBLIC_SMB_NAME!.trim(). Rename smbLabel → smbName
  to match the variable name in every other app's logout file. Drop
  the dead 3-line comment about the fallback.
- docker-entrypoint.js: add fail-fast SSO check before the
  replacements array. Drop the (... || "moneta").trim() || "moneta"
  double-fallback — substitute process.env.SMB_NAME directly.
- surfsense_web/.env.example + docker/.env.example: drop the
  =moneta default. Document as required under SSO with sso-rules
  cross-reference.
- docker/docker-compose.yml: drop :-moneta. Use ${SMB_NAME:?...} so
  compose-up fails with a clear message if unset.
- docker/docker-compose.dev.yml: same — drop the
  ${SMB_NAME:-${NEXT_PUBLIC_SMB_NAME:-moneta}} chain in favor of
  ${SMB_NAME:?...}.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drops the NEXT_PUBLIC_SMB_NAME read on the SPA logout path. The previous
approach required threading SMB_NAME through devstack docker-compose
runtime env → docker-entrypoint.js placeholder substitution → bundle;
any broken link silently routed logout to the wrong host or crashed.

Switching to a regex on window.location.hostname removes the env
dependency and works for any `<prefix>-<app>.<domain>` shape:
- foss-research.local.moneta.dev → foss.local.moneta.dev
- moneta-research.askii.ai       → moneta.askii.ai

The __NEXT_PUBLIC_SMB_NAME__ placeholder + entrypoint substitution are
now dead; will be removed in a separate cleanup pass.
@awais786 awais786 closed this May 2, 2026
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