Actual Behavior

To see a Domain Access field in a View requires the admin permission: 'view domain list'. If not this field doesn't display anything.

Expected Behavior

No need to give access to /admin/config/domain to see this field.
I would expect that it's enough to be assigned to a domain to see this domain name in a View.

CommentFileSizeAuthor
#15 domain-view-label.patch1.6 KBdrpldrp
#14 3332327-14.patch1.46 KBleksat

Issue fork domain-3332327

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

heyyo created an issue. See original summary.

heyyo’s picture

Issue summary: View changes
agentrickard’s picture

Status: Active » Postponed (maintainer needs more info)

Can you please post an example -- or even better a test -- that shows this behavior?

At the very least I need a bullet list of steps to reproduce.

tim-diels’s picture

Status: Postponed (maintainer needs more info) » Active

Use case 1:
An example would be adding the domain access field to a view like the content overview.
User 1 has bypass so that user can see the assigned domains of the content.
Another user that does not have the 'view domain list' will not see the assigned domains in the content overview.

Use case 2:
Add the module Domain Menu Access with the patch from #3120030: Show selected domains for each menulink on the menu edit page.
This will add a column "Domains" to the menu edit screen.
User 1 has bypass so that user can see the assigned domains of the content.
Another user that does not have the 'view domain list' will not see the assigned domains in the overview.

Some more information about the permission:
The check is done in DomainAccessControlHandler->checkAccess

// For view, we allow admins unless the domain is inactive.
$is_admin = $this->isDomainAdmin($entity, $account);
if ($operation === 'view' && ($entity->status() || $account->hasPermission('access inactive domains')) && ($is_admin || $account->hasPermission('view domain list'))) {
  return AccessResult::allowed();
}

I'm not sure what the permission does in general so not really an idea on how to create a test for this.
It's also used in DomainListCheck->viewDomainList which gives access to /admin/config/domain

My guess is that giving this permission to non admin users is not a wanted behaviour, so we should see if there could be another way to allow to view the domain access field values.

tim-diels’s picture

Seems like there is some work done in #3254227: Permission for viewing active domains to provide this. But guess this needs some more explanation and maybe test coverage?

tim-diels’s picture

agentrickard’s picture

Category: Bug report » Feature request

I don't think this is a current bug. I think it's a feature. The logic here is that domain information should not be shown to people who cannot act on it. See the Domain Content module for the core use-case.

That said, I think we can update #3254227: Permission for viewing active domains in this issue and create a special permission for it.

It's a little interesting that the other patch adds a "view active domains" permission. By design, that shouldn't be needed if the domain status is TRUE.

I think this is a special case for how Views interacts with the data. Our current permission rules are about restricting access to the full entity.

The test would add the field to the default "content" overview field and check that it is visible. Ideally, we'd write a failing test first.

makbay made their first commit to this issue’s fork.

makbay’s picture

Version: 8.x-1.0-beta6 » 8.x-1.x-dev

Coming from #3254227: Permission for viewing active domains and I have closed it in favor of this issue.

Well, actually in my case, we have an entity reference field referencing to domain entities in a content type. While using this field in a view to create a link to the referenced domain, non-admin users is not allowed to see the link or referenced domain entity. Please see the image below.

ER

makbay’s picture

Status: Active » Needs review
agentrickard’s picture

Still very interesting....this really needs a test, since we are adding a permission behavior.

leksat’s picture

StatusFileSize
new1.46 KB

Snapshot of MR 42 for using with Composer patches.

drpldrp’s picture

StatusFileSize
new1.6 KB

I have a similar use case and solved it by enabling the "view label" operation in DomainAccessControlHandler.

I also found it useful to implement toUrl() for the Domain entity.

Just a suggestion and for consideration.

mably made their first commit to this issue’s fork.

mably’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Needs work

Why do we have two MRs here?

And could we have a small test added please?

And we should be ready for merge.

mably’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#3461900: Permission allows access to view domain entity

Should be solved by issue #3461900: Permission allows access to view domain entity.

Feel free to reopen if necessary.