chadtmiller.com/group-host
atmosphere group host
0
0
Scopes are read by atproto's scope module, as the reference reads them
Merged Approved
This moves scope reading onto atproto::scope. Permissions now wraps Scopes, covers, own_method, actions_of and SpaceScope::parse use typed scopes, and a migration rewrites stored token and request scopes through scopes::upgraded. I found nothing that must change.
- Reading the code: I read the changes to
scopes.rs,oauth_scope.rs,rbac.rs,permission_sets.rs,group_tokens.rsandstore.rs. The typedcoversand thelegacyrewrite hold together. The migration runs inside the migration transaction, andupgraded_scopeis registered before it. Theoauth_requestupdate skips NULL scopes.oauth_token.scopeisNOT NULL, so the SQL function never sees a NULL. - Not read: I did not read the test files (
members,oauth_scope,rbacandtokens),.changesetordocs/design/signing-in.md, or theCargo.tomlbump. I took the tests and docs on your description. Thecheckandtestchecks were still queued when I looked, so CI is the real verdict on them. - Assumption to confirm:
SpaceScope::parsecomputesread_onlyasmanage.is_empty() && actions.all(reads). It lost the old!actions.is_empty()guard, andmembership_actionsnow usesscope.actions.contains(..)directly. Both are right only if the crate fillsSpace.actionswith the defaults when none are named. Your tests likely cover this. If any scope with no action ever parsed to an empty list, it would become read-only here and would grant no memberships. - Shortcomings you listed: I agree with them. Stored role records and space policies are not rewritten, and a permission in one that the grammar doesn't take now grants nothing. If you have deployed groups with such records, a note in the changelog would help.
Approved
Since my approval at 560d179, the only change is a test addition in tests/oauth_scope.rs. It adds a role c that has a bare repo:a.b.q permission, and it asserts that this permission isn't read as a space write, so writes for c holds only a.b.z. This doesn't touch the earlier reading of covers or the migration, so my approval stands. I didn't re-run the tests.
Merged as f0f6666
What changes
One grammar. The host reads OAuth scopes, roles' permissions and space policies' permissions with atproto 0.4.4's
atproto::scope(Scope,Scopes,resolve_self, theallows_*andmanages_spacechecks), which reads them as the permission spec and@atproto/oauth-scopesdo. Its own grammar goes:scopes.rs'sdecoded,repo_collections,is_blob,named,query,actions,mime_matchesand the action tables, the parsing half ofoauth_scope.rs(SpaceScope::parseis now a view of the crate'sSpace),rbac.rs's ownquery/query_ofand string matching inactions_ofandrepo_collections_for, andpermission_sets::include's reading. The host's policy stays its own:Permissions(now a wrapper overScopes),covers, narrowing to the roles, permission sets, and making a token's scope concrete.Behaviour. Following the reference where the host differed:
repo:C?action=upsert, whose unknown action was dropped before), a parameter its resource doesn't take, a value it takes once named twice, a collection that isn't an NSID, anrpc:audience with no#service. Approval withholds it;createSpaceandupdateSpacerefuse such a policy permission.blob:a,bis no scope (it was read as both); an upload's type is compared as written (IMAGE/pngno longer passesblob:image/*). A token now keeps each blob scope as one scope per type, lowercase, as atproto writes it (concrete, viascopes::blob_scopes).rpc:scope for the host's own methods names<host DID>#atgrpor*; the bare DID it took before is no audience.space?spaceType=Tis kept at approval asspace:Tis (space?type=was already not read).Tokens already issued. A migration rewrites each
oauth_tokenandoauth_requestscope once throughscopes::upgraded, whichStore::openhands SQLite asupgraded_scope(rusqlite'sfunctionsfeature): blob lists split and lowercased, unknown actions and parameters and repeated single values dropped, the host's own methods' bare audience given#atgrp. A scope that granted nothing before is left as written and still grants nothing.Docs.
docs/design/signing-in.mdgains "Reading a scope", and its own-method audience reads<host DID>#atgrp. Change file: patch.Why
Group-host, pds.js and the reference each read scopes a little differently; one implementation, held by atproto to the reference's fixtures, ends that. The reference's verdicts are taken where they differ, and existing grants are migrated rather than read with the old grammar forever: the old reading survives only as the one-time
legacyrewrite.How it was checked
scopes::tests::reads_every_scope_the_host_writes) collects every form the host writes, into tokens and roles' records: each action's scope (rbac::scope_of), each of its five permission sets' scopes and concrete form, a group session's (scopes_for,own_scopes), an invite's, another app's set (included), an app password's, and narrowing's own space forms. Each parses as a scope of its kind, and the migration leaves it as it is. The forms earlier versions wrote (from the git history ofconcrete,scopes_of,group_tokens) are the same shapes, with NSIDs and DIDs as values; none usedtype=or a bare audience.a_token_from_before_keeps_what_its_scope_granted(tests/tokens.rs) rewinds a database to before the migration with a token holding every legacy form, upgrades it, and checks the rewritten scope and what it grants.reads_a_scope_as_atproto_has_it,reads_a_scope_as_covered_by_those_held(rpc audiences with#svc; patterns,transition:generic),reads_a_space_scope,unions_a_roles_writes, rbac fixtures' two-segment collections made NSIDs, and the own-method audience test now names#atgrp.cargo clippy -p group-host --all-targets -D warnings,cargo fmt --check, and the lib, tokens, oauth_scope, members, rbac, proxy, group_tokens and group_spaces tests. The full suite, the coverage gate and e2e are left to CI.Shortcomings
atgrpwrite only forms that read the same.manage=, managed spaces before; it's left as written and now grants nothing, as atproto can't write a space scope with no action.repo:scope that is no scope (it gave the known actions before).%in a value bare, so an audience on adid:webwith a port (localhost%3A…) only reads back if escaped twice; real hosts have none.Review
The design of
coversover typed scopes (scopes.rs) and the migration'slegacyrewrite are where to look.