Improve access logic for Navigation blocks page

Created on 17 May 2024, 7 months ago
Updated 13 June 2024, 6 months ago

Problem/Motivation

Navigation Blocks page (/admin/config/user-interface/navigation-block) is the place to go to edit the navigation layout and manage the blocks to be included there.

Current NavigationSectionStorage::access() implementation just gives free access to the page. That added to logic in LayoutBuilderAccessCheck::access() ends up being just like checking for configure any layout permission.

That permission is not very restrictive nor representative for Navigation module.

Would be great to have a more representative and intuitive way to manage access to that page.

Proposed resolution

Create a new Configure Navigation Layout permission
Override NavigationSectionStorage::access() to check for that permission
Add handles_permission_check to NavigationSectionStorage class attributes to not grant access based on configure any layout permission.

Remaining tasks

User interface changes

None

API changes

New permission added.

Data model changes

Release notes snippet

✨ Feature request
Status

Fixed

Version

10.3 ✨

Component
NavigationΒ  β†’

Last updated about 3 hours ago

No maintainer
Created by

πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

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

Merge Requests

Comments & Activities

  • Issue created by @plopesc
  • Pipeline finished with Success
    7 months ago
    Total: 567s
    #178235
  • Status changed to Needs review 7 months ago
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    MR created

  • Status changed to RTBC 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
    There was 1 failure:
    1) Drupal\Tests\navigation\FunctionalJavascript\NavigationBlockUiTest::testNavigationBlockAdminUiPage
    Invalid permission configure navigation layout.
    /builds/issue/drupal-3447881/core/modules/user/tests/src/Traits/UserCreationTrait.php:298
    /builds/issue/drupal-3447881/core/modules/user/tests/src/Traits/UserCreationTrait.php:253
    /builds/issue/drupal-3447881/core/modules/user/tests/src/Traits/UserCreationTrait.php:156
    /builds/issue/drupal-3447881/core/modules/navigation/tests/src/FunctionalJavascript/NavigationBlockUiTest.php:61
    FAILURES!
    Tests: 1, Assertions: 3, Failures: 1.
    

    Shows the test coverage.

    I believe since this is experimental changing permissions should be fine without needing any kind of upgrade

    Manually testing on 11.x the permission is working as advertised.

    Believe this to be good.

  • Status changed to Needs review 7 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    Because navigation is beta stability, this does need an upgrade path, although it's only been in a beta release of 10.3, not any stable releases yet, so I have double checked with the other release managers - not sure this specific situation has come up before. Upgrade paths are 100% needed when beta stability modules are in release candidates or stable releases at least, and it probably applies here too.

  • Pipeline finished with Success
    7 months ago
    Total: 623s
    #184256
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Thank you for the heads-up. I was not completely sure whether this change might require an upgrade path or not.

    Added post_update hook that assigns configure navigation layout permission to roles with configure any layout permission. Those were the roles with access to modify the navigation layout, so the change will be transparent for them.

    I did not add any replacement for administer navigation_block permission, given that it was not being used anywhere after the LB refactor.

  • πŸ‡¬πŸ‡§United Kingdom catch

    I did not add any replacement for administer navigation_block permission, given that it was not being used anywhere after the LB refactor.

    I think the post update would probably need to delete this permission from any roles that have it.

  • Pipeline finished with Success
    7 months ago
    Total: 553s
    #184293
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Added logic to get rid of the unused permission administer navigation_block.

    Thank you for the guidance here.

  • Status changed to RTBC 7 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    Thanks I think this is fine. We would normally also need hook_role_presave() bc layer to update the config for module-shipped roles as well, but that is really not going to have happened one week after beta and it would be runtime code that would need to stay in navigation until 12.x if we added it, so I think it's better to skip that step here and just support any actual sites that potentially could have installed the beta.

  • Status changed to Needs review 7 months ago
  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

    Thanks for fixing this, just one minor question on the MR about the update path

  • Pipeline finished with Success
    7 months ago
    Total: 509s
    #184671
  • Status changed to RTBC 7 months ago
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Resolved the question opened by @larowlan.

    I think it is safe to move it back to RTBC now.

    Thank you!

  • Status changed to Needs review 7 months ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    catch and I agreed that a change record would be helpful here. I have added one but it needs to be reviewed. So, setting this to NR for that.

  • Status changed to RTBC 7 months ago
  • πŸ‡ͺπŸ‡ΈSpain plopesc Valladolid

    Thank you for taking care of the initial CR.

    Took a look into that and made some minor changes to add some extra information.

    Back to RTBC now.

    • catch β†’ committed 65625e63 on 10.3.x
      Issue #3447881 by plopesc, catch, larowlan, smustgrave, quietone:...
    • catch β†’ committed e20f1241 on 10.4.x
      Issue #3447881 by plopesc, catch, larowlan, smustgrave, quietone:...
    • catch β†’ committed e9707944 on 11.0.x
      Issue #3447881 by plopesc, catch, larowlan, smustgrave, quietone:...
    • catch β†’ committed d7f114cd on 11.x
      Issue #3447881 by plopesc, catch, larowlan, smustgrave, quietone:...
  • Status changed to Fixed 7 months ago
  • πŸ‡¬πŸ‡§United Kingdom catch

    All looks good to me now, thanks for the changes. We might want to tweak the experimental module allowed changes to make upgrades optional in the 'beta-in-beta' situation but at least this one is pretty straightforward.

    Committed/pushed to 11.x and cherry-picked to back through to 10.3.x, thanks!

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

Production build 0.71.5 2024