api-platform-user
Skill2 starsChanged 6 months agoMITView on GitHub
Implement the canonical API Platform 4.3 + Symfony 7.4+ User entity — `User implements UserInterface, PasswordAuthenticatedUserInterface`, `#[UniqueEntity('email')]`, a transient `$plainPassword` validated only on `user:create`, the persisted hashed `$password` excluded from every serialization group, a `UserPasswordHasher` State Processor decorating `api_platform.doctrine.orm.state.persist_processor` to hash on POST/PUT/PATCH + nuke `plainPassword` from memory, a Repository implementing `PasswordUpgraderInterface` for automatic rehashing when the algorithm cost changes, and a `/me` endpoint backed by a `CurrentUserProvider` (Provider-based, REST + GraphQL compatible — not a custom controller). Includes the lightweight `md5` password hashing config for the test environment to speed the suite ×5. Trigger on "User entity", "password hashing", "/me endpoint", "registration", or "current user".
In this repository52 other files it gives its agents.
- api-platform-dto-resourcesSkill
- api-platform-errorsSkill
- api-platform-file-uploadSkill
- api-platform-filtersSkill
- api-platform-identifiersSkill
- api-platform-mcpSkill
- api-platform-mutatorsSkill
- api-platform-openapiSkill
- api-platform-paginationSkill
- api-platform-performanceSkill
- api-platform-resilienceSkill
- api-platform-resourcesSkill
- api-platform-securitySkill
- api-platform-serializationSkill
- api-platform-state-processorsSkill
- api-platform-state-providersSkill
- api-platform-testsSkill
- api-platform-upgradeSkill
- api-platform-versioningSkill
- bootstrap-checkSkill
- brainstormingSkill
- config-env-parametersSkill
- controller-cleanupSkill
- cqrs-and-handlersSkill
- daily-workflowSkill
- doctrine-batch-processingSkill
- doctrine-fetch-modesSkill
- doctrine-fixtures-foundrySkill
- doctrine-migrationsSkill
- doctrine-relationsSkill
- doctrine-transactionsSkill
- effective-contextSkill
- executing-plansSkill
- functional-testsSkill
- interfaces-and-autowiringSkill
- makefile-disciplineSkill
- messenger-retry-failuresSkill
- ports-and-adaptersSkill
- quality-checksSkill
- rate-limitingSkill
- runner-selectionSkill
- strategy-patternSkill
- symfony-cacheSkill
- symfony-messengerSkill
- symfony-schedulerSkill
- symfony-votersSkill
- tdd-with-pestSkill
- tdd-with-phpunitSkill
- test-doubles-mockingSkill
- using-symfony-superpowersSkill
- value-objects-and-dtosSkill
- writing-plansSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 24
Write the UserPasswordHasher State Processor that decorates persist_processor and hashes $plainPassword, then nukes it from memory.
- Very specific: line 26
Add the /me endpoint via a CurrentUserProvider (Provider-based, REST + GraphQL compatible).
- Distinctive: line 34
Hash-light in tests: only — never in any other environment.
- Very specific: line 45
Test-only password hashing config in config/packages/test/security.yaml.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API Platform 4.3 — User entity (UserInterface, password hashing, /me)
Use when
- Bootstrapping a new project that needs authenticated users.
- Adding registration (
POST /api/usersopen) + self-profile updates (PUT /api/users/{id}constrained toobject == user). - Exposing the current authenticated user via
/me. - Adopting auto-rehashing when the password hashing algorithm evolves.
Default workflow
- Implement
User implements UserInterface, PasswordAuthenticatedUserInterface. Persist$password(hashed), keep$plainPasswordtransient. - Apply
#[UniqueEntity('email')]+Default+user:createvalidation context on the POST operation. - Write the
UserPasswordHasherState Processor that decoratespersist_processorand hashes$plainPassword, then nukes it from memory. - Implement
PasswordUpgraderInterfacein the Repository for transparent rehashing. - Add the
/meendpoint via aCurrentUserProvider(Provider-based, REST + GraphQL compatible). - Configure
md5hashing only inconfig/packages/test/security.yamlto speed the test suite ×5.
Guardrails
$passwordis NEVER in a serialization group. It must not appear in any response.$plainPasswordis NEVER persisted (no#[ORM\Column]), only validated onuser:create.- Hashing in the Processor, not in the controller — that's the canonical 4.x pattern.
/mevia Provider, not Controller — for REST + GraphQL compatibility.- Hash-light in tests only — never in any other environment.
Progressive disclosure
SKILL.mdcovers posture and rules.reference.mdcarries the full entity, Processor, Repository withPasswordUpgraderInterface,/meProvider, test hashing config, and best practices.
Output contract
- A
Userentity following the canonical pattern. - A
UserPasswordHasherProcessor that hashes and nukes$plainPassword. - A
UserRepository implements PasswordUpgraderInterfacefor auto-rehashing. - A
/meendpoint backed byCurrentUserProvider. - Test-only password hashing config in
config/packages/test/security.yaml.
References
reference.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

