Skip to content

Commit 563886a

Browse files
committed
add client_secret, check for array key
1 parent e8d734a commit 563886a

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

solid/lib/Controller/ServerController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,17 +321,19 @@ public function session() {
321321
*/
322322
public function token() {
323323
$request = \Laminas\Diactoros\ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
324-
$grantType = $request->getParsedBody()['grant_type'];
324+
$requestBody = $request->getParsedBody();
325+
$grantType = $requestBody['grant_type'] ? $requestBody['grant_type'] : null;
326+
$clientId = $requestBody['client_id'] ? $requestBody['client_id'] : null;
325327
switch ($grantType) {
326328
case "authorization_code":
327-
$code = $request->getParsedBody()['code'];
329+
$code = $requestBody['code'];
328330
// FIXME: not sure if decoding this here is the way to go.
329331
// FIXME: because this is a public page, the nonce from the session is not available here.
330332
$codeInfo = $this->tokenGenerator->getCodeInfo($code);
331333
$userId = $codeInfo['user_id'];
332334
break;
333335
case "refresh_token":
334-
$refreshToken = $request->getParsedBody()['refresh_token'];
336+
$refreshToken = $requestBody['refresh_token'];
335337
$tokenInfo = $this->tokenGenerator->getCodeInfo($refreshToken); // FIXME: getCodeInfo should be named 'decrypt' or 'getInfo'?
336338
$userId = $tokenInfo['user_id'];
337339
break;

solid/tests/Unit/Controller/ServerControllerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ public function testRegisterWithRedirectUris()
348348
'registration_client_uri' => '',
349349
'response_types' => ['id_token token'],
350350
'token_endpoint_auth_method' => 'client_secret_basic',
351+
'client_secret' => '3b5798fddd49e23662ee6fe801085100',
351352
],
352353
'headers' => [
353354
'Cache-Control' => 'no-cache, no-store, must-revalidate',

0 commit comments

Comments
 (0)