-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
receive logout response and session termination
- Loading branch information
Showing
11 changed files
with
277 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...ightSaml/Logout/Action/Profile/Inbound/LogoutResponse/RemoveSsoSessionFromStoreAction.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the LightSAML-Logout package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the GPL-3 license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace LightSaml\Logout\Action\Profile\Inbound\LogoutResponse; | ||
|
||
use LightSaml\Action\Profile\AbstractProfileAction; | ||
use LightSaml\Context\Profile\Helper\LogHelper; | ||
use LightSaml\Context\Profile\Helper\MessageContextHelper; | ||
use LightSaml\Context\Profile\ProfileContext; | ||
use LightSaml\Error\LightSamlContextException; | ||
use LightSaml\Logout\Resolver\Logout\LogoutSessionResolverInterface; | ||
use LightSaml\State\Request\RequestStateParameters; | ||
use LightSaml\Store\Request\RequestStateStoreInterface; | ||
use Psr\Log\LoggerInterface; | ||
|
||
class RemoveSsoSessionFromStoreAction extends AbstractProfileAction | ||
{ | ||
/** @var RequestStateStoreInterface */ | ||
private $requestStore; | ||
|
||
/** @var LogoutSessionResolverInterface */ | ||
private $logoutResolver; | ||
|
||
/** | ||
* @param LoggerInterface $logger | ||
* @param RequestStateStoreInterface $requestStore | ||
* @param LogoutSessionResolverInterface $logoutResolver | ||
*/ | ||
public function __construct(LoggerInterface $logger, RequestStateStoreInterface $requestStore, LogoutSessionResolverInterface $logoutResolver) | ||
{ | ||
parent::__construct($logger); | ||
|
||
$this->requestStore = $requestStore; | ||
$this->logoutResolver = $logoutResolver; | ||
} | ||
|
||
protected function doExecute(ProfileContext $context) | ||
{ | ||
$logoutResponse = MessageContextHelper::asLogoutResponse($context->getInboundContext()); | ||
$id = $logoutResponse->getInResponseTo(); | ||
$requestState = $this->requestStore->get($id); | ||
$partyEntityId = $requestState->getParameters()->get(RequestStateParameters::PARTY); | ||
if ($partyEntityId && $logoutResponse->getIssuer() && $partyEntityId != $logoutResponse->getIssuer()->getValue()) { | ||
$message = sprintf( | ||
'LogoutRequest sent to %s but LogoutResponse for that request was issued by %s', | ||
$partyEntityId, | ||
$logoutResponse->getIssuer()->getValue() | ||
); | ||
$this->logger->critical($message, LogHelper::getActionErrorContext($context, $this, [ | ||
'sent_to' => $partyEntityId, | ||
'received_from' => $logoutResponse->getIssuer()->getValue(), | ||
])); | ||
throw new LightSamlContextException($context, $message); | ||
} | ||
|
||
$nameId = $requestState->getParameters()->get(RequestStateParameters::NAME_ID); | ||
$nameIdFormat = $requestState->getParameters()->get(RequestStateParameters::NAME_ID_FORMAT); | ||
$sessionIndex = $requestState->getParameters()->get(RequestStateParameters::SESSION_INDEX); | ||
|
||
$numberOfTerminatedSessions = $this->logoutResolver->terminateSession( | ||
$logoutResponse->getIssuer()->getValue(), | ||
$nameId, | ||
$nameIdFormat, | ||
$sessionIndex | ||
); | ||
|
||
$this->logger->debug( | ||
sprintf( | ||
'Processing LogoutResponse from %s for %s in format %s and session index %s resulted in termination of %s sso session from the store', | ||
$partyEntityId, | ||
$nameId, | ||
$nameIdFormat, | ||
$sessionIndex, | ||
$numberOfTerminatedSessions | ||
), | ||
LogHelper::getActionContext($context, $this) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/LightSaml/Logout/Builder/Action/Profile/SingleLogout/SloResponseActionBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the LightSAML-Logout package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the GPL-3 license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace LightSaml\Logout\Builder\Action\Profile\SingleLogout; | ||
|
||
use LightSaml\Action\Profile\FlushRequestStatesAction; | ||
use LightSaml\Action\Profile\Inbound\Message\EntityIdFromMessageIssuerAction; | ||
use LightSaml\Action\Profile\Inbound\Message\IssuerValidatorAction; | ||
use LightSaml\Action\Profile\Inbound\Message\MessageSignatureValidatorAction; | ||
use LightSaml\Action\Profile\Inbound\Message\ReceiveMessageAction; | ||
use LightSaml\Action\Profile\Inbound\Message\ResolvePartyEntityIdAction; | ||
use LightSaml\Action\Profile\Inbound\StatusResponse\InResponseToValidatorAction; | ||
use LightSaml\Action\Profile\Inbound\StatusResponse\StatusAction; | ||
use LightSaml\Builder\Action\Profile\AbstractProfileActionBuilder; | ||
use LightSaml\Logout\Action\Profile\Inbound\LogoutResponse\RemoveSsoSessionFromStoreAction; | ||
use LightSaml\SamlConstants; | ||
|
||
class SloResponseActionBuilder extends AbstractProfileActionBuilder | ||
{ | ||
protected function doInitialize() | ||
{ | ||
$this->add(new ReceiveMessageAction( | ||
$this->buildContainer->getSystemContainer()->getLogger(), | ||
$this->buildContainer->getServiceContainer()->getBindingFactory() | ||
), 100); | ||
|
||
// Response validation | ||
$this->add(new IssuerValidatorAction( | ||
$this->buildContainer->getSystemContainer()->getLogger(), | ||
$this->buildContainer->getServiceContainer()->getNameIdValidator(), | ||
SamlConstants::NAME_ID_FORMAT_ENTITY | ||
), 200); | ||
$this->add(new EntityIdFromMessageIssuerAction( | ||
$this->buildContainer->getSystemContainer()->getLogger() | ||
)); | ||
$this->add(new ResolvePartyEntityIdAction( | ||
$this->buildContainer->getSystemContainer()->getLogger(), | ||
$this->buildContainer->getPartyContainer()->getSpEntityDescriptorStore(), | ||
$this->buildContainer->getPartyContainer()->getIdpEntityDescriptorStore(), | ||
$this->buildContainer->getPartyContainer()->getTrustOptionsStore() | ||
)); | ||
$this->add(new InResponseToValidatorAction( | ||
$this->buildContainer->getSystemContainer()->getLogger(), | ||
$this->buildContainer->getStoreContainer()->getRequestStateStore() | ||
)); | ||
$this->add(new StatusAction( | ||
$this->buildContainer->getSystemContainer()->getLogger() | ||
)); | ||
$this->add(new MessageSignatureValidatorAction( | ||
$this->buildContainer->getSystemContainer()->getLogger(), | ||
$this->buildContainer->getServiceContainer()->getSignatureValidator() | ||
)); | ||
$this->add(new RemoveSsoSessionFromStoreAction( | ||
$this->buildContainer->getSystemContainer()->getLogger(), | ||
$this->buildContainer->getStoreContainer()->getRequestStateStore(), | ||
$this->buildContainer->getServiceContainer()->getLogoutSessionResolver() | ||
)); | ||
$this->add(new FlushRequestStatesAction( | ||
$this->buildContainer->getSystemContainer()->getLogger(), | ||
$this->buildContainer->getStoreContainer()->getRequestStateStore() | ||
)); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/LightSaml/Logout/Builder/Profile/WebBrowserSlo/SloResponseProfileBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the LightSAML-Logout package. | ||
* | ||
* (c) Milos Tomic <[email protected]> | ||
* | ||
* This source file is subject to the GPL-3 license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace LightSaml\Logout\Builder\Profile\WebBrowserSlo; | ||
|
||
use LightSaml\Builder\Profile\AbstractProfileBuilder; | ||
use LightSaml\Context\Profile\ProfileContext; | ||
use LightSaml\Logout\Builder\Action\Profile\SingleLogout\SloResponseActionBuilder; | ||
use LightSaml\Logout\Profile\Profiles; | ||
|
||
class SloResponseProfileBuilder extends AbstractProfileBuilder | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
protected function getProfileId() | ||
{ | ||
return Profiles::SLO_RECEIVE_LOGOUT_RESPONSE; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getProfileRole() | ||
{ | ||
return ProfileContext::ROLE_NONE; | ||
} | ||
|
||
/** | ||
* @return \LightSaml\Builder\Action\ActionBuilderInterface | ||
*/ | ||
protected function getActionBuilder() | ||
{ | ||
return new SloResponseActionBuilder($this->container); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters