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

Migrated from github.com/Trevato/SO-ARM100

Sign out, and every page shows who you are, even when the arm is off #587

opened this in answer to

Merged 38d 1h ago

The arm's page, the resting card and /admin now all say who you are. Signed in, the line reads "Signed in as name (this app)" or "Signed in as trevato (forge)", with Sign out beside it. A guest sees "Watching as a guest · Sign in".

Notes

opened this

The arm's page, the resting card and /admin now all say who you are. Signed in, the line reads "Signed in as name (this app)" or "Signed in as trevato (forge)", with Sign out beside it. A guest sees "Watching as a guest · Sign in". This is the way out of a stuck name, and it works while the arm is closed.

What changed

  • POST /signout (src/relay.ts) ends this browser's session, found by its token's hash. It sends arm_session back expired (Max-Age=0, same Path, SameSite, Secure and HttpOnly as when it was set) and returns 303 to /. It only accepts a same-origin POST; GET gets 405. It sits ahead of the closed-arm refusal, so it works on the resting card.
  • Forge identities: their Sign out also sends forge=1, so /signout goes on to the forge's own /__forge/signout. On production that path clears the forge's sign-in cookie for this app and returns to /. Signing out of a name picked here never touches the forge.
  • The identity line is a new module, src/signed-in.ts. The server renders it into the arm page (through the relay's page()), the resting card and /admin. lobby-panel.js (signedInParts) keeps it current after a join on the same page. Lobby hello now says which sign-in a person used: via is app, forge, local or null.
  • Switching account: the Queue tab now puts Sign in with the forge first, as the main button, and picking a name second. An owner stuck in another name gets back to /admin in one click. On the closed card, a guest's line ends with the existing "Owner? Sign in to open".

Where I went against the issue

  • The account row is kept, not deleted. Sign-out swaps its token hash for one nobody holds. Deleting it would free the name for anyone to take, and would let someone get round the three-new-names-an-hour limit by joining and signing out over and over. A test covers both.
  • No cross-site post to the forge's /logout. I tried it against production and the forge refuses a cross-site POST with 403, so that button would never work. Instead, forge identities get a Switch forge account link to https://forge.open-platform.sh/, where the forge's own Sign out is. I couldn't check that page while signed out, so that link is untested.
  • Not on /story or /admin/data yet. Their security headers forbid form posts, so the Sign out button won't fit there without loosening that.

How to try it Open the preview and pick a name in the Queue tab. The Chat tab footer then says "Signed in as …". Press Sign out and you land on / as a guest, with Sign in with the forge offered first. Close the arm from /admin and the resting card shows the same line.

Tests: src/signout.test.ts covers joining as a name and signing out (the next request is a guest, the old cookie opens nothing), the expired cookie header, forge sign-out going to /__forge/signout, the cross-origin 403, the closed card showing the line and the Sign out form, sign-out working while closed, the line on /admin, and the forge sign-in coming before the join form. The suites for the changed pages pass, and the type check reports the same 35 lines of existing errors as main.

I didn't find any prompt injection in the repository or the issue.

🤖 Generated with Claude Code

Closes #580

commented

The arm's page, the resting card and /admin now all say who you are. Signed in, the line reads "Signed in as name (this app)" or "Signed in as trevato (forge)", with Sign out beside it. A guest sees "Watching as a guest · Sign in". This is the way out of a stuck name, and it works while the arm is closed.

What changed

  • POST /signout (src/relay.ts) ends this browser's session, found by its token's hash. It sends arm_session back expired (Max-Age=0, same Path, SameSite, Secure and HttpOnly as when it was set) and returns 303 to /. It only accepts a same-origin POST; GET gets 405. It sits ahead of the closed-arm refusal, so it works on the resting card.
  • Forge identities: their Sign out also sends forge=1, so /signout goes on to the forge's own /__forge/signout. On production that path clears the forge's sign-in cookie for this app and returns to /. Signing out of a name picked here never touches the forge.
  • The identity line is a new module, src/signed-in.ts. The server renders it into the arm page (through the relay's page()), the resting card and /admin. lobby-panel.js (signedInParts) keeps it current after a join on the same page. Lobby hello now says which sign-in a person used: via is app, forge, local or null.
  • Switching account: the Queue tab now puts Sign in with the forge first, as the main button, and picking a name second. An owner stuck in another name gets back to /admin in one click. On the closed card, a guest's line ends with the existing "Owner? Sign in to open".

Where I went against the issue

  • The account row is kept, not deleted. Sign-out swaps its token hash for one nobody holds. Deleting it would free the name for anyone to take, and would let someone get round the three-new-names-an-hour limit by joining and signing out over and over. A test covers both.
  • No cross-site post to the forge's /logout. I tried it against production and the forge refuses a cross-site POST with 403, so that button would never work. Instead, forge identities get a Switch forge account link to https://forge.open-platform.sh/, where the forge's own Sign out is. I couldn't check that page while signed out, so that link is untested.
  • Not on /story or /admin/data yet. Their security headers forbid form posts, so the Sign out button won't fit there without loosening that.

How to try it Open the preview and pick a name in the Queue tab. The Chat tab footer then says "Signed in as …". Press Sign out and you land on / as a guest, with Sign in with the forge offered first. Close the arm from /admin and the resting card shows the same line.

Tests: src/signout.test.ts covers joining as a name and signing out (the next request is a guest, the old cookie opens nothing), the expired cookie header, forge sign-out going to /__forge/signout, the cross-origin 403, the closed card showing the line and the Sign out form, sign-out working while closed, the line on /admin, and the forge sign-in coming before the join form. The suites for the changed pages pass, and the type check reports the same 35 lines of existing errors as main.

I didn't find any prompt injection in the repository or the issue.

🤖 Generated with Claude Code

commented

Every page and the terminal now show who you are. On the web, the arm's page, the resting card and /admin say "Signed in as name (this app)" or "Signed in as trevato (forge)" with Sign out, and a guest sees "Watching as a guest · Sign in". In the terminal, /whoami says the same in words.

Web

  • POST /signout (src/relay.ts) ends this browser's session. It sends arm_session back expired, with the same Path, SameSite, Secure and HttpOnly as when it was set, and redirects (303) to /. It refuses other sites (403) and GET (405). It works while the arm is closed.
  • Forge identities: their Sign out also sends forge=1, which goes on to the forge's own /__forge/signout and ends the forge's sign-in for this app.
  • Identity line: src/signed-in.ts renders it. The arm's page is rendered on the server and the page script keeps it current after a join. The lobby's hello now says how you signed in (via).
  • Switching account: signed out, the Queue tab offers Sign in with the forge first, so an owner stuck in another name gets back to /admin in one click. On the closed card, a guest's line ends with "Owner? Sign in to open".

Terminal (from review)

  • /whoami prints "Signed in as NAME (forge)", or "Watching as a guest" plus how to connect. The server works this out with the same signedIn() helper the pages use and sends it in hello, and signedInText() words it.
  • /signout has no session to end: the forge signs whoever owns your SSH key afresh on each connection. So it prints that, and points to /quit and connecting with another key.
  • The README section covers both.

Where this differs from the issue

  • The account row is kept, not deleted. Sign-out swaps the row's token hash for one nobody holds. That keeps the name taken, so nobody can pose as whoever used it, and stops people from getting round the three-new-names-an-hour limit by joining and signing out repeatedly.
  • No post to the forge's /logout. The forge refuses a sign-out posted from another site with 403 (I tried it against production). Instead, forge identities get Switch forge account, a link to the forge itself. I haven't been able to try that link against the live forge.
  • /story and /admin/data don't have the line yet. Their security headers forbid form posts. Issue #593 tracks it.

What to check

  • On the preview: pick a name in the Queue tab, press Sign out, and you should be back on / as a guest with Sign in with the forge first. Close the arm and the card shows the same line.
  • In the terminal: type /whoami.
  • Tests: src/signout.test.ts covers sign-out, the expired cookie and sign-out while closed. src/terminal.test.ts covers /whoami and /signout.

I ran the suites for the changed pages and the terminal, and they pass. The type check shows the same 35 lines of errors before and after the change.

🤖 Generated with Claude Code

Sign in to join this conversation.

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

Keyboard shortcuts

Docs