Browse Source

Fix broken tests

Maurits van der Schee 6 years ago
parent
commit
b1efe1d7d0

+ 3
- 1
src/Tqdev/PhpCrudApi/Middleware/BasicAuthMiddleware.php View File

@@ -90,7 +90,9 @@ class BasicAuthMiddleware extends Middleware
90 90
             if (!$validUser) {
91 91
                 return $this->responder->error(ErrorCode::AUTHENTICATION_FAILED, $username);
92 92
             }
93
-            session_regenerate_id();
93
+            if (!headers_sent()) {
94
+                session_regenerate_id();
95
+            }
94 96
         }
95 97
         if (!isset($_SESSION['username']) || !$_SESSION['username']) {
96 98
             $authenticationMode = $this->getProperty('mode', 'required');

+ 3
- 1
src/Tqdev/PhpCrudApi/Middleware/JwtAuthMiddleware.php View File

@@ -107,7 +107,9 @@ class JwtAuthMiddleware extends Middleware
107 107
             if (empty($claims)) {
108 108
                 return $this->responder->error(ErrorCode::AUTHENTICATION_FAILED, 'JWT');
109 109
             }
110
-            session_regenerate_id();
110
+            if (!headers_sent()) {
111
+                session_regenerate_id();
112
+            }
111 113
         }
112 114
         if (empty($_SESSION['claims'])) {
113 115
             $authenticationMode = $this->getProperty('mode', 'required');

+ 2
- 2
tests/functional/002_auth/001_jwt_auth.log View File

@@ -1,5 +1,5 @@
1 1
 GET /records/invisibles/e42c77c6-06a4-4502-816c-d112c7142e6d
2
-Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6IjE1MzgyMDc2MDUiLCJleHAiOjE1MzgyMDc2MzV9.Z5px_GT15TRKhJCTHhDt5Z6K6LRDSFnLj8U5ok9l7gw
2
+X-Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6IjE1MzgyMDc2MDUiLCJleHAiOjE1MzgyMDc2MzV9.Z5px_GT15TRKhJCTHhDt5Z6K6LRDSFnLj8U5ok9l7gw
3 3
 ===
4 4
 200
5 5
 Content-Type: application/json
@@ -16,7 +16,7 @@ Content-Length: 45
16 16
 {"id":"e42c77c6-06a4-4502-816c-d112c7142e6d"}
17 17
 ===
18 18
 GET /records/invisibles/e42c77c6-06a4-4502-816c-d112c7142e6d
19
-Authorization: Bearer invalid
19
+X-Authorization: Bearer invalid
20 20
 ===
21 21
 403
22 22
 Content-Type: application/json

Loading…
Cancel
Save