Environment switcher specific permissions do not work.

Created on 23 May 2025, about 23 hours ago

Problem/Motivation

While preparing the 4.0.22 release, I noticed that the environment-specific switcher permissions (e.g. "See environment indicator for 'Development'") were not functioning as expected. I tested both the current dev branch and version 4.0.21, and confirmed the issue exists in both.

Users granted a specific switcher permission are not shown the corresponding switcher in the toolbar. Only granting the "See all environment switchers" permission causes switchers to appear, regardless of the specific permissions set.


Steps to reproduce

Configuration setup via Drush:

# Set the default indicator.
drush config:set environment_indicator.indicator fg_color '#000000' -y
drush config:set environment_indicator.indicator bg_color '#dd3f8f' -y
drush config:set environment_indicator.indicator name 'Local' -y

# Set up three switchers.
drush config:set environment_indicator.switcher.dev machine 'dev' -y
drush config:set environment_indicator.switcher.dev uuid '971430b9-85ed-4fb7-8ef1-0fae13bd3032' -y
drush config:set environment_indicator.switcher.dev name 'Development' -y
drush config:set environment_indicator.switcher.dev url 'https://dev.example.com' -y
drush config:set environment_indicator.switcher.dev fg_color '#31758e' -y
drush config:set environment_indicator.switcher.dev bg_color '#d4e5eb' -y
drush config:set environment_indicator.switcher.dev weight 0 -y
drush config:set environment_indicator.switcher.dev langcode 'en' -y
drush config:set environment_indicator.switcher.dev status true -y

drush config:set environment_indicator.switcher.staging machine 'staging' -y
drush config:set environment_indicator.switcher.staging uuid '971430b9-85ed-4fb7-9ef1-0fae13bd3032' -y
drush config:set environment_indicator.switcher.staging name 'Staging' -y
drush config:set environment_indicator.switcher.staging url 'https://staging.example.com' -y
drush config:set environment_indicator.switcher.staging fg_color '#017bff' -y
drush config:set environment_indicator.switcher.staging bg_color '#ff94fb' -y
drush config:set environment_indicator.switcher.staging weight 1 -y
drush config:set environment_indicator.switcher.staging langcode 'en' -y
drush config:set environment_indicator.switcher.staging status true -y

drush config:set environment_indicator.switcher.prod machine 'prod' -y
drush config:set environment_indicator.switcher.prod uuid '971430b9-85ed-5yb7-8ef1-0fae13bd3032' -y
drush config:set environment_indicator.switcher.prod name 'Production' -y
drush config:set environment_indicator.switcher.prod url 'https://example.com' -y
drush config:set environment_indicator.switcher.prod fg_color '#000000' -y
drush config:set environment_indicator.switcher.prod bg_color '#3dff24' -y
drush config:set environment_indicator.switcher.prod weight 2 -y
drush config:set environment_indicator.switcher.prod langcode 'en' -y
drush config:set environment_indicator.switcher.prod status true -y

Steps:

  1. Enable environment_indicator and environment_indicator_ui.
  2. Create an environment switcher with the name "Development".
  3. Create a new role called "Environment indicator" and grant only See environment indicator for "Development".
  4. Ensure the "Authenticated" role has no environment permissions.
  5. Create a new user and assign only the "Environment indicator" role.
  6. Log in as the new user in a private browser. Observe: no switchers are visible.
  7. As admin, grant the "See all environment switchers" permission to that role.
  8. Refresh the private browser. Now all switchers appear.

Proposed resolution

The current logic does not honor the per-switcher permissions. Either:

  • Fix the implementation so that individual switcher permissions are respected.
  • Or remove those permissions if fine-grained control is not intended to be supported.

Remaining tasks

  • Determine whether fine-grained switcher access is desired long term.
  • Fix permission logic or remove unused permission checks.
  • Add test coverage for switcher visibility under different permission scenarios.

User interface changes

None expected unless permissions are removed.

API changes

None unless access checking APIs are adjusted or deprecated.

Data model changes

None.

πŸ› Bug report
Status

Active

Version

4.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States trackleft2 Tucson, AZ πŸ‡ΊπŸ‡Έ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024