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

Approval keeps reading a space the group has yet to make

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:oauth/read-spaces-to-come

What changes

Approval keeps a scope that only reads spaces of a type, space:T?action=read (or of a type and key), where the group has no such space yet. Before, narrow kept such a scope only if a space of type T already existed and the roles read it, and withheld it otherwise. A scope that writes, or that reads a space the group already has and the roles don't read, is still withheld. signing-in.md's narrowing rules say so.

Why

A grant keeps its scope through every refresh. So an app approved before the group made a space could never read that space without a member approving it again. Grain hits this: it connects to a group with space:social.grain.group.pool?action=read. A group that makes its members-only pool after connecting, whether from Grain, atgrp space create or anything else, leaves Grain's session unable to read it. Grain is about to make that pool itself from its group page, as one approval that asks for manage=create with its reads. That only works if the same grant reads the pool it then makes.

Keeping the read scope gives nothing ahead of time. getDelegationToken still checks that the member reads the space at that moment, under its policy then. So the scope reads nothing its member doesn't, and nothing at all until the group makes the space. The other way, making the app ask again once the space exists, puts the member through a second approval for something the first already said.

How it was checked

  • oauth_scope.rs: keeps_a_space_scope_a_spaces_policy_grants now expects a read of a calendar key the group lacks, and of a type it has no space of, to be kept. It still expects a write to a space not yet made to be withheld, and a read of a space whose policy keeps it from the role (poster) to be withheld.
  • tokens.rs: reads_a_space_the_group_made_after_approving_its_session approves an app for space:com.example.forum?action=read as Bob before the group has a forum. Then it makes one that members read, and buys a credential for it with that session's delegation.
  • Not built or run here; the test check runs them under the gate.

Shortcomings

Grants already made keep the scope they were given. An app reads a space made since only once a member approves it again.

Approved

The pull makes narrow keep a read-only space:T?action=read scope, with or without a key, when the group has no space of that type and key yet. When such a space exists, the old policy check still applies. I found no defects.

  • What stays withheld: writes to a space not yet made, and reads of an existing space the roles can't read. rooms lists all of the group's spaces, not only readable ones, so the poster case still falls to the policy check.
  • Foreign authority: the for_group filter runs before this branch, so a scope naming another authority never reaches it.
  • Safety: each credential still checks that the member reads the space at that moment, so the kept scope grants nothing extra.
  • Tests and docs: the oauth_scope test is updated, the new tokens.rs end-to-end test covers the Grain case, and the change file and signing-in.md are updated as AGENTS.md asks.
  • Not run: I didn't run the tests, and the pull says it didn't either.
Merged as 7bcc3ec