Problem/Motivation
#3059984: Add new “Content Editor” role to Standard Profile added a new role with permissions for modules that not installed. We've removed them in #3221258: Fix content editor role to only have permissions that exist - however this affects how useful the role is.
Let's decide how to add the permissions to role when modules are installed in a way allowed by #2571235: [regression] Roles should depend on objects that are building the granted permissions.
Proposed resolution
When a core recipe enables a module, include permissions from that module for the content_editor role, if any, that were included in #3059984 and removed in #3221258.
Here are some options that were suggested before recipes were available:
- Add standard_hook_modules_installed() to do the work (I think this is the better solution)
- Add a new key to the role config entity to permissions_to_install
- Make modules part of the standard install
Remaining tasks
- Add permissions for the
content_translationmodule. - Add permissions for the
mediamodule.
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3221259
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wim leersPer #3059984-63: Add new “Content Editor” role to Standard Profile, tagging .
Comment #3
aaronmchaleRe-posting my comment #3221258-4: Fix content editor role to only have permissions that exist here as it's relevant here as well:
Comment #4
larowlanThis issue wont be unique to standard
So if the quick fix is remove those permissions and then focus on a real API for optional permissions, +1 to that
I've made my thoughts on standard profile known, so not repeating them here
Comment #5
berdirSome of the modules make sense to have in standard, e.g. media. That topic has been held up on some UX discussions and a migration, which I think is not even desirable, not automated anyway. standard should never do anything to existing sites, and solely exist as a starting point for new sites.
But other modules will definitely not every be added to standard. Everything around translation for example, that by design only makes sense as soon as you have multiple languages.
So yes, a generic concept of optional permissions is interesting, but that's a layer of optional config that we haven't explored yet at all..
Comment #6
aaronmchaleI'm starring to see an interesting feature proposal here for "suggested permissions", I think "optional" is probably the wrong word for this. So when you install a module it can suggest sets of permissions that you might want to give to specific roles.
Comment #7
berdirThat's a slightly different use case though, because we're still talking about standard.module suggesting to do something when you install media. The module module can't do that itself, because it must not have any knowledge of the content editor role, only standard profile knows that. Other install profiles/sites might have similar roles, but they will have different names.
Comment #8
aaronmchaleYeah that's fair, when I wrote that I had in mind a discussion that came up at a UX Call when we were looking at #2919636: Design a better model for managing permissions, which then spawned the issue #3216341: Provide a module-specific permissions form.
Comment #12
pasqualleAs I see this will be a major issue for distributions.
To solve the missing permissions I would expect something like this:
profiles/standard/config/optional/user.role_permissions.content_editor.media.yml
profiles/standard/config/optional/user.role_permissions.content_editor.media.image.yml
In ideal case permissions should be even removed from the
user.role.<role_name>config.Comment #13
berdirIt's fairly easy to work around this, you don't need a fancy API. Just implement hook_modules_installed(), check for module X, if being installed, grant the desired permissions to the role you want.
Comment #14
pasqualleYes, sure, but I prefer to have config in yaml files, not in PHP code. To easily track config changes.
Comment #18
benjifisherNow that The Recipe Initiative APIs have been added to core as experimental, we have a new option for solving this problem. We can use a recipe to install a module and add permissions from that module to existing roles, such as the
content_editorrole.MR 9651 provides a proof of concept: it adds
recipe.ymlto thecontent_moderationmodule. The recipe does the following steps:content_moderationmodule.editorialworkflow) from thestandardprofile.content_editorrole.Now, I have the option of installing the module or applying the recipe. Using Drush, the two options are
drush en content_moderationdrush recipe core/modules/content_moderationOf course, any other recipe that wants to install the module can apply the recipe instead.
I do not have any other examples in mind, but I suspect that there are many modules that can benefit from the same approach.
Comment #2 added the "Security improvements" issue tag. I think the security improvement was already done by the related issue #3221258: Fix content editor role to only have permissions that exist, so I am removing the tag from this issue.
Comment #19
benjifisherComment #20
thejimbirch commentedYou could simplify the recipe a bit by using standard's editorial_workflow also so you also get the optional views.view.moderated_content config which you aren't importing currently.
Comment #21
benjifisherThanks for that suggestion. I did not realize that
core/recipes/had any recipes beyond what thestandardprofile uses.Another option is to add these permissions in the
editorial_workflowrecipe or in a new recipe undercore/recipes/.Either way, we should probably add a dependency on the
content_editor_rolerecipe.Comment #22
smustgrave commentedCan the issue summary be updated as well please.
Comment #23
benjifisherComment #24
benjifisherI am updating the Proposed resolution in the issue summary (and making minor edits to the rest).
Comment #25
benjifisherI updated the MR to add the permissions in the existing
editorial_workflowsrecipe.In Comment #21, I wrote,
I see now that this recipe was created as a place to put the optional configuration
workflows.workflow.editorialfrom thestandardprofile. Since the permissions I am adding depend on theworkflowstransitions defined in that configuration entity, I think it is a good idea to put the permissions and the config in the same recipe.I would like further review of this issue, but I am leaving the status at NW because there are other permissions from other modules that I want to add.
Comment #26
benjifisherLooking at #3221258: Fix content editor role to only have permissions that exist, these are the permissions that were removed, grouped by module:
Core modules
content_moderationuse editorial transition archiveuse editorial transition archived_draftuse editorial transition archived_publisheduse editorial transition create_new_draftuse editorial transition publishview any unpublished contentview latest versioncontent_translationcreate content translationsdelete content translationsupdate content translationsmediaaccess media overviewcreate mediadelete mediaupdate mediaview all media revisionsview own unpublished mediaContrib modules that used to be part of core
aggregatoraccess news feedsbookaccess printer-friendly versionadd content to bookscreate new booksnodemodule, if thebookcontent type is defined (optional config in thebookmodule)delete own book contentedit own book contentdelete book revisionscreate book contentstatisticsview post access counterMR 9651 already handles the permissions from the
content_moderationmodule. It should also handle permissions from thecontent_translationandmediamodules. We might need new recipes for these: none of the core recipes enable either of these modules directly. The*_media_typerecipes enablemediaindirectly (by enabling themedia_librarymodule). Perhaps one of the core recipes enablescontent_translationindirectly, but I do not think so.What about the
aggregator,book, andstatisticsmodules? (These modules were in Drupal core when thecontent_editorrole was created, but have since been removed.) One option is to create separate projects on d.o with recipes for each. If we consider letting modules define their own recipes, as I suggested in Comment #18, then we could add recipes to those contrib modules and add the permissions in those recipes.Comment #27
thejimbirch commentedModules can’t provide recipes. Recipes need to be their own packages and kept in a single folder suggested to be above web root.
Core recipes location is the only exception.
This is so the recipe runner knows where to look for dependent recipes.
Modules also can contain recipes as there would be conflicts with the config folder as recipes and modules have different needs and structures.
Comment #28
benjifisherWe discussed this issue briefly at #3477161: Drupal Usability Meeting 2024-10-04. That issue will have a link to a recording of the meeting.
@rkoller pointed out that I should consider the recipes in https://git.drupalcode.org/project/drupal_cms as well as the core recipes. In particular, the
drupal_cms_multilingualrecipe already enables thecontent_translationmodule and adds permissions to thecontent_editorrole. Probably nothing more has to be done for that module. I have not yet looked for recipes that enable themediamodule.For the record, the attendees at the usability meeting were AaronMcHale, avani.bhut, benjifisher, rkoller, shaal, simohell, and zetagraph.