Respect installations with base paths

Created on 18 December 2023, 6 months ago
Updated 23 January 2024, 5 months ago

Problem/Motivation

The BackendApiRequest middleware is looking for the ce-api prefix in the server's REQUEST_URI. This is not working for installations with base paths. For example Drupal's gitlab ci installation uses the base url http://localhost/web. The actual uri that is checked in the middleware is /web/ce-api/node/1 which the middleware does not recognize as a valid ce-api request and therefore passes the request through without altering it.

Steps to reproduce

Send a request against the ce-api on an installation with a base path.

Proposed resolution

Consider base paths in the middleware.

Remaining tasks

  • Fix middleware ✔️
  • Add a small unit-test here where we mock $request object, so we could fire it up with all kind of URI combinations and verify it's all correct ✔️

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇦🇹Austria arthur_lorenz Berlin

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

Merge Requests

Comments & Activities

  • Issue created by @arthur_lorenz
  • Issue was unassigned.
  • Status changed to Needs review 6 months ago
  • 🇦🇹Austria arthur_lorenz Berlin

    Added a simple unit test to check if base paths are considered.

  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    Looks good to me, just a suggestion for

    ['/web/ce-api', '', NULL]
    ['/ce-api?param=1', '', TRUE]
    ['/ce-api/?param=1', '', TRUE]
    

    I don't know how that works in your list's organization -- lots of dimensions unfortunately :)

  • 🇦🇹Austria arthur_lorenz Berlin

    Thank you! ['/ce-api?param=1', '', TRUE] actually failed. Fixed it and added a couple of test cases.

  • Status changed to RTBC 6 months ago
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    Looks good.

  • Status changed to Needs work 6 months ago
  • 🇦🇹Austria fago Vienna

    it's really great to have a test added here! I do think it's not correctly checking things though, plese take look.

  • Status changed to Needs review 6 months ago
  • 🇦🇹Austria arthur_lorenz Berlin

    Commented and added tests for altered paths.

  • Status changed to Needs work 6 months ago
  • 🇦🇹Austria fago Vienna

    I see, makes sense.

    TEst coverage improvement is great, however not fully there:

    e.g. from test-data

    'Frontpage param CE-API trailing slash' => ['/ce-api/?param=1', '', TRUE, '/'],

    We should see this resulting into /?param=1 - thus we want to test not only the resulting path but the resulting request-URI really. Could you adust the test-case like this? Then I think this is ready to go.

  • Status changed to Needs review 6 months ago
  • 🇳🇱Netherlands roderik Amsterdam,NL / Budapest,HU

    1 commit added (and force-pushed with PHPCS fix): added "?param=1" to all expected/tested values, where the input values had them. Nothing else.

    I hope this is good to merge now, per the previous comment. It simplifies other issues that need to add phpunit tests.

  • Status changed to Fixed 6 months ago
  • 🇦🇹Austria fago Vienna

    ok, thanks. that works well, merged then.

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

Production build 0.69.0 2024