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

Signing in holds at its edges: group tokens, uploads, app passwords

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/sign-in-edges

What changes

A group token for a space for chosen people. getGroupAuth now decides what a member may write in a space by the same function the write check and approval use (writes_in): in a space with people, every collection for those of them who hold repo:*, and nothing for anyone else; otherwise what credentialScopes grant. Before, it read credentialScopes alone, so an admin who was one of the people was refused, and a member who was not one of them got a token every write of which failed. The write check now calls the same function, so the two cannot drift apart again. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdfknjkcmq

Uploads ask what writes ask. uploadBlob refuses a switched-off group (RepoDeactivated), and refuses with 403 when the member who signed the app in may no longer write anything as the group: no repo grant, no group.configure, and no space where they write. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdfmcawop6

A demoted maker's app passwords are forgotten, used or not. A sign-in refused because the maker no longer holds repo:* now forgets every app password of theirs and every session from one, as a refused use or refresh already did. Listing the group's app passwords, or making one, does the same for each maker found without repo:*, so a password nobody signed in with leaves the list and does not work again when its maker is given the role back. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdfnoj7arh

A confidential client's jwks_uri is kept. Its key set is kept ten minutes beside client metadata, so a sign-in or refresh no longer fetches it each time, and a key host that is briefly down does not fail them. When an assertion names a key the kept set does not hold, the set is fetched again once, so keys can rotate. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdfpbdn5tq

The console's callback must carry iss. Atproto's OAuth profile requires authorization servers to send it, so a callback without it is refused as one with the wrong one is. It is refused whatever the server's metadata says, rather than only when it advertises the parameter, since an atproto server always must. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdfqocgijw

No fragment in an assistant's redirect URI. may_return_to refuses a fragment over every scheme, https and loopback http included, not only an app's own. Fixes at://did:plc:bcgltzqazw5tb6k2g3ttenbj/space/dev.knotless.space/group-host/did:plc:bcgltzqazw5tb6k2g3ttenbj/dev.knotless.issue/3mzjdfs4eswm7

docs/design/signing-in.md says each of these.

How it was checked

Each fix has a test that failed before it:

  • group_tokens::in_a_space_for_chosen_people_gives_those_of_them_who_may_do_anything: an admin among the people gets * and writes; a member among them and an admin outside them are refused.
  • tokens::uploads_only_while_its_member_may_write_and_the_group_is_on: uploads refused while the group is off and once the member writes nothing, allowed while they still write somewhere.
  • app_passwords::is_forgotten_once_its_maker_could_no_longer_make_it_though_never_used: a password unused when its maker is demoted is gone from the list and does not sign in after re-promotion, whether forgotten by a listing or by a refused sign-in.
  • oauth_clients::keeps_a_clients_keys_and_fetches_them_again_for_one_it_does_not_know: a kept set outlives its host answering 500; a rotated key is fetched; an unknown key is refused after one fetch, kept or fresh.
  • console_login::refuses_a_sign_in_it_cannot_trust: a new case where the server leaves iss out.
  • assistants::refuses_a_request_it_cannot_trust: fragments on https, loopback http and an app scheme.

cargo test --workspace (the reference PDS included), cargo fmt --all and cargo clippy --workspace --all-targets -- -D warnings pass locally; the coverage gate is left to CI.

Shortcomings

App passwords are forgotten lazily, when a sign-in, use, refresh, listing or new password meets them, not at the moment roles or permissions change: roles change through several paths (assigning roles, editing a role's grants, deleting a role), and checking at each read covers them all. Until one of those happens, the password sits in the store unusable.

🤖 Generated with Claude Code

Approved

This pull makes six sign-in and token fixes. I found nothing that must change.

  • Group token, writes and uploads: getGroupAuth and the write check now share writes_in. rooms and may_issue agree with it. Uploads now check that the group is active and that the member can still write something.
  • App passwords: a refused sign-in, a listing and creating a password all forget the passwords of a maker who has lost repo:*. The forgetting is lazy, as the body says.
  • Client keys and the rest: the jwks_uri key set is cached for ten minutes, with one refetch when the key is unknown. iss is now required on the console callback, and a fragment is refused on every scheme. All of these look correct, and the docs and tests were updated to match.

One small thing you could change, but I wouldn't block on it: the refetch on an unknown key can be triggered by any request that names a known client id with a bad kid, so each such request does an outbound fetch of the client's jwks_uri. Limiting how often a client's set is refetched would bound that.

Approved

The only change since my last review is in a test, ends_once_its_maker_could_no_longer_make_it. The refresh check now runs before the sign-in check, so the refresh is the step that forgets the demoted maker's passwords, as the test intends. That is correct, and the code is unchanged. My earlier approval stands. The optional point about limiting how often a client's key set is refetched is still open, and I'm not blocking on it.

Merged as 82084fa