|
16 | 16 | use OCP\IURLGenerator; |
17 | 17 | use OCP\IUserManager; |
18 | 18 |
|
| 19 | +use OCP\AppFramework\Http\EmptyContentSecurityPolicy; |
| 20 | + |
19 | 21 | use Pdsinterop\Solid\Auth\WAC; |
20 | 22 | use Pdsinterop\Solid\Resources\Server as ResourceServer; |
21 | 23 |
|
@@ -333,7 +335,9 @@ public function handleRequest($userId, $path) { |
333 | 335 | $allowedOrigins = array(); |
334 | 336 | foreach ($allowedClients as $clientId) { |
335 | 337 | $clientRegistration = $this->config->getClientRegistration($clientId); |
336 | | - $allowedOrigins[] = $clientRegistration['client_name']; |
| 338 | + if (isset($clientRegistration['client_name'])) { |
| 339 | + $allowedOrigins[] = $clientRegistration['client_name']; |
| 340 | + } |
337 | 341 | } |
338 | 342 | if (!$this->WAC->isAllowed($request, $webId, $origin, $allowedOrigins)) { |
339 | 343 | $response = $this->resourceServer->getResponse() |
@@ -424,7 +428,19 @@ private function respond($response) { |
424 | 428 | // $result->addHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization'); |
425 | 429 | // $result->addHeader('Access-Control-Allow-Origin', $origin); |
426 | 430 |
|
427 | | - $result->setStatus($statusCode); |
| 431 | + $policy = new EmptyContentSecurityPolicy(); |
| 432 | + $policy->addAllowedStyleDomain("*"); |
| 433 | + $policy->addAllowedStyleDomain("data:"); |
| 434 | + $policy->addAllowedScriptDomain("*"); |
| 435 | + $policy->addAllowedImageDomain("*"); |
| 436 | + $policy->addAllowedFontDomain("*"); |
| 437 | + $policy->addAllowedConnectDomain("*"); |
| 438 | + $policy->allowInlineStyle(true); |
| 439 | + $policy->allowInlineScript(true); |
| 440 | + $policy->allowEvalScript(true); |
| 441 | + $result->setContentSecurityPolicy($policy); |
| 442 | + |
| 443 | + $result->setStatus($statusCode); |
428 | 444 | return $result; |
429 | 445 | } |
430 | 446 | } |
0 commit comments