Problem/Motivation

The toolbar integration doesn't sufficiently check whether the user has the "See all environment indicators" permission. If the user doesn't have the permission, it hides the environment name, but the toolbar color will still be changed.

Steps to reproduce

1. Install environment_indicator, environment_indicator_toolbar and environment_indicator_ui
2. Define a name and background color for the current environment (at /admin/config/development/environment-indicator/current)
3. Assign the "Use toolbar" permission to anonymous users (just for the sake of an example - it works with any role)
4. As anonymous user, visit the page → The toolbar will have the defined background color, although the anonymous users do not have the "See all environment indicators" permission.

Proposed resolution

Add a permission check to ensure the toolbar color is only changed if the current user has the "See all environment indicators" permission

Remaining tasks

Implement a fix

User interface changes

Toolbar color only changes if user has sufficient permission

API changes

None

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

nico.b created an issue. See original summary.

nico.b’s picture

Status: Active » Needs review

Opened a MR to fix the issue.

The lint tests seem to fail, but shouldn't be related to the changes from the MR at all. All other tests seem to pass.

dhruv.mittal’s picture

Reviewing this

trackleft2’s picture

trackleft2’s picture

dhruv.mittal’s picture

Status: Needs review » Reviewed & tested by the community

I've checked that issue persist and MR is resolving the issue so moving it to RTBC

trackleft2’s picture

@dhruv.mittal & @nico.b I've merged a merge request on this issue #3535214: Performance Improvements that should resolve this issue as well. https://git.drupalcode.org/project/environment_indicator/-/commit/324362...,

This is not yet included in a release, but it has been added to the next release plan #3468997: [META] Release Plan for Environment Indicator Minor (feature) Release 4.1.0.

nico.b’s picture

@trackleft2 While that (when looking at the code changes only) indeed seems to fix the issue, I'm wondering whether a fix for this issue is really something that should wait for a new feature release, especially considering it is a permissions-related issue?

jonraedeke’s picture

Status: Reviewed & tested by the community » Needs work

I was experiencing this issue on 4.0.24. While the MR solves the permission check for color, I'm now seeing the Environment Menu in the toolbar for a role that has no permissions related to this module.

jonraedeke’s picture

This seems to be fixed in the 4.x dev release as indicated by comment #8.

trackleft2’s picture

OK, I'll backport the fix to the 4.0.x branch and create a new 4.0.25 release.

trackleft2’s picture

I've created a Merge Request, and a patch for use in the meantime. Please test, and let me know if it works for you, and we can create a new release.

trackleft2’s picture

StatusFileSize
new986 bytes
trackleft2’s picture

Status: Needs work » Needs review

trackleft2 changed the visibility of the branch 3536522-insufficient-permission-check to hidden.

nico.b’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm that this patch/MR is also resolving the issue, so moving it to RTBC.

  • trackleft2 committed 37c5752d on 4.0.x
    Close #3536522 Require permission to color the toolbar.Issue #3536522 by...
trackleft2’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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