Skip to content

Commit d3c278d

Browse files
committed
fixes - webid test suite passing
1 parent 361b0ba commit d3c278d

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

lib/ClientRegistration.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public static function getRegistration($clientId) {
2626

2727
public static function saveClientRegistration($clientData) {
2828
self::connect();
29+
if (!isset($clientData['client_name'])) {
30+
$clientData['client_name'] = $clientData['origin'];
31+
}
2932
$query = self::$pdo->prepare(
3033
'INSERT INTO clients VALUES(:clientId, :origin, :clientData)'
3134
);

www/idp/index.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@
6262
\Lcobucci\JWT\Signer\Key\InMemory::plainText($keys['privateKey']
6363
));
6464

65-
$token = $jwtConfig->parser()->parse($_GET['request']);
66-
$_SESSION['nonce'] = $_GET['nonce'] ?? $token->claims()->get('nonce');
67-
65+
if (isset($_GET['nonce'])) {
66+
$_SESSION['nonce'] = $_GET['nonce'];
67+
} else if (isset($_GET['request'])) {
68+
$token = $jwtConfig->parser()->parse($_GET['request']);
69+
$_SESSION['nonce'] = $token->claims()->get('nonce');
70+
}
71+
6872
if (!isset($getVars["redirect_uri"])) {
6973
$getVars['redirect_uri'] = $token->claims()->get("redirect_uri");
7074
}
@@ -75,8 +79,18 @@
7579

7680
$authServer = Server::getAuthServer();
7781

82+
$approval = false;
7883
// check clientId approval for the user
79-
if (!in_array($clientId, ($user['allowedClients'] ?? []))) {
84+
if (in_array($clientId, ($user['allowedClients'] ?? []))) {
85+
$approval = true;
86+
} else {
87+
$clientRegistration = ClientRegistration::getRegistration($clientId);
88+
if (in_array($clientRegistration['origin'], TRUSTED_APPS)) {
89+
$approval = true;
90+
}
91+
}
92+
93+
if (!$approval) {
8094
header('Location: ' . BASEURL . '/sharing/' . "?" . http_build_query(
8195
array(
8296
"returnUrl" => urlencode($_SERVER["REQUEST_URI"]),
@@ -85,10 +99,8 @@
8599
)
86100
));
87101
exit();
88-
} else {
89-
$approval = true;
90102
}
91-
103+
92104
$webId = "https://id-" . $user['userId'] . "." . BASEDOMAIN . "/#me";
93105
$user = new \Pdsinterop\Solid\Auth\Entity\User();
94106
$user->setIdentifier($webId);
@@ -329,8 +341,8 @@
329341
'client_secret' => $client['client_secret'],
330342
'response_types' => array('code'),
331343
'grant_types' => array('authorization_code', 'refresh_token'),
332-
'application_type' => $client['application_type'],
333-
'client_name' => $client['client_name'],
344+
'application_type' => $client['application_type'] ?? 'web',
345+
'client_name' => $client['client_name'] ?? $client['client_id'],
334346
'id_token_signed_response_alg' => 'RS256',
335347
'token_endpoint_auth_method' => 'client_secret_basic',
336348
'client_id_issued_at' => $client['client_id_issued_at'],

0 commit comments

Comments
 (0)