Dynamic permissions callbacks classes must implement an interface

Created on 24 September 2015, over 9 years ago
Updated 2 June 2025, 10 days ago

Problem/Motivation

Working on #2571235: [regression] Roles should depend on objects that are building the granted permissions β†’ I realized that callbacks that provides permissions are not necessary part of a class implementing a dedicated interface. If we want to provide also dependencies along with permissions (see #2571235: [regression] Roles should depend on objects that are building the granted permissions β†’ ) it would be nice to create some laws on how dynamic permissions are provided.

Proposed resolution

  1. Add a new interface for classes providing dynamic permissions:
    interface DynamicPermissionsInterface {
      public function getPermissions();
      public function calculateDependencies();
    }
    

    .

  2. In *.permissions.yml specify the class, instead of the callback.
  3. Rework \Drupal\user\PermissionHandler::buildPermissionsYaml() to enforce the usage of classes implementing the new interface and use the ->getPermissions() method instead of the previously callback.
  4. Provide dependencies and handle them to keep the system integrity.

Remaining tasks

New interface DynamicPermissionsInterface.

User interface changes

API changes

Data model changes

✨ Feature request
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

user system

Created by

πŸ‡·πŸ‡΄Romania claudiu.cristea Arad πŸ‡·πŸ‡΄

Live updates comments and jobs are added and updated live.
  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for sharing your idea for improving Drupal.

    We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • πŸ‡¬πŸ‡§United Kingdom joachim

    This issue is still relevant.

Production build 0.71.5 2024