Skip to content

Commit 2f448a2

Browse files
committed
find client ID from encrypted code/token data if not posted in the main body
1 parent 961b890 commit 2f448a2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

solid/lib/Controller/ServerController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,26 +325,31 @@ public function session() {
325325
public function token() {
326326
$request = \Laminas\Diactoros\ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
327327
$grantType = $request->getParsedBody()['grant_type'];
328+
$clientId = $request->getParsedBody()['client_id'];
328329
switch ($grantType) {
329330
case "authorization_code":
330331
$code = $request->getParsedBody()['code'];
331332
// FIXME: not sure if decoding this here is the way to go.
332333
// FIXME: because this is a public page, the nonce from the session is not available here.
333334
$codeInfo = $this->tokenGenerator->getCodeInfo($code);
334335
$userId = $codeInfo['user_id'];
336+
if (!$clientId) {
337+
$clientId = $codeInfo['client_id'];
338+
}
335339
break;
336340
case "refresh_token":
337341
$refreshToken = $request->getParsedBody()['refresh_token'];
338342
$tokenInfo = $this->tokenGenerator->getCodeInfo($refreshToken); // FIXME: getCodeInfo should be named 'decrypt' or 'getInfo'?
339343
$userId = $tokenInfo['user_id'];
344+
if (!$clientId) {
345+
$clientId = $tokenInfo['client_id'];
346+
}
340347
break;
341348
default:
342349
$userId = false;
343350
break;
344351
}
345352

346-
$clientId = $request->getParsedBody()['client_id'];
347-
348353
$httpDpop = $request->getServerParams()['HTTP_DPOP'];
349354

350355
$response = new \Laminas\Diactoros\Response();

0 commit comments

Comments
 (0)