From ef26ac4178bca72499d1b7aecc925fb140b0bee0 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Sat, 28 Jun 2025 09:53:02 +0200 Subject: [PATCH 1/6] remove specific flow --- solid/lib/Controller/ServerController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/solid/lib/Controller/ServerController.php b/solid/lib/Controller/ServerController.php index b4dc255b..55687119 100644 --- a/solid/lib/Controller/ServerController.php +++ b/solid/lib/Controller/ServerController.php @@ -109,9 +109,7 @@ private function createAuthServerConfig() { if (isset($_GET['client_id'])) { $clientId = $_GET['client_id']; } else if (isset($_POST['client_id'])) { - if (isset($_POST['refresh_token'])) { // FIXME: Why does the test suite break without this? - $clientId = $_POST['client_id']; - } + $clientId = $_POST['client_id']; } $client = $this->getClient($clientId); $keys = $this->getKeys(); From e8d734ab6b8d0e47f1720f29f104f1318e940189 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Sat, 28 Jun 2025 10:24:50 +0200 Subject: [PATCH 2/6] enable debugging so we see more in the ci/cd run --- env-vars-testers.list | 1 + 1 file changed, 1 insertion(+) diff --git a/env-vars-testers.list b/env-vars-testers.list index a8a79563..7c7d9252 100644 --- a/env-vars-testers.list +++ b/env-vars-testers.list @@ -9,3 +9,4 @@ SERVER_ROOT_ESCAPED=https:\/\/server SERVER_ROOT=https://server STORAGE_ROOT=https://server/apps/solid/~alice/storage/ SKIP_CONC=1 +DEBUG=* \ No newline at end of file From 563886a436f74aebb7bf3e9d4547f311d039d3e5 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Sun, 29 Jun 2025 09:31:12 +0200 Subject: [PATCH 3/6] add client_secret, check for array key --- solid/lib/Controller/ServerController.php | 8 +++++--- solid/tests/Unit/Controller/ServerControllerTest.php | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/solid/lib/Controller/ServerController.php b/solid/lib/Controller/ServerController.php index 55687119..abbd6c60 100644 --- a/solid/lib/Controller/ServerController.php +++ b/solid/lib/Controller/ServerController.php @@ -321,17 +321,19 @@ public function session() { */ public function token() { $request = \Laminas\Diactoros\ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); - $grantType = $request->getParsedBody()['grant_type']; + $requestBody = $request->getParsedBody(); + $grantType = $requestBody['grant_type'] ? $requestBody['grant_type'] : null; + $clientId = $requestBody['client_id'] ? $requestBody['client_id'] : null; switch ($grantType) { case "authorization_code": - $code = $request->getParsedBody()['code']; + $code = $requestBody['code']; // FIXME: not sure if decoding this here is the way to go. // FIXME: because this is a public page, the nonce from the session is not available here. $codeInfo = $this->tokenGenerator->getCodeInfo($code); $userId = $codeInfo['user_id']; break; case "refresh_token": - $refreshToken = $request->getParsedBody()['refresh_token']; + $refreshToken = $requestBody['refresh_token']; $tokenInfo = $this->tokenGenerator->getCodeInfo($refreshToken); // FIXME: getCodeInfo should be named 'decrypt' or 'getInfo'? $userId = $tokenInfo['user_id']; break; diff --git a/solid/tests/Unit/Controller/ServerControllerTest.php b/solid/tests/Unit/Controller/ServerControllerTest.php index 2920b0dd..12886477 100644 --- a/solid/tests/Unit/Controller/ServerControllerTest.php +++ b/solid/tests/Unit/Controller/ServerControllerTest.php @@ -348,6 +348,7 @@ public function testRegisterWithRedirectUris() 'registration_client_uri' => '', 'response_types' => ['id_token token'], 'token_endpoint_auth_method' => 'client_secret_basic', + 'client_secret' => '3b5798fddd49e23662ee6fe801085100', ], 'headers' => [ 'Cache-Control' => 'no-cache, no-store, must-revalidate', From dd60cf257893db7e6a70937b29f693a30efa38f1 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Sun, 29 Jun 2025 09:39:38 +0200 Subject: [PATCH 4/6] empty commit for GHA weirdness From 2072675bf5a6749ecaf7d8244b7a26732df08757 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Sun, 29 Jun 2025 10:55:00 +0200 Subject: [PATCH 5/6] use isset --- solid/lib/Controller/ServerController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solid/lib/Controller/ServerController.php b/solid/lib/Controller/ServerController.php index abbd6c60..88ad3194 100644 --- a/solid/lib/Controller/ServerController.php +++ b/solid/lib/Controller/ServerController.php @@ -322,8 +322,8 @@ public function session() { public function token() { $request = \Laminas\Diactoros\ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); $requestBody = $request->getParsedBody(); - $grantType = $requestBody['grant_type'] ? $requestBody['grant_type'] : null; - $clientId = $requestBody['client_id'] ? $requestBody['client_id'] : null; + $grantType = isset($requestBody['grant_type']) ? $requestBody['grant_type'] : null; + $clientId = isset($requestBody['client_id']) ? $requestBody['client_id'] : null; switch ($grantType) { case "authorization_code": $code = $requestBody['code']; From c180eb167fab49d2a15ce156eabe9a38d9e0be12 Mon Sep 17 00:00:00 2001 From: Yvo Brevoort Date: Sun, 29 Jun 2025 10:57:53 +0200 Subject: [PATCH 6/6] fix test by adding grant_type authorization_code --- solid/tests/Unit/Controller/ServerControllerTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/solid/tests/Unit/Controller/ServerControllerTest.php b/solid/tests/Unit/Controller/ServerControllerTest.php index 12886477..4c3cf8c2 100644 --- a/solid/tests/Unit/Controller/ServerControllerTest.php +++ b/solid/tests/Unit/Controller/ServerControllerTest.php @@ -370,6 +370,7 @@ public function testToken() { $_POST['client_id'] = self::MOCK_CLIENT_ID; $_POST['code'] = ''; + $_POST['grant_type'] = 'authorization_code'; $_SERVER['HTTP_DPOP'] = 'mock dpop'; $_SESSION['nonce'] = 'mock nonce';