Skip to content

feat: allow loopback auth bypass in development - #15

Closed
BunsDev wants to merge 4 commits into
mainfrom
feat/dev-loopback-auth-bypass
Closed

feat: allow loopback auth bypass in development#15
BunsDev wants to merge 4 commits into
mainfrom
feat/dev-loopback-auth-bypass

Conversation

@BunsDev

@BunsDev BunsDev commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

  • allow sessionless dashboard access only for exact external NODE_ENV=development after loopback Host and Origin validation
  • keep test, production, unset, and other environments behind strict session auth and one-time launch tokens
  • preserve valid development cookies for logout revocation and document the development/production split

Test plan

  • pnpm test (121 tests)
  • pnpm typecheck
  • bundled NODE_ENV=test launch prints a tokenized URL and unauthenticated status returns 401
  • bundled NODE_ENV=development launch prints a bare URL and unauthenticated status returns 200
  • staged privacy guard and secret scan

BunsDev and others added 4 commits July 26, 2026 10:40
Keep non-development modes behind one-time launch tokens and strict session authentication even when Next rewrites NODE_ENV in bundled route code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Copilot AI review requested due to automatic review settings August 1, 2026 02:17
@vercel

vercel Bot commented Aug 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
coven-memory Error Error Aug 1, 2026 2:17am

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an explicit “development auth mode” that permits sessionless access only for loopback requests (after Host/Origin validation), while keeping strict session+token auth for production, test, and other environments. It also adjusts the launch URL behavior so development can print a plain URL while non-development environments print a tokenized fragment URL.

Changes:

  • Add a runtime auth-mode signal (COVEN_MEMORY_RUNTIME_AUTH_MODE) derived from NODE_ENV, and use it to gate development-only session bypass.
  • Introduce createLaunchUrl to emit bare URLs in development and one-time-token fragment URLs otherwise, and wire it into server.ts.
  • Update route/test coverage and documentation to reflect the development vs production behavior split.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/server/request-guard.ts Enables development-only sessionless behavior after loopback Host/Origin validation, returning session: null when bypassed.
src/server/request-guard.test.ts Adds coverage for the development bypass and session preservation behavior.
src/server/launch-url.ts Adds helper to create a dev (plain) vs non-dev (tokenized fragment) launch URL.
src/server/launch-url.test.ts Tests launch URL behavior and ensures token issuance only when required.
src/server/auth-mode.ts Adds runtime auth-mode derivation and query helpers (configureRuntimeAuthMode, isDevelopmentAuthMode).
src/server/auth-mode.test.ts Verifies strict-by-default behavior and exact development enablement semantics.
src/app/api/session/session-routes.test.ts Adds development-mode coverage for status/logout without a cookie and for revocation behavior when a cookie exists.
src/app/api/session/logout/route.ts Avoids revoking a session when development mode returns session: null (sessionless path).
src/app/api/memory/routes.test.ts Adds development-mode coverage allowing sessionless loopback reads.
server.ts Configures runtime auth mode at startup and switches to printing a computed launch URL.
SECURITY.md Documents the development vs production differences for tokens/sessions and loopback validation.
README.md Updates usage docs to describe development plain-URL behavior and production token exchange.
docs/superpowers/specs/2026-07-26-standalone-memory-dashboard-design.md Updates the design spec with additional hardening/UX/security details and endpoint list changes.
.beads/interactions.jsonl Records bead status/field changes associated with the work.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1 to +8
import {
guardLocalRequest,
guardLoopbackRequest,
SESSION_COOKIE
} from "./request-guard";

const RUNTIME_AUTH_MODE_ENV = "COVEN_MEMORY_RUNTIME_AUTH_MODE";

Comment on lines +125 to +136
it("preserves a valid development session cookie", () => {
vi.stubEnv(RUNTIME_AUTH_MODE_ENV, "development");
const hasSession = vi.fn((value: string) => value === "valid");

expect(
guardLocalRequest(
request(undefined, { cookie: `${SESSION_COOKIE}=valid` }),
hasSession
)
).toEqual({ ok: true, session: "valid" });
expect(hasSession).toHaveBeenCalledWith("valid");
});
Comment on lines 6 to +11
import { GET as status, OPTIONS as statusOptions } from "./status/route";
import { runtime } from "@/server/runtime";
import { SESSION_COOKIE } from "@/server/request-guard";

const RUNTIME_AUTH_MODE_ENV = "COVEN_MEMORY_RUNTIME_AUTH_MODE";

Comment on lines 15 to 18
const mockedRuntime = vi.mocked(runtime);
const id = "d251bc66-3e45-5d03-8d78-1e76919642f9";
const RUNTIME_AUTH_MODE_ENV = "COVEN_MEMORY_RUNTIME_AUTH_MODE";

Comment thread README.md
Comment on lines +36 to +39
The custom server binds to `127.0.0.1:3737` by default. In development it
prints a plain loopback URL; open that URL directly. Development skips the
session cookie only after the strict loopback Host and same-origin Origin
checks pass.
Comment thread src/server/auth-mode.ts
Comment on lines +6 to +10
export function normalizeNodeEnvironment(
nodeEnvironment: string | undefined
): string | undefined {
return nodeEnvironment;
}
@BunsDev

BunsDev commented Aug 1, 2026

Copy link
Copy Markdown
Member Author

Superseded by #13, which removed launch tokens, browser sessions, logout, and lock state in favor of process-local transport proof. Merging this branch would reintroduce the retired security architecture.

@BunsDev BunsDev closed this Aug 1, 2026
@BunsDev
BunsDev deleted the feat/dev-loopback-auth-bypass branch August 1, 2026 02:46
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