chadtmiller.com/group-host
atmosphere group host
0
0
The console's cookie is __Host-, and only its own pages use it
Merged Approved
This pull names the console's cookies __Host- where CONSOLE_URL is https. It also treats a request whose Origin is not the console's as nobody's, and answers 403 to /console/switch and /console/logout from such a request. I read every changed file and found nothing wrong.
- Cookie reads: a search finds no other reader of the session cookie. The old public
cookie_ofis gone, and the two remaining users ofCOOKIE(the MCP caller and thegroup_configtest) now go throughcookie_name. - Logout:
logoutchecksOriginbeforeconsole_caller, and the cookies it clears use the same__Host-name that was set, so sign-out works. Originmatch: the comparison is exact on the serialized origin. That is whynulland the same name on another port are refused, and the new test covers both.- Docs and tests: the docs are updated with the change as
AGENTS.mdasks, and the new test covers the behaviours the body claims.
One small thing to know: asked_elsewhere calls expect on parsing CONSOLE_URL for every request. That is safe as long as config rejects a bad URL at startup.
Merged as a7aa5f3
Where the console is on https, its cookies are now
__Host-and Secure, so no page at a name beside the console's, such as a group's address, can set one in their place. A request whoseOriginis not the console's is taken as nobody's, whatever cookie it carries, and can't switch accounts or sign out.Claude Opus 5.5
What changes
The cookies' names (
console_login.rs).Host::cookie_nameputs__Host-before each cookie's name whenCONSOLE_URLis https: the session, the sign-in under way, and the other accounts signed in. Every cookie the host sets is alreadyPath=/, has noDomain, and is Secure there, as__Host-requires. Over http, as in tests reaching the host directly, they keep their names, and a browser would refuse a__Host-cookie that isn't Secure anyway. Reading one goes throughHost::cookie_of, by the same name. The MCP server's calls in place of a member name it the same way.Where a cookie is taken from.
Host::console_calleranswers nobody for a request whoseOriginis notCONSOLE_URL's origin. That covers every method a cookie authenticates, and/img./console/switchand/console/logoutrefuse such a request with 403, setting no cookie. Otherwise a page elsewhere could still clear the session or swap accounts by the cookies alone.Originis answered as before. That is how a browser's own navigations, its same-origin GETs, the console's server calling the host, and the MCP server's calls come.Docs.
docs/design/signing-in.mdsays what the cookie is named and where it is taken from.docs/reference/api.mdnames it.docs/reference/config.md'sCONSOLE_URLrow says it is the oneOriginthe cookie is taken from.docs/design/sites.md's sandbox section names both as the host's own guard beside the sandbox.Why
It is the item of at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzlk7gxpmi3j that comes before a page the host serves around a group's site holds sessions. A group's address is under the host's domain, so its pages are the same site as the console. The sandbox keeps those pages from carrying the console's cookie, and a browser test pull checks that it does. This makes the host refuse it on its own, should any page reach it without the sandbox:
__Host-, a page atriders.groups.example.comcould set agroup_host_sessioncookie for.example.com, which the console would then receive in place of the person's own.Originrule, a same-site request carries aSameSite=Laxcookie.How it was checked
New
a_session_is_the_consoles_alone_and_only_its_pages_use_it(tests/console_login.rs), with the console on https:__Host-group_host_session;getViewernames its holder with noOriginor the console's, and nobody from a group's address, fromnull(a sandboxed page), or from the console's name on another port;/console/switchand/console/logoutfrom a group's address answer 403 with noSet-Cookie, and the person stays signed in;Origin, signing out clears__Host-group_host_sessionas it was set (Path=/; HttpOnly; SameSite=Lax; Max-Age=0; Secure).tests/group_config.rsnames its cookie bycookie_name, its host's console being https.Locally:
just t -p group-host --test console_login --test group_config --test mcp --test account_movepasses;just e2epasses all its flows: signing in through the PDS, switching accounts, signing out, and every form, each sending the console'sOriginthrough its server or none.Coverage and the rest are left to CI.
Shortcomings
just servewithjust web-dev. There the console (on its own port) is notCONSOLE_URL, so a browser's own calls to the host would be nobody's. That console can't sign anyone in either, as signing in needs https at a name, so this changes nothing there.just dev,just lookand e2e setCONSOLE_URLto the console's address.