|
62 | 62 | \Lcobucci\JWT\Signer\Key\InMemory::plainText($keys['privateKey'] |
63 | 63 | )); |
64 | 64 |
|
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 | + |
68 | 72 | if (!isset($getVars["redirect_uri"])) { |
69 | 73 | $getVars['redirect_uri'] = $token->claims()->get("redirect_uri"); |
70 | 74 | } |
|
75 | 79 |
|
76 | 80 | $authServer = Server::getAuthServer(); |
77 | 81 |
|
| 82 | + $approval = false; |
78 | 83 | // 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) { |
80 | 94 | header('Location: ' . BASEURL . '/sharing/' . "?" . http_build_query( |
81 | 95 | array( |
82 | 96 | "returnUrl" => urlencode($_SERVER["REQUEST_URI"]), |
|
85 | 99 | ) |
86 | 100 | )); |
87 | 101 | exit(); |
88 | | - } else { |
89 | | - $approval = true; |
90 | 102 | } |
91 | | - |
| 103 | + |
92 | 104 | $webId = "https://id-" . $user['userId'] . "." . BASEDOMAIN . "/#me"; |
93 | 105 | $user = new \Pdsinterop\Solid\Auth\Entity\User(); |
94 | 106 | $user->setIdentifier($webId); |
|
329 | 341 | 'client_secret' => $client['client_secret'], |
330 | 342 | 'response_types' => array('code'), |
331 | 343 | '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'], |
334 | 346 | 'id_token_signed_response_alg' => 'RS256', |
335 | 347 | 'token_endpoint_auth_method' => 'client_secret_basic', |
336 | 348 | 'client_id_issued_at' => $client['client_id_issued_at'], |
|
0 commit comments