-
Notifications
You must be signed in to change notification settings - Fork 138
Add support for asynchronous SLO profile #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
71753bf
Import schema
tvdijen 9bfe530
Update class-registry
tvdijen 4450458
Add abstract and NS-constant
tvdijen 599a3b5
Implement Asynchronous SLO schema items
tvdijen c637668
Fix typos
tvdijen ec7f6ae
Fix codesniffer
tvdijen 1157ff0
Fix static analysis issues
tvdijen f095f71
Add unit-test for SingleLogoutService
tvdijen 3eb4eca
Refactor
tvdijen 2e7dd45
Add unit-test for AuthnRequest containing aslo:Asynchronous
tvdijen 80772e1
Fix codesniffer issues
tvdijen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,13 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <schema xmlns:aslo="urn:oasis:names:tc:SAML:2.0:protocol:ext:async-slo" | ||
| xmlns="http://www.w3.org/2001/XMLSchema" | ||
| targetNamespace="urn:oasis:names:tc:SAML:2.0:protocol:ext:async-slo" | ||
| elementFormDefault="qualified"> | ||
|
|
||
| <element name="Asynchronous" type="aslo:AsynchronousType" /> | ||
| <complexType name="AsynchronousType" /> | ||
|
|
||
| <attribute name="supportsAsynchronous" type="boolean"/> | ||
|
|
||
| </schema> |
This file contains hidden or 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 hidden or 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,23 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace SimpleSAML\SAML2\XML\aslo; | ||
|
|
||
| use SimpleSAML\SAML2\Constants as C; | ||
| use SimpleSAML\XML\AbstractElement; | ||
|
|
||
| /** | ||
| * Abstract class to be implemented by all the classes in this namespace | ||
| * | ||
| * @see https://docs.oasis-open.org/security/saml/Post2.0/saml-async-slo/v1.0/saml-async-slo-v1.0.pdf | ||
| * @package simplesamlphp/saml2 | ||
| */ | ||
| abstract class AbstractAsloElement extends AbstractElement | ||
| { | ||
| public const string NS = C::NS_ASLO; | ||
|
|
||
| public const string NS_PREFIX = 'aslo'; | ||
|
|
||
| public const string SCHEMA = 'resources/schemas/saml-async-slo-v1.0.xsd'; | ||
| } |
This file contains hidden or 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,45 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace SimpleSAML\SAML2\XML\aslo; | ||
|
|
||
| use Dom; | ||
| use SimpleSAML\SAML2\Assert\Assert; | ||
| use SimpleSAML\XML\SchemaValidatableElementInterface; | ||
| use SimpleSAML\XML\SchemaValidatableElementTrait; | ||
| use SimpleSAML\XMLSchema\Exception\InvalidDOMElementException; | ||
|
|
||
| /** | ||
| * Class representing a aslo:Asynchronous element. | ||
| * | ||
| * @package simplesaml/saml2 | ||
| */ | ||
| final class Asynchronous extends AbstractAsloElement implements SchemaValidatableElementInterface | ||
| { | ||
| use SchemaValidatableElementTrait; | ||
|
|
||
|
|
||
| /** | ||
| * Convert XML into a Asynchronous | ||
| * | ||
| * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException | ||
| * if the qualified name of the supplied element is wrong | ||
| */ | ||
| public static function fromXML(Dom\Element $xml): static | ||
| { | ||
| Assert::same($xml->localName, 'Asynchronous', InvalidDOMElementException::class); | ||
| Assert::same($xml->namespaceURI, Asynchronous::NS, InvalidDOMElementException::class); | ||
|
|
||
| return new static(); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Convert this Asynchronous to XML. | ||
| */ | ||
| public function toXML(?Dom\Element $parent = null): Dom\Element | ||
| { | ||
| return $this->instantiateParentElement($parent); | ||
| } | ||
| } | ||
This file contains hidden or 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,40 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace SimpleSAML\SAML2\XML\aslo; | ||
|
|
||
| use SimpleSAML\SAML2\Constants as C; | ||
| use SimpleSAML\XMLSchema\Type\BooleanValue; | ||
|
|
||
| /** | ||
| * @package simplesamlphp/saml2 | ||
| */ | ||
| trait SupportsAsynchronousTrait | ||
| { | ||
| /** @var \SimpleSAML\XMLSchema\Type\BooleanValue|null */ | ||
| protected ?BooleanValue $supportsAsynchronous = null; | ||
|
|
||
|
|
||
| /** | ||
| * @return \SimpleSAML\XMLSchema\Type\BooleanValue|null | ||
| */ | ||
| public function getSupportsAsynchronous(): ?BooleanValue | ||
| { | ||
| return $this->supportsAsynchronous; | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * @param array<\SimpleSAML\XML\Attribute> $namespacedAttributes | ||
| */ | ||
| private function setSupportsAsynchronous(array $namespacedAttributes = []): void | ||
| { | ||
| foreach ($namespacedAttributes as $attr) { | ||
| if ($attr->getNamespaceURI() === C::NS_ASLO && $attr->getAttrName() === 'supportsAsynchronous') { | ||
| $this->supportsAsynchronous = BooleanValue::fromString($attr->getAttrValue()->getValue()); | ||
| return; | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,57 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace SimpleSAML\SAML2\Test\SAML2\XML\aslo; | ||
|
|
||
| use PHPUnit\Framework\Attributes\CoversClass; | ||
| use PHPUnit\Framework\Attributes\Group; | ||
| use PHPUnit\Framework\TestCase; | ||
| use SimpleSAML\SAML2\XML\aslo\AbstractAsloElement; | ||
| use SimpleSAML\SAML2\XML\aslo\Asynchronous; | ||
| use SimpleSAML\XML\DOMDocumentFactory; | ||
| use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
| use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
|
|
||
| use function dirname; | ||
| use function strval; | ||
|
|
||
| /** | ||
| * Class \SimpleSAML\SAML2\XML\aslo\AsynchronousTest | ||
| * | ||
| * @package simplesamlphp/saml2 | ||
| */ | ||
| #[Group('aslo')] | ||
| #[CoversClass(Asynchronous::class)] | ||
| #[CoversClass(AbstractAsloElement::class)] | ||
| final class AsynchronousTest extends TestCase | ||
| { | ||
| use SchemaValidationTestTrait; | ||
| use SerializableElementTestTrait; | ||
|
|
||
|
|
||
| /** | ||
| */ | ||
| public static function setUpBeforeClass(): void | ||
| { | ||
| self::$testedClass = Asynchronous::class; | ||
|
|
||
| self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
| dirname(__FILE__, 4) . '/resources/xml/aslo_Asynchronous.xml', | ||
| ); | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| */ | ||
| public function testMarshalling(): void | ||
| { | ||
| $asynchronous = new Asynchronous(); | ||
|
|
||
| $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); | ||
| $this->assertNotFalse($expectedXml); | ||
| $actualXml = strval($asynchronous); | ||
|
|
||
| $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); | ||
| } | ||
| } |
This file contains hidden or 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,78 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace SimpleSAML\Test\SAML2\XML\md; | ||
|
|
||
| use PHPUnit\Framework\Attributes\CoversClass; | ||
| use PHPUnit\Framework\Attributes\Group; | ||
| use PHPUnit\Framework\TestCase; | ||
| use SimpleSAML\SAML2\Type\SAMLAnyURIValue; | ||
| use SimpleSAML\SAML2\XML\md\AbstractMdElement; | ||
| use SimpleSAML\SAML2\XML\md\SingleLogoutService; | ||
| use SimpleSAML\Test\SAML2\Constants as C; | ||
| use SimpleSAML\XML\Attribute as XMLAttribute; | ||
| use SimpleSAML\XML\DOMDocumentFactory; | ||
| use SimpleSAML\XML\TestUtils\SchemaValidationTestTrait; | ||
| use SimpleSAML\XML\TestUtils\SerializableElementTestTrait; | ||
| use SimpleSAML\XMLSchema\Type\BooleanValue; | ||
|
|
||
| use function dirname; | ||
| use function strval; | ||
|
|
||
| /** | ||
| * Tests for md:SingleLogoutService. | ||
| * | ||
| * @package simplesamlphp/saml2 | ||
| */ | ||
| #[Group('md')] | ||
| #[CoversClass(SingleLogoutService::class)] | ||
| #[CoversClass(AbstractMdElement::class)] | ||
| final class SingleLogoutServiceTest extends TestCase | ||
| { | ||
| use SchemaValidationTestTrait; | ||
| use SerializableElementTestTrait; | ||
|
|
||
|
|
||
| /** | ||
| */ | ||
| public static function setUpBeforeClass(): void | ||
| { | ||
| self::$testedClass = SingleLogoutService::class; | ||
|
|
||
| self::$xmlRepresentation = DOMDocumentFactory::fromFile( | ||
| dirname(__FILE__, 4) . '/resources/xml/md_SingleLogoutService.xml', | ||
| ); | ||
| } | ||
|
|
||
|
|
||
| // test marshalling | ||
|
|
||
|
|
||
| /** | ||
| * Test creating a SingleLogoutService from scratch. | ||
| */ | ||
| public function testMarshalling(): void | ||
| { | ||
| $supportsAsynchronous = new XMLAttribute( | ||
| C::NS_ASLO, | ||
| 'aslo', | ||
| 'supportsAsynchronous', | ||
| BooleanValue::fromBoolean(true), | ||
| ); | ||
|
|
||
| $sloep = new SingleLogoutService( | ||
| SAMLAnyURIValue::fromString(C::BINDING_HTTP_POST), | ||
| SAMLAnyURIValue::fromString(C::LOCATION_A), | ||
| SAMLAnyURIValue::fromString(C::LOCATION_B), | ||
| [], | ||
| [$supportsAsynchronous], | ||
| ); | ||
|
|
||
| $expectedXml = self::$xmlRepresentation->saveXml(self::$xmlRepresentation->documentElement); | ||
| $this->assertNotFalse($expectedXml); | ||
| $actualXml = strval($sloep); | ||
|
|
||
| $this->assertXmlStringEqualsXmlString($expectedXml, $actualXml); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.