Review 14.3 Merged

96589[BUGFIX] Keep status with WWW-Authenticate header

Oli Bartsch CR +2 V +2 Normal +66 −1 updated 10/10/26, 08:22

Commit message

PHP sets the response status to 401 whenever a WWW-Authenticate header
is sent with header(), even when a different status line was sent
before. This is done by PHP's SAPI layer itself and is not mentioned in
the documentation of header(). Sending

  header('HTTP/1.1 403 Forbidden');
  header('WWW-Authenticate: Bearer error="insufficient_scope"');

therefore answers with "401 Unauthorized".

As AbstractApplication::sendResponse() sends the status line before
the headers, a PSR-7 response with status 400 or 403 and a
WWW-Authenticate header, as RFC 6750 requires for "invalid_request"
and "insufficient_scope", reached the client as 401.

The status line of the response is now sent again after its headers
when a WWW-Authenticate header is present, so the status of the PSR-7
response is kept.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
  • Verified V +2 Done
    • Oli Bartsch +2
    • core-ci +1 CI

Issues 1

Files 2

Review log 34

  1. Oli Bartsch commented on patch set 1 10/10/26, 07:40

    Cherry Picked from branch main.
  2. core-ci voted on patch set 1 V +1 10/10/26, 07:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110761

  3. Oli Bartsch voted on patch set 1 CR +2 V +2 10/10/26, 08:21

  4. Oli Bartsch merged patch set 2 10/10/26, 08:22