Skip to content

feat(auth): add request-owned authentication and workspace access - #2

Merged
mateoroldos merged 20 commits into
mainfrom
auth
Sep 3, 2026
Merged

feat(auth): add request-owned authentication and workspace access#2
mateoroldos merged 20 commits into
mainfrom
auth

Conversation

@mateoroldos

Copy link
Copy Markdown
Owner

What changed

  • add application-owned identities, provider accounts, and workspace membership
  • integrate Better Auth behind an API-owned authentication port
  • provision identities atomically and safely under concurrent first requests
  • scope workspace creation and reads to the authenticated principal
  • compose public health and authenticated API groups through dependency-open Effect Layers
  • add SSR-aware browser authentication, route guards, forms, and safe return paths
  • route each deployed stage through one application host with host-only session cookies
  • keep staging and preview deployments out of search indexes

Architecture

HTTP credentials
  → Better Auth adapter
  → RequestAuth middleware
  → IdentityDirectory
  → CurrentPrincipal
  → principal-scoped application services
  → PostgreSQL adapters

Domain and core remain independent of HTTP, SQL, provider SDKs, and Cloudflare. The Worker is the only production composition root.

Validation

  • bun run check
  • domain and core service tests
  • Better Auth adapter tests
  • PostgreSQL/PGlite transaction, race, and scoping tests
  • scoped production Fetch-router tests
  • complete local application HTTP integration tests
  • stage-host derivation tests

Deployment verification

After the preview deploys, verify /api/health, signup/session cookies, /api/me, workspace isolation, host-only cookie behavior across stages, and preview noindex metadata.

@mateoroldos mateoroldos added the preview Deploy an isolated preview label Sep 2, 2026
@mateoroldos
mateoroldos force-pushed the auth branch 2 times, most recently from 8b7f00d to f5a1b2f Compare September 2, 2026 20:25
~ Exercise production request middleware through the scoped identity Fetch router.
~ Verify typed failures project to status-only responses without leaking internal details.
~ Keep provider-to-persistence behavior in isolated complete-application integration scenarios.
~ Avoid re-reading deployment-owned booleans through the Worker runtime Config bridge.
~ Derive the public origin, trusted origin, secure-cookie mode, and local CORS policy from the Alchemy stage.
~ Remove redundant AUTH_BASE_URL, WEB_ORIGIN, and AUTH_SECURE bindings.
@mateoroldos
mateoroldos merged commit 0c1a464 into main Sep 3, 2026
2 checks passed
@mateoroldos
mateoroldos deleted the auth branch September 3, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Deploy an isolated preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant