Problem/Motivation

If I enable the "Access the taxonomy vocabulary overview page" permission for Anonymous users, the Vocabulary names appear; they also have access to the /admin/structure/taxonomy path, which I don't wish to allow. I don't see any other permission for allowing access to the Vocabulary name.

This also occurs if I am not using grouping - if I want to list a term in a row with its Vocabulary name, the name does not appear without the user having the above permission.

Steps to reproduce

I have a Taxonomy term view which groups several terms by their Vocabulary name. For example:

- Vocab 1
-- Term 1
-- Term 2
- Vocab 2
-- Term 3
-- Term 4

However, if I am not logged in, the Vocabulary names are not shown. The output is instead like this:

-- Term 1
-- Term 2
-- Term 3
-- Term 4

Proposed resolution

There are two solutions proposed for this issue.
#29 where we can add access for `view label` operation. (Added in issue's PR)
#37 This patch is adding access for `view` operation.

Per @xjm and @larowlan the solution forward is a new permission "view vocabulary labels" which builds on proposal 1

Remaining tasks

  • Needs discussion about solution approach. #45 @xjm agreed on the solution of a new permission by @larowlan
  • Sub-system maintainer review #45 @xjm gave feedback

User interface changes

N/A

API changes

New permission "view vocabulary labels" added

Data model changes

N/A

Release notes snippet

Issue fork drupal-3114365

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

wsantell created an issue. See original summary.

lendude’s picture

I sounds like Views is respecting Taxonomy vocabulary access checks, so this sounds like a lack of granularity in Taxonomy permissions is the underlying issue here (which we can't fix in Views). But didn't dig into this, so there might be a different reason this is hidden (but the toggling of the permission does point strongly to this being the issue).

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

sirclickalot’s picture

I think this is quite a serious and overllooked issue.

Firstly, surely many sites would like to be able to present a 'catalogue' made up of terms from several vocabularies and then be able to use views to present all such terms in nice neat groups.

Secondly, if the anonymous user can view terms (which they can out of the box) then why on earth not allow them to also see the vocabulary name.

As wsantell righty says, "applying the "Access the taxonomy vocabulary overview page" permission for Anonymous users" workaround is a bad idea because that enables anonymous users to reorganise your terms!

Can anyone offer ideas here?

Thank you

sivaji_ganesh_jojodae’s picture

Priority: Normal » Major

I'm sailing on the same boat here!!

lendude’s picture

Component: views.module » taxonomy.module

As I pointed out in #2 this seems like a problem in taxonomy, so moving it to that queue for now. If it turns out to be something specific to Views we can always move it back.

Not sure this can be classified as major, but since there is no workaround, I'll leave it there for now.

jhmnieuwenhuis’s picture

Same issue here.

JLucySong’s picture

Using this module: https://www.drupal.org/project/taxonomy_access_fix and update permissions of terms can fix this

anruether’s picture

@sjnsmnkl Can you elaborate how taxonomy_access_fix helps with this issue? I installed 3.x-dev and don't find a "View vocabulary X name permission", also enabling "View terms in X" does not make me show the vocabulary name for anonymous users.

anruether’s picture

It seems that you mentioned a hack, that does not work anymore in 3.x-dev: #3161541-2: Add permissions to view vocabulary names

JLucySong’s picture

@anruether Install the module and go to /admin/people/permissions, search for "Taxonomy Access Fix", and check boxes for "View terms in XXX", which can fix this. My version is 8.x-2.8 tho

greg__’s picture

How about this patch ?

WidgetsBurritos’s picture

Issue tags: +Needs tests

I can confirm the patch in #12 works. It's a pretty straightforward approach, in my mind. It definitely needs test coverage though.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

lambch’s picture

Patch given in #12 works for me. Adds the missing permissions. Thanks Greg__.

danflanagan8’s picture

Version: 9.2.x-dev » 9.3.x-dev
StatusFileSize
new4.1 KB

Here's a test-only fail patch to expose the bug. I'm trying to just run the new test to save time and money. Let's see if I'm doing it right.

I wrote the test as if 'access content' should be enough of a permission to see a vocab name. This is consistent with (node) Content Types. So I personally don't think we should add a new permission.

danflanagan8’s picture

Status: Active » Needs review
Issue tags: -Needs tests
StatusFileSize
new3.63 KB
new2.37 KB

Great! Only the updated test ran and it failed as expected for a user with `access content` permissions. Here's a fix that relies on `access content` instead of adding new permissions to view vocabs. This is consistent with how Content Types work.

Note that the interdiff is mostly related to now letting all tests run.

danflanagan8’s picture

There has already been considerable discussion about how to handle the permissions for something like this as part of #2808217: To be able to view Vocabulary config entities via REST, one should not have to grant the 'administer taxonomy' permission. It's a long thread and I haven't quite figured out why they didn't use access content to solve that problem.

The approach there was to rely on the then-new access taxonomy overview permission.

I think people on the issue here seem to agree that it's pretty weird to give anonymous users that permission.

Status: Needs review » Needs work

The last submitted patch, 17: 3114365-17.patch, failed testing. View results

danflanagan8’s picture

Status: Needs work » Needs review

Just like in #12 this broke a bunch of tests related to REST and HAL. I'm not interested in fixing those until there's some agreement on what permission to rely on. Setting back to NR to get some eyes on this.

greg__’s picture

It seems that they resolved the point in the issue you linked in #18. https://www.drupal.org/project/drupal/issues/2808217

scotwith1t’s picture

As with #18 and others, seems like giving access to taxonomy overview for this purpose makes absolutely no sense to me. The anonymous user can then go to admin/structure/taxonomy and reorder the vocabulary weights?! How is that sensible? I get that REST access needed to be accommodated but giving this permission to anonymous was not a good solution imho.

Using "access content" makes perfect sense to me as all that needs to be accomplished is access to the name of the vocabulary and this should be something publicly accessible for any and all users who can access content. I can't think of a use case where the name of the vocabulary would be something that should be excluded from access for users who can access the content as a whole...

Even though it isn't passing tests, applies cleanly to 9.3.6 and works as expected. Thanks!

yospyn’s picture

#17 worked for me, I'm using it to render the Vocabulary in search results (as a label atop the taxonomy term name). The Vocabulary name was not showing up for anonymous users, but now it is. There are no errors in the logs either.

Status: Needs review » Needs work

The last submitted patch, 17: 3114365-17.patch, failed testing. View results

alison’s picture

Oooo I just ran into this problem, thrilled to see there's a patch.

Anyone have an inclination about support (or lack thereof) for the concept from core maintainers?

alison’s picture

Version: 9.3.x-dev » 9.5.x-dev
Status: Needs work » Needs review
Issue tags: +Needs subsystem maintainer review

Patch works for me on 9.3.x, and applies cleanly + functions properly on 9.5.x.

Changing status to "needs review", and adding "needs subsystem maintainer review" tag, may @ someone on Slack later -- also will try rerunning tests!

Status: Needs review » Needs work

The last submitted patch, 17: 3114365-17.patch, failed testing. View results

ghost of drupal past’s picture

I was unsure whether 'access content' is the right one but it certainly looks like it: TermAccessControlHandler also uses that one for view.

berdir’s picture

Surprised to see this on NodeTypeAccessControlHandler as well.

IMHO it should be limited to the view label access operation for both, not everything should IMHO be publicly exposed.

danflanagan8’s picture

Issue tags: +Bug Smash Initiative

Taggin for Bug Smash

alison’s picture

Thank you to @Berdir for the guidance on Slack #contribute!

- Tests are queued to run against 9.5.x.
- But, leaving "Needs work" status, because the tests need to be updated to reflect the permission change.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

david.muffley’s picture

StatusFileSize
new3.8 KB

Rerolling #17 for 10.1.x.

alison’s picture

FWIW, the patch in #34 does apply fine to 10.1!

I attempted to adjust the tests so it runs against 10.1.x, too; I hope I did it right, if not, ...oops and I hope it doesn't cause a hassle, I gave it a shot 🤞

EDIT: Mmmm now I can't seem to "retest" against 11.x... I'll give it another try after the 10.1.x tests are done.
EDIT 2: Not important, but I swear I didn't notice til right now that I had an earlier comment (#31) with questions/wonderings about running tests against different branches 😆 the circle of life........

david.muffley’s picture

StatusFileSize
new4.57 KB
new646 bytes

Updated the expected permissions in the test failing in #34. I'll leave it to someone else to review whether that change should be made or not.

david.muffley’s picture

StatusFileSize
new5.42 KB

One more test base class.

david.muffley’s picture

StatusFileSize
new1.3 KB

Interdiff for #37.

mohit_aghera’s picture

Status: Needs work » Needs review
smustgrave’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs issue summary update, +Needs Review Queue Initiative

Reviewing this part of the needs review queue. And the issue summary seemed incomplete. Got it started if relevant sections to this issue could be filled in please.

sirclickalot’s picture

I am really struggling to understand quite why this is still a thing.

I first discovered this on my sites about 4 years ago and I have looked back today to find that I did indeed contribute here.

Right now, my non-admin users (e.g. Anonymous and Authenticated) still cannot view Vocabulary names and it's madness!

I wholeheartedly agree that if they can View published content then they really ought, without any question, by able to view the names of the vocabs that are used to categorise that content.
Seems like a Page 1 expectation to me or have I really missed something here?

The only way for me to enable my users to see vocabulary names is by giving them Administer vocabularies and terms permission and I sure as hell am not going to do that.

Adding in the Taxonomy Access Fix module and ticking every occurrence of...

TAXONOMY VOCABULARY NAME: View vocabulary name
Has no effect at all, none of my users cannot view the NAME of any vocabulary.

Even with...
View any vocabulary name TICKED for both Anonymous and Authenticated they still cannot view any vocabulary names.

I have tried the patch in #37 (3114365-37.patch) and ticked off...

'Access the taxonomy vocabulary overview page
Get an overview of all taxonomy vocabularies.'

for both Anonymous and Authenticated roles, cleared all caches but they still cannot see the vocabulary names.

Possible workaround for some

By completely rebuilding some of my Content views and Search API Index views where I expose vocabulary names as fields, I was eventually able to get my user the what I wanted, i.e. a simple page of Term sorted alphabetically and grouped under Vocabulary name but one shouldn't need an MSc in Drupal site building to get such a simple thing done ;-)

After all the various threads here are at a point where we can just go with 'View Published content' or or we must, simply 'View Taxonomy vocabulary names'.?

danflanagan8’s picture

Hi @SirClickalot! Per the comment in #40, this issue is in need of an issue summary update. I'd agree with that assessment given that the proposed resolution is stated as TBD. This issue won't likely get over the finish line until someone tidies up the summary, which will allow core committers to easily assess the fix after this gets to RTBC.

mohit_aghera’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

Based on @Berdir's feedback in #29,
I've added a PR that adds permissions for `view label` operation.

I think we need some inputs from sub system maintainer about which is the correct approach.
I feel that `view label` access is more safe and restricted.

Updated the issue summary and mentioned that we need consensus about the solution.
Hiding other patches since #37 seems another valid implementation and passing test cases as well.

xjm’s picture

Status: Needs review » Needs work
Issue tags: -Needs subsystem maintainer review

Thanks everyone for your thoughtful comments and work on this issue! It's good to see all the different comments showing that this definitely needs a fix.

I agree with @larowlan that this should actually have its own permission. "Access content" is almost as overmuch in its way as "administer taxonomy terms". A dedicated permission would improve the functionality and also be a sort of security hardening. :D

NW to implement that. Thanks!

mohit_aghera’s picture

Status: Needs work » Needs review

Tests are green, back to needs review

larowlan’s picture

Status: Needs review » Needs work

Hiding patches

Left a comment on the MR, I think we can simplify this to a single permission

mohit_aghera’s picture

Status: Needs work » Needs review

Fixed the feedback.

larowlan’s picture

Status: Needs review » Needs work

Very close, couple of minor things

mohit_aghera’s picture

Status: Needs work » Needs review

Fixed the PR feedback.

smustgrave’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Appears feedback from @larowlan has been addressed

Cleaned up the issue summary some to include the new proposed solution.

Also drafted a simple change record https://www.drupal.org/node/3436818 to announce the new permission.

smustgrave’s picture

Issue summary: View changes
alexpott’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Assigning issue credit.

I do wonder if a new permission is the best thing here. But going with the decision by @xjm and @larowlan. I also wonder how you are going to find this permission if you are trying to fix this problem.

Committed and pushed 8d5b54efa8 to 11.x and 495174e527 to 10.3.x. Thanks!

  • alexpott committed 495174e5 on 10.3.x
    Issue #3114365 by mohit_aghera, david.muffley, danflanagan8, Greg__,...

  • alexpott committed 8d5b54ef on 11.x
    Issue #3114365 by mohit_aghera, david.muffley, danflanagan8, Greg__,...

Status: Fixed » Closed (fixed)

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