`api.config.auto-save.get` route returns data without any authentication

Created on 23 June 2025, 22 days ago

Overview

The experience_builder.api.config.auto-save.get route returns data of js_component and xb_asset_library entities without any authentication. This has been the case since πŸ› Content authors cannot see components Active landed.

Proposed resolution

Restrict access properly.

User interface changes

n/a

πŸ› Bug report
Status

Active

Version

0.0

Component

… to be triaged

Created by

πŸ‡³πŸ‡±Netherlands balintbrews Amsterdam, NL

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

Merge Requests

Comments & Activities

  • Issue created by @balintbrews
  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί
  • πŸ‡³πŸ‡±Netherlands balintbrews Amsterdam, NL

    I just realized that I meant to open the issue for api.config.get, that's where I originally discovered the problem. I haven't tested api.config.auto-save.get, so let's be sure to check that, too.

  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    I just realized that I meant to open the issue for api.config.get, that's where I originally discovered the problem.

    That shouldn't be the case:

    experience_builder.api.config.get:
      path: '/xb/api/v0/config/{xb_config_entity_type_id}/{xb_config_entity}'
      defaults:
        _controller: 'Drupal\experience_builder\Controller\ApiConfigControllers::get'
      requirements:
        _xb_http_eligible_config_entity: 'TRUE'
        _entity_access: 'xb_config_entity.view'
        # Allow a subset: `Component` config entities are read-only via the internal HTTP API.
        xb_config_entity_type_id: '(pattern|js_component|xb_asset_library)'
    

    AFAICT this is simply questioning πŸ“Œ Add access control for "code components" and "asset libraries", special case: instantiated code components must be accessible to *all* Active 's introduction of explicit access for all β†’ ?

    IOW: authentication & authorization are present, authorization is simply granted very broadly.

    I suspect what we want is the _user_is_logged_in thing πŸ“Œ Add access control for "code components" and "asset libraries", special case: instantiated code components must be accessible to *all* Active did for experience_builder.api.config.list:

    experience_builder.api.config.list:
      path: '/xb/api/v0/config/{xb_config_entity_type_id}'
      defaults:
        _controller: 'Drupal\experience_builder\Controller\ApiConfigControllers::list'
      requirements:
        # Any internal HTTP API-eligible XB config entity type.
        _xb_http_eligible_config_entity: 'TRUE'
        # But deter users from trying to access other config entities via this route: this ensures 404 responses rather than
        # 403.
        # @see \Drupal\Tests\experience_builder\Functional\XbConfigEntityHttpApiTest::testNonXbConfigEntity()
        xb_config_entity_type_id: '(component|pattern|js_component|xb_asset_library)'
        # The UI client can fetch all the components the current user has access too, regardless of which kind of XB-enabled
        # entity you're editing.
        _user_is_logged_in: 'TRUE'
      options:
        # Indicate that external applications may use this route. For authentication, see `modules/xb_oauth/README.md`.
        xb_external_api: true
      methods: [GET]
    

    Because here's the thing: @lauriii wanted XB to both:

    • only have a single simple "admin permission" per config entity type: JavaScriptComponent::ADMIN_PERMISSION etc.
    • NOT have a catch-all "use XB" permission β€” see πŸ“Œ SdcController cleanup tasks Active 's functional requirements

    See:

    1. my write-up about about this at #3508694-14: Permissions for XB config entity types β†’ .2
    2. my very detailed write-up about the consequences of this at #3508694-19: Permissions for XB config entity types β†’ .2
    3. confirmed by @lauriii at #3508694-20: Permissions for XB config entity types β†’
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Either we must do what I just pushed based on #4, or, and probably that's the safer option, \Drupal\experience_builder\EntityHandlers\VisibleWhenDisabledXbConfigEntityAccessControlHandler should be narrows to only logged in users rather than the current

          // We always allow viewing these entities, even if disabled.
          'view' => AccessResult::allowed(),
    
  • Merge request !1183Add missing `_user_is_logged_in`. β†’ (Merged) created by wim leers
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • Pipeline finished with Failed
    22 days ago
    #529986
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Actually, I think we can do both, but perhaps that means the first commit is now obsolete

    Plus, we need to expand assertAuthenticationAndAuthorization() to facilitate testing GETting an unauthorized individual config entity (i.e. the new test coverage that this issue needs).

  • Pipeline finished with Failed
    21 days ago
    Total: 972s
    #530232
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    πŸ› ContentCreatorVisibleXbConfigEntityAccessControlHandler bypasses admin permissions for view Active is in, which means we kinda don't need this test coverage here anymore … except that it would be good to generalize to all XB config entity types, instead of just Pattern.

  • Pipeline finished with Failed
    21 days ago
    Total: 1064s
    #530405
  • Pipeline finished with Failed
    21 days ago
    Total: 857s
    #530409
  • πŸ‡ͺπŸ‡ΈSpain penyaskito Seville πŸ’ƒ, Spain πŸ‡ͺπŸ‡Έ, UTC+2 πŸ‡ͺπŸ‡Ί

    Added tests for anonymous GET at assertAuthenticationAndAuthorization based on openapi examples, so we can generalize to all XB config entity types.

  • Pipeline finished with Failed
    21 days ago
    Total: 288s
    #530414
  • Pipeline finished with Failed
    21 days ago
    Total: 1674s
    #530417
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    VERY nice work here, @penyaskito!

  • Pipeline finished with Skipped
    21 days ago
    #530478
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024