api-platform-security — скилл для Claude Code: установка и суть
Скилл api-platform-security настраивает правила доступа в Symfony API Platform через выражения security, воутеры и хуки жизненного цикла операций.
MIT ★ 234 обновлён 2026-10-05
npx skills add dev-toolings/superpowers-symfony --skill api-platform-security -a claude-codeЧто делает api-platform-security
Скилл помогает ограничить доступ к операциям сущностей API Platform. Он выстраивает проверку прав на уровне отдельных ресурсов: связывает вызовы is_granted() с контекстом текущего пользователя и объекта, а сложные условия выносит в отдельные воутеры Symfony.
В работу включена цепочка проверок жизненного цикла запроса. Для проверки входящих данных применяются securityPostDenormalize и securityPostValidation, а видимость строк в коллекциях ограничивается через QueryCollectionExtensionInterface или стейт-провайдеры, а не через простые выражения security.
Хелпер access_decision() в Twig и метод getAccessDecision() требуют Symfony 8.1 или новее: на старых версиях фреймворка этот код вызовет сбой. Секретные поля вроде паролей по правилам скилла закрываются атрибутом #[Ignore].
Какие задачи решает
- Разграничить права на вызов операций API Platform для ролей и владельцев сущностей
- Фильтровать строки в коллекциях через расширения Doctrine без блокировки всего эндпоинта
- Скрыть конфиденциальные поля ресурса с помощью групп сериализации
- Сгенерировать тесты разрешённого, запрещённого и анонимного доступа к API
Примеры запросов агенту
- Ограничь операцию PATCH ресурса Order так, чтобы её мог вызвать только владелец заказа
- Настрой QueryCollectionExtensionInterface для сущности Invoice, чтобы менеджер видел только свои счета
- Перенеси сложную логику проверки прав из аннотаций ресурса в отдельный Symfony Voter
Как установить api-platform-security
1Через Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-security -a claude-code2Вручную: положить файлы
~/.claude/skills/api-platform-security/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/api-platform-security/
1Через Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-security -a codex2Вручную: положить файлы
.agents/skills/api-platform-security/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-security -a cursor2Вручную: положить файлы
.cursor/skills/api-platform-security/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install dev-toolings/superpowers-symfony content/skills/api-platform-security2Вручную: положить файлы
.github/skills/api-platform-security/SKILL.md1Через Skills CLI (Vercel)
npx skills add dev-toolings/superpowers-symfony --skill api-platform-security -a gemini-cli2Командой платформы
gemini skills install https://github.com/dev-toolings/superpowers-symfony --path content/skills/api-platform-securityВручную: положить файлы
.devin/skills/api-platform-security/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Claude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы об api-platform-security
Как установить api-platform-security в Claude Code?
Выполните команду npx skills add dev-toolings/superpowers-symfony --skill api-platform-security -a claude-code в терминале проекта.
Что делает скилл api-platform-security?
Он задаёт шаблоны и правила защиты ресурсов API Platform: настраивает воутеры, разграничивает операции и фильтрует выдачу коллекций.
Почему нельзя фильтровать коллекции через security-выражения?
Выражение security проверяет доступ ко всей коллекции разом. Чтобы скрыть отдельные строки для разных ролей, требуется использовать расширения запросов или стейт-провайдеры.
Исходный текст
SKILL.md · MIT
---
name: api-platform-security
description: Secure API Platform resources with security expressions, voters, securityPostValidation, and operation-level access control
capabilities: [read, search, edit, shell]
tags: [api-platform, security]
# projected by `bun run build` — do not edit by hand
allowed-tools:
- Read
- Glob
- Grep
- Write
- Edit
- Bash
---
# Api Platform Security (Symfony)
## Use when
- Restricting who may call each operation of an API Platform resource.
- Authorization depends on the object (owner) or on the submitted data.
- Users must see only a subset of a collection.
- Fields must be hidden depending on role or ownership.
## Default workflow
1. Set `security` per operation with `is_granted()`, `object`, and `user`, plus a `securityMessage`.
2. Move complex rules into voters: `is_granted('POST_EDIT', object)`.
3. When the rule depends on input, use `securityPostDenormalize`, or `securityPostValidation` to run after the Validator.
4. Scope rows with a `QueryCollectionExtensionInterface` (and `QueryItemExtensionInterface`) or a state provider.
5. Hide fields with serializer groups and a decorated context builder, and guard the firewall with `access_control`.
6. Test both the grant and the deny case for every protected operation.
## Guardrails
- Never filter rows with a `security` expression on a collection: it gates the whole collection, it does not scope it.
- Order of checks: `security`, denormalization, `securityPostDenormalize`, validation, `securityPostValidation`.
- `previous_object` exists only in `securityPostDenormalize`, and `request` only at resource level.
- Deny by default and mark secrets such as `password` with `#[Ignore]`.
- `getAccessDecision()` and the Twig `access_decision()` helper need Symfony 8.1 or later: verify before using them.
## Progressive disclosure
- Use this file for execution posture and risk controls.
- Open references when deep implementation details are needed.
## Output contract
- The security expression and message per operation, and the voters involved.
- How collections and fields are scoped per user.
- Tests covering allowed, forbidden, and anonymous access.
## References
- `reference.md`
© dev-toolings · MIT · dev-toolings/superpowers-symfony