Skip to content

Commit dc9ba7d

Browse files
committed
support jwt+cors
1 parent d0d94ba commit dc9ba7d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3117,7 +3117,7 @@ public function handle(Request $request): Response
31173117
$response = $this->responder->error(ErrorCode::ORIGIN_FORBIDDEN, $origin);
31183118
} elseif ($method == 'OPTIONS') {
31193119
$response = new Response(Response::OK, '');
3120-
$allowHeaders = $this->getProperty('allowHeaders', 'Content-Type, X-XSRF-TOKEN');
3120+
$allowHeaders = $this->getProperty('allowHeaders', 'Content-Type, X-XSRF-TOKEN, X-Authorization');
31213121
if ($allowHeaders) {
31223122
$response->addHeader('Access-Control-Allow-Headers', $allowHeaders);
31233123
}

examples/clients/auth0/vanilla.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<head>
33
<meta charset="utf-8" />
44
<script>
5-
var domain = ''; // hostname ending in '.auth0.com'
5+
var authUrl = 'https://php-crud-api.auth0.com/authorize'; // hostname ending in '.auth0.com'
66
var clientId = ''; // client id as defined in auth0
77
var audience = ''; // api audience as defined in auth0
88
window.onload = function () {
99
var match = RegExp('[#&]access_token=([^&]*)').exec(window.location.hash);
1010
var accessToken = match && decodeURIComponent(match[1].replace(/\+/g, ' '));
1111
if (!accessToken) {
12-
document.location = 'https://'+domain+'/authorize?audience='+audience+'&response_type=token&client_id='+clientId+'&redirect_uri='+document.location.href;
12+
document.location = authUrl+'?audience='+audience+'&response_type=token&client_id='+clientId+'&redirect_uri='+document.location.href;
1313
} else {
1414
document.location.hash = '';
1515
var req = new XMLHttpRequest();

src/Tqdev/PhpCrudApi/Middleware/CorsMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function handle(Request $request): Response
3232
$response = $this->responder->error(ErrorCode::ORIGIN_FORBIDDEN, $origin);
3333
} elseif ($method == 'OPTIONS') {
3434
$response = new Response(Response::OK, '');
35-
$allowHeaders = $this->getProperty('allowHeaders', 'Content-Type, X-XSRF-TOKEN');
35+
$allowHeaders = $this->getProperty('allowHeaders', 'Content-Type, X-XSRF-TOKEN, X-Authorization');
3636
if ($allowHeaders) {
3737
$response->addHeader('Access-Control-Allow-Headers', $allowHeaders);
3838
}

0 commit comments

Comments
 (0)