Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.
This repository was archived by the owner on Jun 11, 2026. It is now read-only.

[Authorization] Create OwnershipRule #66

@Shifrin

Description

@Shifrin

Goal

Implement the most common conditional access pattern: a subject may only act on resources they own. This rule compares AuthorizableResource::ownerId() against AuthorizationSubject::subjectId(). If the resource has no owner concept (ownerId() returns null) the rule passes unconditionally — it is not this rule's responsibility to enforce ownership where no ownership model exists. This built-in rule ships with the framework so extension developers do not need to rewrite it.

Methods

  • isSatisfied(AuthorizationSubject $subject, AuthorizableResource $resource): bool

Acceptance criteria

  • Class lives at src/Authorization/Infrastructure/Rules/OwnershipRule.php
  • Implements Rule interface
  • Returns true when ownerId() is null (no ownership concept on this resource)
  • Returns true when ownerId() === subjectId()
  • Returns false when ownerId() is set and does not match subjectId()
  • PHPStan level 8 passes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    On Hold

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions