chadtmiller.com/group-host
atmosphere group host
The host moves an account here for someone signed in to the console
MergedThis pull lets a console user sign in to the account they're moving, at its own server, with a DPoP-bound OAuth sign-in. The host keeps the tokens and runs getAccountMove, startAccountMove, finishAccountMove and cancelAccountMove itself. The import and completion logic moves into import_as and complete_import_as, which the old endpoints now share. The refactor looks behaviour-preserving. The DPoP handling (nonce retry, ath, one refresh retry on invalid_token) and the mover-must-still-be-signed-in check in the callback read correctly. I did not read the lexicon JSON files, the docs pages or tests/account_move.rs; the pull says the tests pass.
One thing to fix, though it doesn't block the merge:
- Expired rows are never cleared.
account_moverows older than a day are hidden bymove_ofbut never deleted or revoked. The access and refresh tokens and the DPoP private key stay in SQLite, and the refresh token stays valid at the account's server. This is the "a day at most" promise in the body. Delete and revoke stale rows when they are found, or sweep them.
Minor:
- A sign-in that returns to a browser no longer signed in as the mover is refused after the token exchange, and those tokens are left unrevoked.
renewsends an empty refresh token when the server issued none, so the failure surfaces as a vague upstream error.
crates/group-host/src/account_move.rsline 66Outdated
These lines can no longer be read.
started > now - KEPT_FOR only hides expired rows. They stay with their tokens and key, and the tokens are never revoked. Delete and give back an expired row when it is found, or sweep them.
Fixed in 3b12100: the host's hourly sweep (the uploads' loop in serve) deletes moves kept past a day and gives their tokens back (Host::sweep_moves). move_of still hides one lapsed between sweeps. Covered by gives_back_and_forgets_a_move_kept_a_day.
crates/group-host/src/account_move.rsline 206Outdated
These lines can no longer be read.
With no refresh token this sends an empty one. Return a clear error such as "sign in to the account again" instead.
Fixed in 3b12100: with no refresh token, renewing fails with SignInAgain ("the account's sign-in has lapsed: sign in to it again"), now in both lexicons' errors. Covered by the same new test.
The new commit asks describeServer before listing spaces, in both the host and the opensocial command. It also restores \n in the command's output. This round has one thing to fix, and last round's expiry finding is still open.
- A failed
describeServerdrops the spaces without a word.described.unwrap_or_default()["spacesAlpha"] == trueturns a timeout, a 5xx or bad JSON into "holds no spaces". The move then carries on and finishes, andfinishAccountMovemoves the identity, which can't be undone. An account whose server hiccuped once would lose its spaces. Return the error when the request fails, and treat only a successful answer withoutspacesAlpha: trueas "none". The same applies incrates/opensocial/src/lib.rs. The test only covers the server answeringfalse, so add one wheredescribeServerfails. - Last round's expiry finding is not addressed. Rows older than a day are still only hidden, not deleted, and their tokens are never revoked. Both inline comments from last round, on expired rows and on the empty refresh token, are still open. The earlier review did not block on these, and this one doesn't either, but the "a day at most" promise is still not kept.
crates/group-host/src/account_move.rslines 356 to 357Outdated
These lines can no longer be read.
A failed describeServer is read as "no spaces", and the move goes on to move the identity. Pass the error up when the request fails. Read only a successful answer's spacesAlpha.
Fixed in 3b12100: a describeServer that fails stops the move with UpstreamFailure, before the code is asked for, in the host and in opensocial import alike. Only a successful answer without spacesAlpha: true means no spaces. Covered by stops_rather_than_move_without_what_it_cannot_read_or_renew.
All three open findings are now fixed at 3b12100.
- Failed
describeServer: the host'sdescribeServercall now returns an upstream error through.map_err(upstream)?, so a failed call stops the move before it asks for the code or moves the identity.opensocial importdoes the same with?. Only a successful answer withoutspacesAlpha: truemeans "no spaces". The new teststops_rather_than_move_without_what_it_cannot_read_or_renewcovers a failingdescribeServer. - Expired rows:
Host::sweep_movesruns every hour fromserve. It deletes rows kept more than a day withDELETE ... RETURNINGand revokes their tokens.gives_back_and_forgets_a_move_kept_a_daychecks both the revocation and the deletion. - No refresh token: renewing now fails with
SignInAgain, which is tested.
Remaining minor point, not blocking: a move sign-in that comes back to a browser no longer signed in as the mover is still refused after the token exchange, and I did not check whether those tokens are revoked.
What changes
The host moves an account for someone signed in to the console. A person signed in to the console signs in to the account they're moving, at its own server (
/console/move/login?handle=<account>&back=<page>). The host asks it for what a move needs and no more:atproto;createAccountservice token for this host's#opensocialservice;identity:*;space:*?authority=*&action=read_self).The browser stays signed in as the person, and a move's sign-in that comes back to a browser no longer signed in as them is refused. The host keeps the account's tokens, one account per person for a day at most, and does each step itself:
getAccountMove: the account signed in for the caller to move, if any, and whether its move is started.startAccountMove {address?}: the account's token for this host, from its server. Then the copy, asimportAccountmakes it, and the account's spaces, asimportAccountSpacetakes them. Then its server is asked to email the code. Started again, it starts over.finishAccountMove {code}: the account's server signs the operation, the move finishes ascompleteImportdoes, and the tokens are given back.cancelAccountMove: the tokens are given back and forgotten, and a copy not yet finished is discarded.Calls to the account's server. They are DPoP-bound to a key made for the sign-in (with
ath). Each takes the nonce the server asks for. A token is refreshed before it lapses, or once if the server refuses it as lapsed, as it may while the code is in the mail. The tokens are also given back when the person signs in to another account to move.Spaces come only from a server that says it holds them (
describeServer'sspacesAlpha), for the console's move and foropensocial importalike. A stock PDS, as most are yet, hands a method it lacks to its app view, which refuses it in no one way (the reference PDS answers 502), so listing spaces there failed the whole move. An account on such a server now moves with nothing more to bring. This also puts back\nin the command's output strings, where an earlier edit of mine had left raw line breaks.Smaller changes:
importAccount's andcompleteImport's work moves intoHost::import_asandHost::complete_import_as, which both paths share.atproto.Why
You chose the command first, then a console page in which the host signs in to the account. The browser holds no PDS tokens, since the host is the console's OAuth client, so the host has to be the one calling the account's server.
The person's own sign-in still asks for
atprotoalone and keeps nothing. Only this one asks for more, only for a move, and only until the move ends.signing-in.mdsays so.How it was checked
tests/account_move.rsuses a fake that is both the account's server and its authorization server. It answers only calls bound to a token it gave and the key that token was given for, checkingathandhtu. It asks for a nonce first, as atproto's servers do. It can take a token as lapsed once, or give one that lasts less than the host waits for.listSpaces. Then a wrong code, which the server refuses, and the right one, which finishes the move and gives the tokens back.NotFoundandNotStarted; an unreachable server reported asUpstreamFailure.The import tests pass unchanged after the refactor.
account_move.rsandconsole_login.rsare at 100% here.cargo test --workspacepasses.Shortcomings
createAccounttoken, the emailed code and the PLC signature.startAccountMovedoes everything in one request, so a big account means a long wait with no progress shown.🤖 Generated with Claude Code