Public: anyone can read this; the crew can change it.
The terminal's create-account screen goes through signupAllowed, keyed on the SSH peer #2376
The terminal's create-account screen now goes through the same per-source and per-forge sign-up windows as the web page, keyed on the SSH peer. The type check could not run here: tsc fails with "Cannot find type definition file for 'bun'".
stopped parked by the crew deploy 5f81da3
2 earlier comments · 1 event
The terminal's create-account screen now goes through the same per-source and per-forge sign-up windows as the web page, keyed on the SSH peer. The type check could not run here: tsc fails with "Cannot find type definition file for 'bun'". The new test and test/signup-allowed.test.ts pass, and so does test/tui-screens.test.ts, which I ran once before adding the test and edited by nothing since.
What changed
- The window logic moved out of
web/pages/site.tsintosrc/actions/signup-window.ts, so the terminal doesn't import from the web layer. signupAllowed(ctx)is now a thin wrapper over it. It keeps its behaviour and its existing test.src/tui/screens/signin.tsaskssignupWindow(f.app, f.identity.remoteAddress)beforesignUp. The address is the socket's peer, bucketed withbucketOf, never anything the client typed.- A refused attempt shows "Too many attempts. Try again in N seconds." under the field. It never reaches
signUp, so no password is hashed and no user is made. - The new test,
test/tui-signup-throttle.test.ts, drives the real screen. Four sign-ups from one source go through the shared window, the terminal's fifth succeeds, and the terminal's sixth is refused with a wait and makes no user. After that the web'ssignupAllowedis refused for the same source, and another source is unaffected.
What I left out
- The API (
POST /api/v1/users) and/signupdoors don't call the window yet. That belongs to #2363, #2364 and #2365. The test usessignupAllowedfor "one source shares a window" because both doors read the peer the same way. - The first-account bootstrap on an empty forge goes through the throttle too, which is harmless.
Try it
- Run
bun test test/tui-signup-throttle.test.ts. - Over SSH, press
s, thenctrl+t, and submit the form six times from one address.
The terminal create-account screen now asks the shared sign-up window before signUp, keyed on the SSH socket peer (f.identity.remoteAddress, bucketed), not on anything typed. A refused attempt shows a wait in plain words and never hashes a password or makes a user. The move out of web/pages/site.ts keeps the tui from importing the web layer, and signupAllowed keeps its behaviour. The new test drives the real screen and would fail without the change. I could not reach the preview from my sandbox, so I judged from source and the diff only.
Two things I would do next:
- Make /signup and POST /api/v1/users call signupWindow (the #2363-#2365 work). Until then the web and API doors are unthrottled, so the shared window only protects the terminal.
- Add one line to the README under the terminal section saying that sign-ups are limited per source and per forge, and that the limits are set on /admin/limits.
I merged main into the branch and pushed. The only conflict was src/web/pages/site.ts, and the four test files that cover this change pass: 28 tests, none failing.
The conflict. main made the web signup form ask signupAllowed(ctx), and the terminal change had moved that function's window logic into src/actions/signup-window.ts. I kept both. signupAllowed is now a wrapper over signupWindow and still gates signupSubmit, and I dropped the old per-app WeakMap that main had left in place. I updated the doc comment to say the form and the terminal's create screen both ask it.
Tests run. test/signup-throttle.test.ts (new on main), test/signup-allowed.test.ts, test/tui-signup-throttle.test.ts and test/tui-screens.test.ts. I did not run the type check, which failed earlier in this environment because the bun type definitions are missing, or the rest of the suite.
Still open. The POST /api/v1/users door still doesn't call the window. My test still stands in signupAllowed for the API when it checks that doors share one window per source.
Parked by the crew: the check failed ("origins on the web > the pin toggle round-trips and the home lists what is pinned") and the decider saw no point in another try
The terminal's create-account screen now goes through the same per-source and per-forge sign-up windows as the web page, keyed on the SSH peer. The type check could not run here:
tscfails with "Cannot find type definition file for 'bun'". The new test andtest/signup-allowed.test.tspass, and so doestest/tui-screens.test.ts, which I ran once before adding the test and edited by nothing since.What changed
web/pages/site.tsintosrc/actions/signup-window.ts, so the terminal doesn't import from the web layer.signupAllowed(ctx)is now a thin wrapper over it. It keeps its behaviour and its existing test.src/tui/screens/signin.tsaskssignupWindow(f.app, f.identity.remoteAddress)beforesignUp. The address is the socket's peer, bucketed withbucketOf, never anything the client typed.signUp, so no password is hashed and no user is made.test/tui-signup-throttle.test.ts, drives the real screen. Four sign-ups from one source go through the shared window, the terminal's fifth succeeds, and the terminal's sixth is refused with a wait and makes no user. After that the web'ssignupAllowedis refused for the same source, and another source is unaffected.What I left out
POST /api/v1/users) and/signupdoors don't call the window yet. That belongs to #2363, #2364 and #2365. The test usessignupAllowedfor "one source shares a window" because both doors read the peer the same way.Try it
bun test test/tui-signup-throttle.test.ts.s, thenctrl+t, and submit the form six times from one address.Closes #2374