Skip to content

fix(ui): audit remediation for auth, errors, and environment handling - #302

Merged
kkopanidis merged 2 commits into
ui-rewritefrom
fix/audit-remediation
Jul 31, 2026
Merged

fix(ui): audit remediation for auth, errors, and environment handling#302
kkopanidis merged 2 commits into
ui-rewritefrom
fix/audit-remediation

Conversation

@CluelessBiker

@CluelessBiker CluelessBiker commented Jul 31, 2026

Copy link
Copy Markdown

Summary

Follow-up fixes from a full-stack audit of Conduit and Conduit-UI. This PR tightens session handling, API error paths, and multi-environment configuration in the admin panel.

  • Smarter 401 handling — Session-timeout redirects only fire when a real session cookie exists, and auth endpoints (/login, /verify-twofa) are excluded so failed logins do not loop.
  • Secure cookie defaults — Auth cookies use secure, sameSite: 'lax', and maxAge derived from the JWT expiry instead of a fixed duration.
  • Canonical environment names — Login, logout, 2FA, and the 401 interceptor all resolve env names through EnvManager so cookie names stay consistent across mixed-case inputs.
  • EnvManager fingerprint — Environment config changes (base URL, master key) are detected reliably via a SHA-256 fingerprint, including multi-env setups.
  • Shared error helpers — Replaces communications-api-error.ts with api-error.ts for consistent Axios and communications error formatting across modules.
  • Database APIgetSchemaDocument rethrows non-404 errors instead of swallowing them.
  • Global error page — "Go Home" uses a full page navigation so it works when the app shell is broken.

Why

The audit found that loose 401 redirects and mismatched cookie names could cause false logouts or broken session-timeout flows on remote environments. Fixed cookie lifetimes and env name normalization reduce those failures. Centralized error helpers make API failures easier to diagnose in production.

Related PRs

Test plan

  • Log in, wait for session expiry — confirm redirect to /login?session-timeout=true
  • Failed login with wrong password — no redirect loop
  • Switch between configured environments — cookies use correct names
  • Open a communications template detail page — API errors surface clearly
  • Trigger global error boundary — "Go Home" navigates to /

Tighten session handling and API error paths after a full-stack audit:
smarter 401 redirects, secure cookie defaults aligned with JWT lifetime,
canonical multi-env names, and shared api-error helpers.
@CluelessBiker
CluelessBiker requested a review from kkopanidis July 31, 2026 10:40
Pure cookie utility functions must not live in a use server module —
Next.js requires all exports there to be async Server Actions. Also
tighten SessionCookieOptions so value is always required for cookies().set().
@kkopanidis
kkopanidis merged commit cc08e27 into ui-rewrite Jul 31, 2026
3 checks passed
@kkopanidis
kkopanidis deleted the fix/audit-remediation branch July 31, 2026 14:26
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