|
27 | 27 | use OC\Core\Controller\ClientFlowLoginV2Controller; |
28 | 28 | use OCA\User_SAML\Exceptions\NoUserFoundException; |
29 | 29 | use OCA\User_SAML\Exceptions\UserFilterViolationException; |
| 30 | +use OCA\User_SAML\Helper\TXmlHelper; |
30 | 31 | use OCA\User_SAML\SAMLSettings; |
31 | 32 | use OCA\User_SAML\UserBackend; |
32 | 33 | use OCA\User_SAML\UserData; |
|
47 | 48 | use OneLogin\Saml2\ValidationError; |
48 | 49 |
|
49 | 50 | class SAMLController extends Controller { |
| 51 | + use TXmlHelper; |
| 52 | + |
50 | 53 | /** @var ISession */ |
51 | 54 | private $session; |
52 | 55 | /** @var IUserSession */ |
@@ -289,7 +292,9 @@ public function login(int $idp = 1) { |
289 | 292 | public function getMetadata(int $idp = 1) { |
290 | 293 | $settings = new Settings($this->samlSettings->getOneLoginSettingsArray($idp)); |
291 | 294 | $metadata = $settings->getSPMetadata(); |
292 | | - $errors = $settings->validateMetadata($metadata); |
| 295 | + $errors = $this->callWithXmlEntityLoader(function () use ($settings, $metadata) { |
| 296 | + return $settings->validateMetadata($metadata); |
| 297 | + }); |
293 | 298 | if (empty($errors)) { |
294 | 299 | return new Http\DataDownloadResponse($metadata, 'metadata.xml', 'text/xml'); |
295 | 300 | } else { |
@@ -350,7 +355,10 @@ public function assertionConsumerService(): Http\RedirectResponse { |
350 | 355 | } |
351 | 356 |
|
352 | 357 | $auth = new Auth($this->samlSettings->getOneLoginSettingsArray($idp)); |
353 | | - $auth->processResponse($AuthNRequestID); |
| 358 | + // validator (called with processResponse()) needs an XML entity loader |
| 359 | + $this->callWithXmlEntityLoader(function () use ($auth, $AuthNRequestID): void { |
| 360 | + $auth->processResponse($AuthNRequestID); |
| 361 | + }); |
354 | 362 |
|
355 | 363 | $this->logger->debug('Attributes send by the IDP: ' . json_encode($auth->getAttributes())); |
356 | 364 |
|
@@ -510,13 +518,16 @@ private function tryProcessSLOResponse(?int $idp): array { |
510 | 518 | foreach ($idps as $idp) { |
511 | 519 | try { |
512 | 520 | $auth = new Auth($this->samlSettings->getOneLoginSettingsArray($idp)); |
513 | | - $targetUrl = $auth->processSLO( |
514 | | - true, // do not let processSLO to delete the entire session. Let userSession->logout do the job |
515 | | - null, |
516 | | - $this->samlSettings->usesSloWebServerDecode($idp), |
517 | | - null, |
518 | | - true |
519 | | - ); |
| 521 | + // validator (called with processSLO()) needs an XML entity loader |
| 522 | + $targetUrl = $this->callWithXmlEntityLoader(function () use ($auth, $idp): string { |
| 523 | + return $auth->processSLO( |
| 524 | + true, // do not let processSLO to delete the entire session. Let userSession->logout do the job |
| 525 | + null, |
| 526 | + $this->samlSettings->usesSloWebServerDecode($idp), |
| 527 | + null, |
| 528 | + true |
| 529 | + ); |
| 530 | + }); |
520 | 531 | if ($auth->getLastErrorReason() === null) { |
521 | 532 | return [$targetUrl, $auth]; |
522 | 533 | } |
|
0 commit comments