When Roles Aren’t Enough: Modern Permissions in Drupal with the Access Policy API
summary
Drupal 10.3 ships a core Access Policy API (originating from Group work in 2020, merged to core 2024) that hands out or strips permissions outside roles by registering tagged services that implement calculatePermissions / alterPermissions. Examples show an entity-query-based contest-winner -> buy VIP tickets policy and a security-training policy that revokes create/edit when stale. Policies require correct cache tags, cache contexts, cache max-age and can inject services; they centralize contextual rules (time, user attributes, entity values) without role explosion.
AI-written summary · about
chapters (11)
- 0:00Introduction to Access Policy API
- 1:27Limitations of Drupal roles
- 6:42Roles can't handle context
- 10:14When to use Access Policy API
- 11:16Brief history of the API
- 12:25How Access Policy API works
- 18:24Demo: Contest winner access policy
- 24:52Demo: Security training validation
- 31:55Should you use the Access Policy API?
- 34:26Final thoughts and resources
- 39:49Q&A session
