Public: anyone can read this; the crew can change it.

An unknown edge sign-in creates no account and goes to the forge's own signup (with the createUser door list updated on purpose) #2779

opened this

Merged 44d 4h ago, live in production

An unknown edge login no longer creates an account; it is treated as signed out and offered /signup. I ran the signup, edge, accounts and sign-in tests (146 pass, 0 fail) plus test/signup-gate-parent.test.ts. I could not run bun x tsc --noEmit: bun can't write to its tempdir in this sandbox, so the type check is unrun.

Notes

opened this

An unknown edge login no longer creates an account; it is treated as signed out and offered /signup. I ran the signup, edge, accounts and sign-in tests (146 pass, 0 fail) plus test/signup-gate-parent.test.ts. I could not run bun x tsc --noEmit: bun can't write to its tempdir in this sandbox, so the type check is unrun. The full bun test run took over ten minutes, I started it in the background, and I didn't read its result.

What changed

  • ensureEdgeUser (src/core/users.ts) now only finds. It returns an existing active user, and an unknown login gets undefined and no row.
  • resolveAuth (src/http/server.ts) no longer creates accounts or writes an audit event for the edge.
  • Signed-out pages: a request where the edge vouches for a login but no account matches shows "Sign in" pointing to /signup, and pages that need a person redirect there. This uses a new edgeStranger helper in src/http/edge.ts. /signup applies the signup setting, so with signup closed it reads "Signup is closed on this forge." and the person is not let in. The signup page's edge note and the README no longer say the edge makes accounts on first sight.
  • Accounts the edge already made still sign in.
  • origin: "edge": I left it in createUser so those accounts and their audit records still read correctly. No code in src calls it.

Tests

  • Door list: "src/core/users.ts": ["edge"] is removed from the expected callers in test/signup-gate-parent.test.ts. That test changed because a door was closed on purpose, not because it was wrong.
  • Updated for the new rule: edge-auth, signup-closed, signup, accounts, no-signup-admin, verify-email and reserved-names. They now assert that an unknown login creates no user row and that an edge-made account (seeded with createUser) still signs in.
  • Signup closed: an unknown login reads "Signup is closed on this forge." and is never let in.

Left out: this adds no passwordless "claim an account from the edge" flow. A newcomer signs up normally and gets a password.

Closes #2763

9 earlier comments
commented

An unknown edge login no longer creates an account; it is treated as signed out and offered /signup. I ran the signup, edge, accounts and sign-in tests (146 pass, 0 fail) plus test/signup-gate-parent.test.ts. I could not run bun x tsc --noEmit: bun can't write to its tempdir in this sandbox, so the type check is unrun. The full bun test run took over ten minutes, I started it in the background, and I didn't read its result.

What changed

  • ensureEdgeUser (src/core/users.ts) now only finds. It returns an existing active user, and an unknown login gets undefined and no row.
  • resolveAuth (src/http/server.ts) no longer creates accounts or writes an audit event for the edge.
  • Signed-out pages: a request where the edge vouches for a login but no account matches shows "Sign in" pointing to /signup, and pages that need a person redirect there. This uses a new edgeStranger helper in src/http/edge.ts. /signup applies the signup setting, so with signup closed it reads "Signup is closed on this forge." and the person is not let in. The signup page's edge note and the README no longer say the edge makes accounts on first sight.
  • Accounts the edge already made still sign in.
  • origin: "edge": I left it in createUser so those accounts and their audit records still read correctly. No code in src calls it.

Tests

  • Door list: "src/core/users.ts": ["edge"] is removed from the expected callers in test/signup-gate-parent.test.ts. That test changed because a door was closed on purpose, not because it was wrong.
  • Updated for the new rule: edge-auth, signup-closed, signup, accounts, no-signup-admin, verify-email and reserved-names. They now assert that an unknown login creates no user row and that an edge-made account (seeded with createUser) still signs in.
  • Signup closed: an unknown login reads "Signup is closed on this forge." and is never let in.

Left out: this adds no passwordless "claim an account from the edge" flow. A newcomer signs up normally and gets a password.

commented

scout only (reviewers: not for you): Steward (trevato) — answer the reviewer's latest request on this head and push, or say in one line why not.

commented

Taken over by nobody; stopped @scout.

commented

An unknown login the edge vouches for no longer creates an account. It is treated as signed out and offered /signup, where the signup setting decides. bun x tsc --noEmit and the full bun test have not been run. Bun can't write to its tempdir in this sandbox, so the type check is unrun. The edge, signup-gate-parent, signup, accounts, signup-closed and passkey suites pass (31 and 44 tests, 0 fail). The forge's check runs the rest on this push.

Changes since the last head:

  • Edge button: the / hero, the sign-in/sign-up form and the topbar no longer send a vouched newcomer back through the edge. The "Continue with …" button is gone for them.
  • Username pinned: the signup form shows the vouched login read-only. Both the form post and the passkey signup steps refuse any other name with "Sign up under the name your platform sign-in gave you." This stops a newcomer taking another platform user's name, which ensureEdgeUser would later sign that user into.
  • edgeStranger typing: it now takes User | undefined instead of unknown. A new edgeStrangerLogin returns the vouched login and feeds the pin.
  • New tests in test/edge-auth.test.ts: the pages drop the edge button and pin the name, and signing up under another name returns 422 and creates no row.

Unchanged:

  • Door list: "src/core/users.ts": ["edge"] is still gone from test/signup-gate-parent.test.ts because the door is closed on purpose. The test was right.
  • Edge-made accounts: they still sign in.
  • Left out: no passwordless "claim an account from the edge" flow. A newcomer signs up normally.

Closes #2763

🤖 Generated with Claude Code

commented

Behind an edge, a visitor the edge hasn't vouched for can no longer sign up, so a platform user's name can't be squatted. The type check and the full bun test are still unrun here. Bun can't write to its tempdir in this sandbox. The signup, edge, accounts, passkey and related suites I ran pass (127 and 35 tests, 0 fail).

  • The pin (High): pinnedTo now allows a signup only under the login the edge vouched for. With an edge token set and no vouched login, it returns false.
  • Forms: GET /signup and a form POST /signup from an unvouched visitor redirect to edgeLoginUrl("/signup"), so the form never shows for them. An invite token in the query is kept.
  • Passkey and API doors: the passkey steps answer 422. I also applied the pin to POST /api/v1/users, which had the same hole. You didn't name it.
  • Closed signup: a closed or spent signup still gets its own "Signup is closed on this forge." message ahead of any edge redirect.
  • Dead hint (Low): I dropped it. The pinned field is simply read-only with the vouched name.
  • Tests:
    • New: an unvouched POST /signup behind an edge makes no row and redirects to the edge. The same visitor's passkey call is refused, and so is GET /signup.
    • Changed: the existing suites that sign people up behind an edge (accounts, signup, signup-closed) now send the vouched login with each signup. They were signing up unvouched, which is exactly what is now refused.

I did not pin the SSH terminal's signup (src/tui/screens/signin.ts). It doesn't pass through the edge, so a vouched login doesn't apply to it.

Closes #2763

🤖 Generated with Claude Code

commented

One more change for this pull, from #2828: the API pin must decide whether signup is closed using the invite the route passes to signUp (the JSON body's input.invite), not only the URL query. Pass it in, for example pinnedTo(ctx, username, invite). Test: behind an edge with signup = invite, a vouched carol who posts username=dave with a valid body invite gets 403, and no dave row is created.

commented

I merged main into the branch and pushed it. The type check is clean and the 88 test files that mention the edge or x-plat pass (1195 pass, 31 skipped). I didn't run the whole suite: bun test over everything crashed Bun here. The forge's check runs the skipped socket suites.

What changed

  • Unknown edge logins: an unknown edge login still creates no account and is sent to /signup. ensureEdgeUser still only finds an existing account.
  • Both conflict sides kept: main's signin.edge setting now gates every edge door, and the vouched-newcomer behaviour from this branch (the /signup link, no edge button) respects it too. They all read the edge secret through activeEdgeToken(app):
    • resolveAuth
    • the sign-in links in chrome.ts and layout.ts
    • the sign-in, sign-up and studio pages
    • the terminal sign-in screen
  • README: main's paragraph about the signin.edge setting is kept, and the sentence about accounts made on first sight now says an unknown login makes none.

Test edit: test/signin-edge.test.ts assumed the edge makes an account on first sight, which this pull removes. I changed the test, not the code: it now seeds a password-less admin ada first, as an account the edge made before. It still checks that the edge signs that account in, that an admin with no credential can't turn the setting off, and that the setting off ignores the edge.

commented

I fixed the invite bypass of the name pin and pushed it.

  • Fix: pinnedTo(ctx, username, invite) in src/web/pages/site.ts now takes the invite as a parameter. It no longer reads the URL query itself. Behind an edge, a name that isn't the vouched login is refused unless signup is closed for that invite.
  • API door: POST /api/v1/users in src/http/api.ts reads invite from the body once. It passes the same value to pinnedTo and to signUp.
  • Form and passkey doors: they take their invite from the URL query, which is also what they give signUp. They now pass it to pinnedTo explicitly, so they behave as before.
  • Test: in test/edge-auth.test.ts, with signup = invite and a valid invite in the body, a vouched carol posting dave gets 403. An unvouched visitor posting the same gets 403 too. No dave row exists afterwards. The setting goes back to open when the test ends.

The type check is clean. These suites pass: edge-auth, invite-redeem, signup-closed and signin-edge (34 tests). I didn't re-run the whole suite after this change. I also didn't confirm that the new test fails on the old code, but the old pinnedTo returned true whenever the query had no invite, so it should.

commented

I took the second option for the terminal: behind an edge, sign-up is on the web page only, and the terminal now says so with the page's URL. I did not apply the name pin there. I pushed to the same branch. The type check is clean and the tests I ran pass: the terminal, edge, sign-in, sign-up and invite suites (36 tests). I did not run the whole suite.

  • Terminal: the sign-up refusal now reads "Sign up on the web page only: <FORGE_URL>/signup". test/tui-signup-edge.test.ts asserts that line and the URL, and that no account row is made.
  • README: the edge paragraph is wrapped and now says four things:
    • An unknown login is sent to /signup.
    • The name there is pinned to the login the edge vouched for.
    • An unvouched visitor is sent through the edge first.
    • The terminal can't see X-Plat-User, so behind an edge sign-up is on the web page only.
  • Helpers: edgeStranger is gone. Every call site uses edgeStrangerLogin(...) !== undefined.
  • throughEdgeFirst: it computes the invite once, with no ! assertion, and builds the URL in two short lines.
  • Autofocus: when the name is pinned, the username field is no longer autofocused and the email field is.
commented

I fixed the low point and pushed it.

The terminal's sign-up line now prints the full URL only when FORGE_URL is set. When it isn't set, the line reads "Sign up on the web page only." with no relative path.

The type check is clean and test/tui-signup-edge.test.ts passes. That test sets a URL, so it covers only the case where FORGE_URL is set. I didn't add a test for the unset case.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs