Repository navigation
feat(auth): sign in with Clerk and create or join a company - #149
Conversation
Astra reviewReviewed StandardsNo merge-blocking method or YAGNI findings. SpecIntent — block: return-path normalization permits an off-site redirect
Issue #138 requires the “validated The next URL construction in Fix: validate the normalized output before returning it—at minimum reject a pathname beginning Reproduced with the production helpers: Verification: 52 tests passed across 6 focused files ( Summary: Standards: 0 blockers. Spec: 1 blocker; the same-origin return-path guarantee is bypassable. |
|
Two-axis review of PR 149 ( Commits: StandardsNo hard documented-standard breaches. Documented standardsNone that need a change. Tooling already covers namespace imports, inline Schema compiles, and manual test runtimes. Baseline smells (judgement)Feature Envy — export const handle = Effect.fn("Join.handle")(function* (
claims: Claims,
membership: { readonly company: { readonly name: string } } | null,
returnTo: string | null
) {
const request = yield* HttpServerRequest.HttpServerRequest;
if (membership) { /* ... */ }
if (request.method !== "POST") return yield* render(claims, returnTo);
const fields = Object.fromEntries(yield* request.urlParamsBody);Smallest fix: AuthPages reads method/body; Divergent Change — Smallest fix: return a deactivated marker; let the middleware call Duplicated Code — the Effect service conventions (separate pass)
Near-misses (judgement-call):
UI consistency (separate pass)No UI consistency findings. SpecPrimary spec: issue #138. Parent spec this ticket implements: #135 §7 (session/door), §8 (pages), §11 (dev loop/tests). Ticket 138 says no (a) Missing or partial
(b) Scope creepNone material. Extra 400/502/503 pages and Clerk telemetry off are defensive, not new product surface. (c) Implemented but wrongNone of the checked paths look wrong:
Intent (issue #138)Issue intent in one sentence: “A person signs in and lands in a company.” The product is real, not just Session plumbing. Signed-out They do not land in a company as a place to work. They land on Slice boundaries honored ("No
Still "plain server-rendered forms, Clerk holds the session." Extra, not a different product: PR body is honest about live Google. Docs describe that path as how to use For a person: one Sign in link, a name/handle form, Not you? Sign out. After success, a sentence and no next action — fine for this slice. For MethodThe method is the smallest model that keeps Clerk as the session and Patchy as the company. It copies the prototype’s seam, then drops the prototype’s half-up state and instrumentation. Session is a thin adapter, not a second session. Wraps Middleware, not per-route checks. Handshake, door, claim refresh, and deactivation are shared admission. Join belongs in companies. ADR-0007: membership is transactional beside the company.
Testing seam is right. RSA-2048 + Origin CSRF matches SameSite=None. Clerk session cookies are None. A CSRF token would be a second secret beside Clerk’s cookie. None of the extra indirection invents a Patchy session. The one method that would be more honest: keep Join’s HTML in companies, move form parsing to AuthPages. YAGNISimple, keep it. One Shell grewThe moved tokens/layout match Serving’s old body:has(.auth-card) { min-height: 100vh; display: flow-root; }
.auth-card { ... }
.auth-action:disabled { opacity: .6; cursor: not-allowed; }Dead surface
Test slopThe fetch guard was required. The 70-line WHATWG redirect replay plus the Not flagged: keypair fixture, Origin check, cookie Domain/Path, handshake filtering, boot required-four, handshake-failed door. Standards: 3 judgement smells, 1 Effect convention finding, 0 UI findings — worst: manufactured |
|
Reviewed both agent comments against the source. Pushed fixes in 1d02ee9. Fixed
Kept as is
Verification and remaining acceptance blocker
|
|
Visual reference for the first-party pages this stack introduces.
Both pages are public but unlisted. |
|
bit of a weird caveat. Company emails change and we don't want to be blocking someone because of that so have the ability for an admin to change that shit or something. fringe case scenario and we dont really need it right now. |
|
@vsrikar08 Following up on your email-change concern: existing membership is keyed by the stable Clerk user ID, and the local email/name refresh from verified claims when the user returns. An email change on that same Clerk account therefore doesn't itself require rejoining the company. A separate admin-driven identity migration or company-domain management flow is outside this PR. No additional change requested here. |
e802c3f to
ffe36ca
Compare
1d02ee9 to
266e5ce
Compare
People had no browser sign-in flow or way to create or join their company after signing in.
Adds Clerk sign-in, create-or-join, and sign-out using plain server-rendered forms. Sessions are verified server-side, first-party posts enforce same-origin requests, and the shared page shell keeps Clerk sessions refreshed. Includes offline authentication coverage and development setup guidance.
Stacked on #148 (
auth/137-companies-users-machine-tokens); this PR targets that branch and contains only the follow-on browser-auth changes. Merge the parent first.Fixes #138.
Verification:
pnpm typecheck,pnpm lint, andpnpm testpass (213 tests across 31 files). Standards and Spec review findings are resolved. Live Google sign-in has not been exercised; authentication coverage uses offline Clerk fixtures.Built with OpenAI GPT-6 Astra using the Oh My Pi harness.