Skip to content

Commit 9bb9a25

Browse files
committed
add client_secret, check for array key
1 parent 2f448a2 commit 9bb9a25

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

solid/lib/Controller/ServerController.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,12 @@ public function session() {
324324
*/
325325
public function token() {
326326
$request = \Laminas\Diactoros\ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
327-
$grantType = $request->getParsedBody()['grant_type'];
328-
$clientId = $request->getParsedBody()['client_id'];
327+
$requestBody = $request->getParsedBody();
328+
$grantType = $requestBody['grant_type'] ? $requestBody['grant_type'] : null;
329+
$clientId = $requestBody['client_id'] ? $requestBody['client_id'] : null;
329330
switch ($grantType) {
330331
case "authorization_code":
331-
$code = $request->getParsedBody()['code'];
332+
$code = $requestBody['code'];
332333
// FIXME: not sure if decoding this here is the way to go.
333334
// FIXME: because this is a public page, the nonce from the session is not available here.
334335
$codeInfo = $this->tokenGenerator->getCodeInfo($code);
@@ -338,7 +339,7 @@ public function token() {
338339
}
339340
break;
340341
case "refresh_token":
341-
$refreshToken = $request->getParsedBody()['refresh_token'];
342+
$refreshToken = $requestBody['refresh_token'];
342343
$tokenInfo = $this->tokenGenerator->getCodeInfo($refreshToken); // FIXME: getCodeInfo should be named 'decrypt' or 'getInfo'?
343344
$userId = $tokenInfo['user_id'];
344345
if (!$clientId) {

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)