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.

Command icon 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

jonathanshaw created an issue. See original summary.

jonathanshaw’s picture

jonathanshaw’s picture

Status: Active » Needs review

So this is a simple fix, if one is willing to accept the change of behavior.

jonathanshaw’s picture

I 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.

jonathanshaw’s picture

Status: Needs review » Needs work
jonathanshaw’s picture

[deleted]

jonathanshaw’s picture

N.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.

jonathanshaw’s picture

One 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.

jonathanshaw’s picture

I'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.

jonathanshaw’s picture

Title: RegistrationAccessControlHandler checks 'administer own $type registration' incorrectly » 'administer own' and 'manage own' permissions are confusing
Category: Bug report » Task
Issue summary: View changes

Updated the IS with new proposal now I understand this is not a bug per se.

jonathanshaw’s picture

Issue summary: View changes
jonathanshaw’s picture

Issue summary: View changes
john.oltman’s picture

@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.

jonathanshaw’s picture

I would love to coordinate on a new structure for a future 3.5 or 4.x version of the module.

Great, 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.

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)

I will have a look at it.

john.oltman’s picture

Version: 3.1.x-dev » 3.3.x-dev

I wonder if we can close this and combine it into https://www.drupal.org/project/registration/issues/3479435

jonathanshaw’s picture

I think we should do this in this issue, before or after #3479435: Create 'manage host' and 'administer host' permissions:

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.

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:

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.

So there's 3 separable issues here. We could combine, but I tend to assume seperating is better if possible.

jonathanshaw’s picture

Status: Needs work » Needs review
john.oltman’s picture

Status: Needs review » Needs work

Thanks @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.

jonathanshaw’s picture

Re ManageRegistrationsAccessCheck

"Do we need a couple new examples now - for administer own conference registration settings - with host update TRUE and FALSE - and expected being TRUE and FALSE respectively."

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.

jonathanshaw’s picture

Status: Needs work » Reviewed & tested by the community
jonathanshaw’s picture

Title: 'administer own' and 'manage own' permissions are confusing » Refine semantic of 'administer own $type registration' permission
Issue summary: View changes
Related issues: +#3479435: Create 'manage host' and 'administer host' permissions, +#3493421: Remove "administer own $type_id registration settings" & "manage own $type_id registration"
john.oltman’s picture

Assigned: Unassigned » john.oltman
Status: Reviewed & tested by the community » Needs work

This 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.

john.oltman’s picture

I 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.

john.oltman’s picture

All 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.

john.oltman’s picture

Status: Needs work » Fixed

Skipped the update hook tests since new "host" replacement permissions are imminent and want this merged before then. Can always add a test later.

john.oltman’s picture

Assigned: john.oltman » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

john.oltman’s picture

@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.

john.oltman’s picture

Status: Closed (fixed) » Fixed
jonathanshaw’s picture

My bad :( I think we shouldn't have given 'manage own $type registration' at all, we should have given 'administer own $type registration settings'.

john.oltman’s picture

Status: Fixed » Closed (fixed)