create-access-control
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-access-control":https://skillpi.com/zh/skills/deepskill-1d532f3a4049659280b9afa0d08268ee67cb145d5b9a6457d67f1a00b9167b92。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 PHP 8.4 生成访问控制组件:创建基于 RBAC/ABAC 的访问控制构件,包含 PermissionInterface、RoleInterface、VoterInterface 和 AccessDecisionManager,并附带单元测试。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
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/
Permission.php— Permission enumRole.php— Role value object with hierarchyAccessSubject.php— Value object wrapping the authenticated user context
Step 2: Generate Voter System
Path: src/Infrastructure/Security/AccessControl/
VoterInterface.php— Voter contract with GRANT/DENY/ABSTAINVote.php— Vote result enumAccessDecisionManager.php— Voter aggregation with strategiesDecisionStrategy.php— Strategy enum (affirmative, unanimous, consensus)
Step 3: Generate Concrete Voters
Path: src/Infrastructure/Security/AccessControl/Voter/
RoleVoter.php— Role hierarchy voterResourceOwnerVoter.php— Resource ownership voter
Step 4: Generate Tests
RoleTest.php— Role hierarchy testsAccessDecisionManagerTest.php— Strategy decision testsRoleVoterTest.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 templatesreferences/examples.md— Authorization examples and tests
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 为 PHP 8.4 生成完整的 RBAC/ABAC 访问控制组件,解决实际开发中的权限管理痛点
- 包含 PermissionInterface、RoleInterface、VoterInterface、AccessDecisionManager 等核心接口与实现
- 提供多种决策策略(affirmative/unanimous/consensus)和具体 Voter 实现(RoleVoter、ResourceOwnerVoter)
- 包含单元测试,确保组件可靠性
亮点
- 触发词精准完整,明确描述生成 PHP 8.4 访问控制组件,包含 RBAC/ABAC 和具体接口
- 边界清晰,覆盖多种授权场景(角色、资源所有权、属性规则)
待提升项
-
文档过长 原报告严重程度:轻微
文档内容约600行,超出建议的单文件500行限制
改进建议:考虑将部分模板代码或详细说明拆分到引用文件中,保持主文档简洁
亮点
- 结构清晰,分 When to Use、Component Characteristics、Generation Process 等章节
- 步骤划分明确(Step 1-4),有端到端示例和模板代码
- frontmatter 完整,包含 name 和 description
亮点
- 提供完整的 PHP 模板和结构说明,逻辑自洽
- 包含多种决策策略和具体 Voter 实现,覆盖主要使用场景
- 文档中提供了 Anti-patterns 指导,帮助用户避免常见错误
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。