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