Prevent access to "Configure block" page for non-existance themes

Created on 30 October 2023, about 1 year ago
Updated 18 December 2023, about 1 year ago

Problem/Motivation

If I visit path admin/structure/block/library/non_existance_theme, I get an access denied error. However, if I visit admin/structure/block/add/page_title_block/non_existance_theme, the "Configure block" page appears with an empty region selector (page_title_block could be an block ID). I ran into this in functional testing.

Proposed resolution

This path should also return access denied.

Remaining tasks

Implement.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Block 

Last updated 1 day ago

Created by

🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Liam Morland
  • 🇮🇳India sijumpk

    There is a page available to add block to any theme, at admin/structure/block/add/page_title_block. Because of that _access_theme: 'TRUE' requirements is avoided from block.admin_add route. Even if we reach the page like you said (admin/structure/block/add/page_title_block/non_existance_theme), we won't be able to create any block as there wont be any options available in the required "Region" field.

  • Status changed to Needs work about 1 year ago
  • 🇵🇭Philippines abhaypai

    Thanks @LiamMorland to report the issue.

    Few updates from end so far:

    1. I was able to replicate the issue according to the description
    2. Did comparison between block.admin_library which defines path admin/structure/block/library/non_existance_theme and block.admin_add which defines path admin/structure/block/add/page_title_block/non_existance_theme have a delta of _access_theme in block.routing.yml file
    3. Did some initial debugging and after applying _access_theme under block.admin_add issue is resolved
  • Status changed to Needs review about 1 year ago
  • 🇵🇭Philippines abhaypai

    Keeping the status to "Needs work" since phpunit test is failing, adding "Needs Test" tag and updating the version to "11.x-dev" since i also replicated the same in that version

  • Status changed to Needs work about 1 year ago
  • 🇵🇭Philippines abhaypai

    Keeping the status to "Needs work" since phpunit test is failing

  • 🇮🇳India sijumpk

    @abhaypai, your patch will cause an "Access denied" to /admin/structure/block/add/page_title_block . In order to avoid that _access_theme: 'TRUE' is avoided from block.admin_add route. We need to add a block even if there is no theme present in the url

  • 🇵🇭Philippines abhaypai

    Thanks for looking into my suggestion and updating your comments on #2, although i have few points to share:

    1. From where did you find the source of this following statement, Any reference link issue is gonna be helpful here to proceed with solution
      In order to avoid that _access_theme: 'TRUE' is avoided from block.admin_add route.
    2. Can you please share replicating steps to land on this url /admin/structure/block/add/page_title_blockfrom user interface ? I aware of landing on this url directly from url path is possible and forms field shows default theme inputs.
    3. Also i cannot see any code use case of this said /admin/structure/block/add/{placeholder} path or block.admin_add route source in the system without being usage of theme name to any pluginid

    Looking for suggestions here from other community members; what can be solution of this bug ? Ideally from my POV form should not be visible if there is no theme available or installed in the system.

  • 🇨🇦Canada Liam Morland Ontario, CA 🇨🇦

    I ran into this in functional testing with a test that directly requests the page. I don't know of any place where a link to the invalid page exists. It would have been easier to debug that the test was missing the theme if that invalid page had returned a 403 or 404 status.

Production build 0.71.5 2024