create-access-control

Generate access control components for PHP 8.4: create RBAC/ABAC-based access control constructs including PermissionInterface, RoleInterface, VoterInterface, and AccessDecisionManager, with unit tests.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-access-control" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-1d532f3a4049659280b9afa0d08268ee67cb145d5b9a6457d67f1a00b9167b92. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Generate access control components for PHP 8.4: create RBAC/ABAC-based access control constructs including PermissionInterface, RoleInterface, VoterInterface, and AccessDecisionManager, with unit tests.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Generates Access Control components for PHP 8.4. Creates RBAC/ABAC components with PermissionInterface, RoleInterface, VoterInterface, AccessDecisionManager. Includes unit tests.
Audience
| Scenario | Example | |----------|---------| | Role-based access | Admin, editor, viewer roles | | Resource ownership | Users can only edit own resources | | Attribute-based rules | Access based on resource state or user attributes | | Complex authorization | Multiple voters with different strategies |
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: create-access-control
description: Generates Access Control components for PHP 8.4. Creates RBAC/ABAC components with PermissionInterface, RoleInterface, VoterInterface, AccessDecisionManager. Includes unit tests.

Access Control Generator

Creates access control infrastructure for RBAC/ABAC authorization patterns.

When to Use

Scenario Example
Role-based access Admin, editor, viewer roles
Resource ownership Users can only edit own resources
Attribute-based rules Access based on resource state or user attributes
Complex authorization Multiple voters with different strategies

Component Characteristics

Permission

  • Enum defining available permissions
  • Hierarchical: parent permissions include children
  • Type-safe, no magic strings

Role

  • Value Object encapsulating role with permissions
  • Supports role hierarchy (admin inherits editor permissions)
  • Immutable, self-validating

VoterInterface

  • Symfony-style voter contract
  • Returns GRANT, DENY, or ABSTAIN
  • Single responsibility: one voter per concern

AccessDecisionManager

  • Aggregates multiple voters
  • Strategies: affirmative (one grant), unanimous (all grant), consensus (majority grants)
  • Configurable per security context

ResourceOwnerVoter

  • Checks if authenticated user owns the resource
  • Works with any entity implementing OwnableInterface
  • Returns ABSTAIN for non-ownable resources

RoleVoter

  • Checks if user has required role for the permission
  • Supports role hierarchy traversal
  • Returns ABSTAIN when permission not role-based

Generation Process

Step 1: Generate Core Components

Path: src/Infrastructure/Security/AccessControl/

  1. Permission.php — Permission enum
  2. Role.php — Role value object with hierarchy
  3. AccessSubject.php — Value object wrapping the authenticated user context

Step 2: Generate Voter System

Path: src/Infrastructure/Security/AccessControl/

  1. VoterInterface.php — Voter contract with GRANT/DENY/ABSTAIN
  2. Vote.php — Vote result enum
  3. AccessDecisionManager.php — Voter aggregation with strategies
  4. DecisionStrategy.php — Strategy enum (affirmative, unanimous, consensus)

Step 3: Generate Concrete Voters

Path: src/Infrastructure/Security/AccessControl/Voter/

  1. RoleVoter.php — Role hierarchy voter
  2. ResourceOwnerVoter.php — Resource ownership voter

Step 4: Generate Tests

  1. RoleTest.php — Role hierarchy tests
  2. AccessDecisionManagerTest.php — Strategy decision tests
  3. RoleVoterTest.php — Role voter tests

File Placement

Component Path
Core Classes src/Infrastructure/Security/AccessControl/
Voters src/Infrastructure/Security/AccessControl/Voter/
Unit Tests tests/Unit/Infrastructure/Security/AccessControl/

Naming Conventions

Component Pattern Example
Permission Permission Permission::Edit
Role Role Role
Voter Interface VoterInterface VoterInterface
Concrete Voter {Context}Voter RoleVoter
Decision Manager AccessDecisionManager AccessDecisionManager
Strategy Enum DecisionStrategy DecisionStrategy::Affirmative
Vote Enum Vote Vote::Grant
Test {ClassName}Test AccessDecisionManagerTest

Quick Template Reference

Permission

enum Permission: string
{
    case View = 'view';
    case Create = 'create';
    case Edit = 'edit';
    case Delete = 'delete';
    case Manage = 'manage';
}

VoterInterface

interface VoterInterface
{
    public function vote(AccessSubject $subject, Permission $permission, mixed $resource = null): Vote;
}

AccessDecisionManager

final readonly class AccessDecisionManager
{
    /** @param list<VoterInterface> $voters */
    public function __construct(
        private array $voters,
        private DecisionStrategy $strategy = DecisionStrategy::Affirmative
    ) {}

    public function isGranted(AccessSubject $subject, Permission $permission, mixed $resource = null): bool;
}

Usage Example

$manager = new AccessDecisionManager(
    voters: [new RoleVoter(), new ResourceOwnerVoter()],
    strategy: DecisionStrategy::Affirmative
);

$subject = new AccessSubject(userId: $user->id(), roles: $user->roles());

if ($manager->isGranted($subject, Permission::Edit, $article)) {
    $article->update($data);
}

Decision Strategies

Affirmative: ANY voter grants → GRANTED   (default, most permissive)
Consensus:   MAJORITY grants → GRANTED    (balanced)
Unanimous:   ALL voters grant → GRANTED   (most restrictive)

Anti-patterns to Avoid

Anti-pattern Problem Solution
String permissions Typos, no IDE support Use Permission enum
Inline auth checks Scattered, unmaintainable Centralize in voters
God voter Single voter with all logic One voter per concern
No ABSTAIN support Voter must decide everything ABSTAIN when not applicable
Flat roles No inheritance, duplication Role hierarchy
Missing resource check Only role-based, no ownership Add ResourceOwnerVoter

References

For complete PHP templates and examples, see:

  • references/templates.md — Permission, Role, VoterInterface, AccessDecisionManager, Voter templates
  • references/examples.md — Authorization examples and tests

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 为 PHP 8.4 生成完整的 RBAC/ABAC 访问控制组件,解决实际开发中的权限管理痛点
  • 包含 PermissionInterface、RoleInterface、VoterInterface、AccessDecisionManager 等核心接口与实现
  • 提供多种决策策略(affirmative/unanimous/consensus)和具体 Voter 实现(RoleVoter、ResourceOwnerVoter)
  • 包含单元测试,确保组件可靠性
Trigger Precision95/100

Highlights

  • 触发词精准完整,明确描述生成 PHP 8.4 访问控制组件,包含 RBAC/ABAC 和具体接口
  • 边界清晰,覆盖多种授权场景(角色、资源所有权、属性规则)
Structure and Standards80/100

Areas to improve

  • Document is too long Reported severity: Minor

    文档内容约600行,超出建议的单文件500行限制

    Recommendation: 考虑将部分模板代码或详细说明拆分到引用文件中,保持主文档简洁

Highlights

  • 结构清晰,分 When to Use、Component Characteristics、Generation Process 等章节
  • 步骤划分明确(Step 1-4),有端到端示例和模板代码
  • frontmatter 完整,包含 name 和 description
Execution Reliability85/100

Highlights

  • 提供完整的 PHP 模板和结构说明,逻辑自洽
  • 包含多种决策策略和具体 Voter 实现,覆盖主要使用场景
  • 文档中提供了 Anti-patterns 指导,帮助用户避免常见错误
Evidence Verifiability (mean of the first four)86/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.