Repository navigation
Conversation
Apps register their resource types and permissions, other apps register restriction providers. The app owning a resource asks the permission manager which permissions are left for an actor and enforces the result. Permissions are boolean and every app permission is a kind of one core permission, so restricting a core permission also restricts permissions the restricting app does not know. Access entries allow to restrict only the access gained through one recipient, e.g. a team. Assisted-by: ClaudeCode:claude-fable-5-2 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Results are kept in a capped cache that restriction providers clear when their restrictions change, so long-running processes neither keep stale results nor grow without limit. A restriction provider that cannot be loaded now restricts everything, like a provider that throws. The permissions that apply to a resource type are read once per check instead of once per resource. Assisted-by: ClaudeCode:claude-fable-5-2 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Assisted-by: ClaudeCode:claude-fable-5-2 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
| * @experimental 36.0.0 | ||
| */ | ||
| #[Consumable(since: '36.0.0')] | ||
| final readonly class ResourceAccess { |
There was a problem hiding this comment.
basically data object pattern here, this makes scoping easier, but we could get rid of this if we just pass e.g. an assoc. array "resource => entries" but I do not really like that idea.
(we need this at least until everything uses unified sharing thus we would only need the resource and the actor, but until then we need resource and potentially multiple entries to let restrictors know about origin)
…rectly `EffectivePermissions::isAllowed()` now also accepts a `CorePermission` case, so callers no longer need `->value` for the core permissions, and the allowed IDs are kept as a map for constant time lookups. Also document why `CorePermission::DOWNLOAD` is a constant and not a case. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
| /** | ||
| * @experimental 36.0.0 | ||
| */ | ||
| public function getResourceType(string $id): ?IResourceType; |
There was a problem hiding this comment.
Maybe this and getResourceTypes could go into another manager (e.g. IResourceManager) since permissions are a component of resources and not the other way around and may require further additions that may not fit into this manager. But TBF this could also be done later, so this is a non-blocker for me.
There was a problem hiding this comment.
Agree its maybe nice to have but not a blocker, I think we should first see if this covers all needs and add it if needed or once we move to OCP and think its still cleaner?
| * @experimental 36.0.0 | ||
| */ | ||
| public function __construct( | ||
| public ResourceReference $resource, |
There was a problem hiding this comment.
suggestion: thinking whether we should also add a reference to the actor the access refers to. This was the object can be used as-is in different places where keying-by the actor would be awkward because of the added need to track access ownership.
Summary
Apps register their resource types and permissions, other apps register restriction providers. The app owning a resource asks the permission manager which permissions are left for an actor and enforces the result.
Permissions are boolean and every app permission is a kind of one core permission, so restricting a core permission also restricts permissions the restricting app does not know. Access entries allow to restrict only the access gained through one recipient, e.g. a team.
Example usage
Example usage how it can be used directly with this PR:
Details
sequenceDiagram autonumber actor U as Alice (browser) participant T as Tables app participant M as IPermissionManager participant G as Governance (restriction provider) rect rgba(128, 128, 128, 0.12) Note over T,G: Boot, once per process T->>M: registerResourceType(TableResourceType) T->>M: registerResourcePermission(ExportPermission) G->>M: registerResourceRestrictionProvider(LabelRestrictionProvider) end rect rgba(128, 128, 128, 0.12) Note over U,G: Alice opens her list of tables U->>T: GET /tables T->>T: load tables and the shares that give Alice access T->>M: checkAll(Actor of Alice, tables + access entries) M->>G: getRestrictions(actor, all tables) G-->>M: table 7: core:download restricted (label "Internal") M-->>T: EffectivePermissions per table T-->>U: tables with their allowed permissions Note over U: Download is hidden for table 7 end rect rgba(128, 128, 128, 0.12) Note over U,G: Alice calls the download endpoint anyway U->>T: GET /tables/7/download T->>M: check(Actor of Alice, table 7, access entries) Note over M: answered from the cache M-->>T: EffectivePermissions T->>T: isAllowed("core:download") is false T-->>U: 403 Forbidden end rect rgba(128, 128, 128, 0.12) Note over U,G: Later the label is removed from table 7 G->>M: clearCache() U->>T: GET /tables/7/download T->>M: check(Actor of Alice, table 7, access entries) M->>G: getRestrictions(actor, table 7) G-->>M: no restrictions M-->>T: EffectivePermissions T-->>U: 200, the file endIn a follow up we can make it integrated with Interaction API:
Details
sequenceDiagram autonumber actor U as Alice (browser) participant T as Tables app participant I as Interaction API participant L as Core listener (new) participant M as IPermissionManager participant G as Governance U->>T: share table 7 with a receiver T->>I: RestrictInteractionEvent(actor, table 7, action "core:share", receivers) I->>L: dispatch L->>M: check(actor, table 7) M->>G: getRestrictions(actor, table 7) Note over M,G: skipped when the answer is cached G-->>M: restrictions from labels M-->>L: EffectivePermissions alt core:share is restricted L-->>I: throws InteractionRestrictedException I-->>T: restricted, with a hint T-->>U: 403 with the hint Note over G: Governance wrote no listener for this else core:share is allowed L-->>I: no objection I->>G: dispatch to the receiver listener alt receiver breaks a rule, e.g. external receiver on an "Internal" label G-->>I: throws InteractionRestrictedException I-->>T: restricted, with a hint T-->>U: 403 with the hint else receiver is fine G-->>I: no objection I-->>T: allowed T->>T: create the share T-->>U: 201 Created end end Note over I: every outcome is written to the audit log, as todayAnd also a follow up to integrate unified sharing is planned:
Details
sequenceDiagram autonumber actor U as Alice (browser) participant T as Tables app participant M as IPermissionManager participant S as Unified sharing participant G as Governance (provider) participant C as Circles (provider) participant I as Interaction API rect rgba(128, 128, 128, 0.12) Note over U,C: Alice opens table 7. Tables passes only the resource. U->>T: GET /tables/7 T->>M: check(actor, table 7) M->>S: shares on table 7 that apply to Alice? S-->>M: share 42 to team Sales: read, update · share 17 to Alice: read Note over M: shares become access entries (team Sales, user Alice) M->>G: getRestrictions(actor, table 7 + entries) G-->>M: core:download restricted for the resource M->>C: getRestrictions(actor, table 7 + entries) C-->>M: nothing, Alice is a full member of Sales M-->>T: allowed: read, update T-->>U: table 7 with its allowed permissions end rect rgba(128, 128, 128, 0.12) Note over U,I: Alice shares table 7 with Bob. Tables is not involved. U->>S: create share on table 7 for Bob with read, update S->>M: check(actor, table 7) M-->>S: allowed: read, update (from the cache) Note over S: Alice can grant at most what she is allowed herself S->>I: RestrictInteractionEvent(actor, table 7, action "core:share", receiver Bob) Note over I: core listener and receiver listeners, as in the previous diagram I-->>S: allowed S->>S: store the share with permission IDs S-->>U: 201 Created endEntities of this design
Owning app
Mail, Tables, later Files
Core
The new API
Restricting app
Governance, later Circles
Checklist
3. to review, feature component)stable32)AI (if applicable)