Skip to content

Commit b1efe1d

Browse files
committed
Fix broken tests
1 parent 3573ad9 commit b1efe1d

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/Tqdev/PhpCrudApi/Middleware/BasicAuthMiddleware.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ public function handle(Request $request): Response
9090
if (!$validUser) {
9191
return $this->responder->error(ErrorCode::AUTHENTICATION_FAILED, $username);
9292
}
93-
session_regenerate_id();
93+
if (!headers_sent()) {
94+
session_regenerate_id();
95+
}
9496
}
9597
if (!isset($_SESSION['username']) || !$_SESSION['username']) {
9698
$authenticationMode = $this->getProperty('mode', 'required');

src/Tqdev/PhpCrudApi/Middleware/JwtAuthMiddleware.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ public function handle(Request $request): Response
107107
if (empty($claims)) {
108108
return $this->responder->error(ErrorCode::AUTHENTICATION_FAILED, 'JWT');
109109
}
110-
session_regenerate_id();
110+
if (!headers_sent()) {
111+
session_regenerate_id();
112+
}
111113
}
112114
if (empty($_SESSION['claims'])) {
113115
$authenticationMode = $this->getProperty('mode', 'required');

tests/functional/002_auth/001_jwt_auth.log

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
GET /records/invisibles/e42c77c6-06a4-4502-816c-d112c7142e6d
2-
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6IjE1MzgyMDc2MDUiLCJleHAiOjE1MzgyMDc2MzV9.Z5px_GT15TRKhJCTHhDt5Z6K6LRDSFnLj8U5ok9l7gw
2+
X-Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6IjE1MzgyMDc2MDUiLCJleHAiOjE1MzgyMDc2MzV9.Z5px_GT15TRKhJCTHhDt5Z6K6LRDSFnLj8U5ok9l7gw
33
===
44
200
55
Content-Type: application/json
@@ -16,7 +16,7 @@ Content-Length: 45
1616
{"id":"e42c77c6-06a4-4502-816c-d112c7142e6d"}
1717
===
1818
GET /records/invisibles/e42c77c6-06a4-4502-816c-d112c7142e6d
19-
Authorization: Bearer invalid
19+
X-Authorization: Bearer invalid
2020
===
2121
403
2222
Content-Type: application/json

0 commit comments

Comments
 (0)