~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

The console signs in with one OAuth client on atproto-client 0.6

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:client/oauth3

What changes

One OAuth client. The console signs people in, and signs in to accounts being moved here, with one atproto-client 0.6 client in place of two. authorize returns the request's state, which the browser's cookie now holds, so the callback no longer peeks at the stored request. The callback takes the login unkept (callback_unkept), checks the route it came back to and, for a move, that its mover is still the one signed in; then a move's session is kept (keep) and a console sign-in's given back at once (discard). A sign-in coming back to the other callback is refused as one this browser did not start, approved or refused: a failed callback now carries its app_state, and the host's refusal reads the failure's cause.

A move ended stays ended. The move session store keeps a session only while its account's move is kept, and answers StoreError::Ended otherwise, so a move finished, cancelled or swept while its session was being refreshed is not brought back: the crate gives the refreshed tokens back, and the move answers NotFound. Finishing and cancelling now forget the move before giving its session back.

Service auth by verify_any. service_caller (the host's own methods, notifyRepoUpdate, notifyCredentialsRevoked) and the account-import token check with atproto_client::service_auth::verify_any, in place of Resolver::with_key and a hand-read document, each for the audience it took before (this host's DID or any of its services; a space's authority or its host; a repo hosted here). Audience and method are judged before any key is read. An import token whose DID can't be resolved is now InvalidToken, as one naming no key is, where it was InvalidRequest.

Docs. signing-in.md says what the cookie holds now and that one client serves both.

Why

Pull 2 worked around atproto-client 0.4/0.5: two clients, as a sign-in ended any session its client kept; the state carried in app_state with a store peek; no app_state on a refused callback; no way for a store to say a session ended. 0.5 and 0.6 add what each lacked.

How it was checked

New tests: a console sign-in's state arriving at the move callback, approved and refused, is refused and keeps nothing; a move cancelled while its session refreshes answers NotFound, and the refreshed tokens are revoked. account_move, console_login, groups, spaces and import pass locally; the gate and e2e are left to CI.

Approved

This pull moves the console onto one atproto-client 0.6 OAuth client for console sign-ins and account moves. It also checks service auth with verify_any. I read the whole diff and the base AGENTS.md. I didn't read the checks or run the tests.

  • Browser check: the callback compares the cookie to the returned state before anything is redeemed. A sign-in arriving at the wrong callback is refused as one this browser didn't start, and a session it was granted is given back with discard.
  • Move session store: KEEP_SESSION inserts only while the account's account_move row exists, and the store answers StoreError::Ended otherwise. The INSERT … SELECT … WHERE … ON CONFLICT parses in SQLite and counts one row changed on both insert and update.
  • Finish and cancel: they forget the move before giving the session back, which closes the race the pull describes.
  • Callback order: the move callback now does keep_move and the give-back of the previous account before keep. This also fixes a latent case where signing in again to the same account could have revoked the session just stored.
  • Service auth: service_caller still checks the method and the audience before any key is read, then calls verify_any. Each caller's audience rule moved into a closure and keeps its earlier meaning.
  • Other changes: the changeset, the signing-in.md update and the new tests are present, and the InvalidToken change matches the body.
Approved

Since my approval at a1de846, the pull only adds a test in spaces.rs. A Bearer nonsense token sent to notifyCredentialsRevoked must answer 401 with BadJwt. The test fits the verify_any change and doesn't touch the earlier findings. I did not run it. My earlier approval stands.

Merged as 4692a97