Problem/Motivation
The semantics of 'administer own $type_id registration' and 'manage own $type_id registration' are very confusing.
"administer own $type_id registration"
'%type_name: Administer own registrations'
'View, edit and delete own registrations of this type. Manage registrations and registration settings of this type for host entities to which a user has edit access.'
"manage own $type_id registration"
'%type_name: Manage registrations for editable entities'
'Manage registrations of this type for host entities to which a user has edit access.'
Diagnosis
There are 2 problems here:
(1) I think most people would expect "managing registrations" to mean view, editing and deleting them. This would be similar to what "manage registration settings" means. But actually, manage registrations has a special meaning here: it means 'view the list of registrations for a host".
(2) The semantics of 'own' are very confused. In 'manage own $type_id registration' it means 'registrations that belong to a host you can edit'. In 'view own registrations' it means 'registrations that you are the registrant for'. In 'administer own $type_id registration' it means both, but for different things! You can view, edit and delete registrations you are the registrant for, but also control settings and view the registrations list for a host you can edit.
Proposed resolution
We should change the functioning of "administer own $type_id registration" so that it only addresses administering registrations the user is the registrant of; this can be done in a fully BC way by giving anyone who has it the "manage own $type_id registration" permission as well.
In follow-up issues:
- #3479435: Create 'manage host' and 'administer host' permissions
- #3493421: Remove "administer own $type_id registration settings" & "manage own $type_id registration"
Remaining tasks
User interface changes
None
API changes
Deprecated permission.
Data model changes
None.
Issue fork registration-3464704
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
jonathanshawComment #4
jonathanshawSo this is a simple fix, if one is willing to accept the change of behavior.
Comment #5
jonathanshawI think the fix I propose here is sound but wrong.
This permission is intrinsically confusing because of its name. Rather than fixing it to make it adhere to what we said it has been doing, but which it hasn't, lets take advantage of the fact that no one is relying on for its intended purpose, to simply kill it. Let's remove the permission, and replace it with an 'administer host registration' permission.
Comment #6
jonathanshawComment #7
jonathanshaw[deleted]
Comment #8
jonathanshawN.B. the docs for 'administer own $type_id registration' say 'Manage registrations and registration settings of this type for host entities to which a user has edit access.' Currently the code allows the user to administer the settings but not the registrations.
Comment #9
jonathanshawOne problem with removing 'administer own $type_id registration' altogether is that we still have 'manage own $type_id registration' so the odd semantic lingers on.
Comment #10
jonathanshawI'm finally understanding why this is so confusing. For 'administer own $type_id registration' the description is:
"View, edit and delete own registrations of this type. Manage registrations and registration settings of this type for host entities to which a user has edit access."
And this is in fact how it works.
What's confusing is that the semantic of own is effectively different in the 2 sentences of the description: in the first sentence "View, edit and delete own registrations" it means registrations that one is the registrant for; in the second sentence it means the same as it does for "manage own $type_id registrations", registrations for host entities you can edit.
Additionally confusing is that I would naively have understand 'Manage registrations' to mean being able to do things like view, update and edit registrations. But actually all it really means "is able to view the manage registrations route'.
So the code does match the docs, but what these permissions are doing is so weird that I've found it very hard to understand or believe.
Comment #11
jonathanshawUpdated the IS with new proposal now I understand this is not a bug per se.
Comment #12
jonathanshawComment #13
jonathanshawComment #14
john.oltman commented@jonathanshaw thanks for digging into this and sorry that it is confusing. What happened is I tried in my original port from D7 to keep the original permission names and meanings to the degree possible in a D9 context, to preserve the ability to easily migrate. Thus some confusion was created from the beginning, and then as requests to make things more granular came in, it snowballed. I would love to coordinate on a new structure for a future 3.5 or 4.x version of the module. Perhaps we can deal with the existing structure by creating a documentation page on d.org (I have an issue for this in the issue queue) to explain the nuances.
Comment #15
jonathanshawGreat, let's do it. I suggest we discuss on a messy way in this issue, and once we understand what's needed better, we can maybe make a new roadmap or subissues.
My current thinking is that we have 3 problematic permisisons:
"administer own $type_id registration"
"administer own $type_id registration settings"
"manage own $type_id registration"
We should create 2 new permissions to replace these:
"manage host registrations"
"administer host registrations"
We should change the functioning of "administer own $type_id registration" so that it only addresses administering registrations the user is the registrant of; this can be done in a fully BC way by giving anyone who has it the "manage own $type_id registration" permission as well.
We then need to get rid of "administer own $type_id registration settings" and "manage own $type_id registration". This is impossible to do in a fully BC way. Perhaps the best solution is to use hook_requirements to block upgrading the module if those permissions are still in use, forcing sitebuilders to take action.
I will have a look at it.
Comment #16
john.oltman commentedI wonder if we can close this and combine it into https://www.drupal.org/project/registration/issues/3479435
Comment #17
jonathanshawI think we should do this in this issue, before or after #3479435: Create 'manage host' and 'administer host' permissions:
And then we should create a new issue to discuss (and maybe implement but only after #3479435: Create 'manage host' and 'administer host' permissions) this:
So there's 3 separable issues here. We could combine, but I tend to assume seperating is better if possible.
Comment #18
jonathanshawComment #19
john.oltman commentedThanks @jonathan - this is basically ready - just a few minor nits in the tests. The above makes it look like a lot of work but it's basically the same issues that repeat and I wanted to be sure I flagged all the occurrences.
Comment #20
jonathanshawRe ManageRegistrationsAccessCheck
I don't think it's as simple as that. We would need to add a new scenario if I understand the existing data provider logic correctly. And I'm not sure that's worth doing given I've opened #3493421: Remove "administer own $type_id registration settings" & "manage own $type_id registration" as a follow up.
Comment #21
jonathanshawComment #22
jonathanshawComment #23
john.oltman commentedThis was ready but then I realized that somewhere along the way "manage own $bundle registration' became too powerful and was allowing settings access. As implied in the description for 'manage $bundle registration settings' permission, settings access requires this additional permission when using either 'manage $bundle registration' or 'manage own $bundle registration' permission. I don't want to have yet another update hook in a separate issue, so we'll have to fix that in this issue. I will work on it.Comment #24
john.oltman commentedI thought there might be an issue with settings access control but on further review it looks okay. But to be sure I'll add some tests, which are missing, to RegistrationSettingsAccessTest. Currently there are no tests for "manage own". I'll add some to this MR.
Comment #25
john.oltman commentedAll tests are passing. I want to add one more test, for the update hook, proving that a user with 'administer own' lost the ability to do certain things before the update hook runs, and regains them after the update hook runs. Will add that within the next day or two.
Comment #28
john.oltman commentedSkipped the update hook tests since new "host" replacement permissions are imminent and want this merged before then. Can always add a test later.
Comment #30
john.oltman commentedComment #32
john.oltman commented@jonathanshaw, I ran commerce registration tests against 3.3.x dev branch and they indicated that the update hook in the merged MR for this issue should possibly have also included granting "manage $type_id registration settings" and "manage $type_id registration broadcast" permissions, in addition to the "manage own $type registration" permission. If you agree, I will open a new issue, or perhaps a new branch against this same issue. It makes sense, since previously, "administer own $type registration" permission was like "administer $type" except just for host entities the user could edit. But I'd like your take on it if you have time to look.
Comment #33
john.oltman commentedComment #34
jonathanshawMy bad :( I think we shouldn't have given 'manage own $type registration' at all, we should have given 'administer own $type registration settings'.
Comment #35
john.oltman commented