Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/qa-config/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@
\Rector\Php81\Rector\Property\ReadOnlyPropertyRector::class,
\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class,
\Rector\Php82\Rector\Class_\ReadOnlyClassRector::class,
\Rector\Php84\Rector\MethodCall\NewMethodCallWithoutParenthesesRector::class,
\Rector\Php84\Rector\Class_\DeprecatedAnnotationToDeprecatedAttributeRector::class,
]);
8 changes: 8 additions & 0 deletions library/EngineBlock/Application/FunctionalTestDiContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,31 @@
*/
class EngineBlock_Application_FunctionalTestDiContainer extends EngineBlock_Application_DiContainer
{
#[Override]
public function getUserDirectory()
{
return new FakeUserDirectory(new Filesystem());
}

#[Override]
public function getFeatureConfiguration()
{
return $this->getSymfonyContainer()->get('engineblock.functional_testing.fixture.features');
}

#[Override]
public function getAuthenticationLoopGuard()
{
return $this->getSymfonyContainer()->get('engineblock.functional_testing.fixture.authentication_loop_guard');
}

#[Override]
public function getPdpClient()
{
return $this->getFunctionalTestingPdpClient();
}

#[Override]
public function getPdpClientId()
{
return 'Federation';
Expand All @@ -53,11 +58,13 @@ public function getPdpClientId()
/**
* @return \OpenConext\EngineBlockBundle\AttributeAggregation\AttributeAggregationClientInterface
*/
#[Override]
public function getAttributeAggregationClient()
{
return $this->getSymfonyContainer()->get('engineblock.functional_testing.fixture.attribute_aggregation_client');
}

#[Override]
public function getAuthnContextClassRefBlacklistRegex()
{
return '/invalid-authn-context-class-ref/';
Expand All @@ -71,6 +78,7 @@ public function getAuthnContextClassRefBlacklistRegex()
*
* @return array
*/
#[Override]
public function getEncryptionKeysConfiguration()
{
$basePath = $this->container->getParameter('kernel.project_dir');
Expand Down
7 changes: 7 additions & 0 deletions library/EngineBlock/Application/TestDiContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@ class EngineBlock_Application_TestDiContainer extends EngineBlock_Application_Di
*/
private $pdpClient;

#[Override]
public function getXmlConverter(): EngineBlock_Corto_XmlToArray
{
return Phake::mock('EngineBlock_Corto_XmlToArray');
}

#[Override]
public function getFilterCommandFactory(): EngineBlock_Corto_Filter_Command_Factory
{
return Phake::mock('EngineBlock_Corto_Filter_Command_Factory');
}

#[Override]
public function getDatabaseConnectionFactory(): EngineBlock_Database_ConnectionFactory
{
return Phake::mock('EngineBlock_Database_ConnectionFactory');
}

#[Override]
public function getPdpClient()
{
return $this->pdpClient ?? parent::getPdpClient();
Expand All @@ -53,6 +57,7 @@ public function setPdpClient(?PdpClientInterface $pdpClient)
$this->pdpClient = $pdpClient;
}

#[Override]
public function getConsentFactory(): EngineBlock_Corto_Model_Consent_Factory
{
$consentFactoryMock = Phake::mock('EngineBlock_Corto_Model_Consent_Factory');
Expand All @@ -67,6 +72,7 @@ public function getConsentFactory(): EngineBlock_Corto_Model_Consent_Factory
/**
* @return EngineBlock_Attributes_Metadata
*/
#[Override]
public function getAttributeMetadata()
{
// returns a realistic representation of the attribute metadata
Expand All @@ -82,6 +88,7 @@ public function getAttributeMetadata()
*
* @return array
*/
#[Override]
public function getEncryptionKeysConfiguration()
{
$basePath = $this->container->getParameter('kernel.project_dir');
Expand Down
2 changes: 1 addition & 1 deletion library/EngineBlock/Corto/Filter/Command/LogLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function execute()
$logAttributes = [];
if (!empty($this->configuredLogAttributes)) {
foreach ($this->configuredLogAttributes as $attributeLabel => $responseAttributeKey) {
if (array_key_exists($responseAttributeKey, $this->_responseAttributes)) {
if (array_key_exists((string) $responseAttributeKey, $this->_responseAttributes)) {
$attributeValues = implode(',', $this->_responseAttributes[$responseAttributeKey]);
$logAttributes[$attributeLabel] = $attributeValues;
}
Expand Down
1 change: 1 addition & 0 deletions library/EngineBlock/Corto/Filter/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
class EngineBlock_Corto_Filter_Output extends EngineBlock_Corto_Filter_Abstract
{
#[Override]
public function filter(
EngineBlock_Saml2_ResponseAnnotationDecorator &$response,
array &$responseAttributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class EngineBlock_Corto_Mapper_Metadata_Entity_IdpSsoDescriptor extends EngineBl
/**
* @var AbstractRole
*/
#[Override]
protected $_entity;

public function __construct(AbstractRole $entity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class EngineBlock_Corto_Mapper_Metadata_Entity_SpSsoDescriptor extends EngineBlo
/**
* @var AbstractRole
*/
#[Override]
protected $_entity;

public function __construct(AbstractRole $entity)
Expand Down
10 changes: 2 additions & 8 deletions library/EngineBlock/Corto/Module/Bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class EngineBlock_Corto_Module_Bindings extends EngineBlock_Corto_Module_Abstrac
/**
* @var EngineBlock_Corto_ProxyServer
*/
#[Override]
protected $_server;

/**
Expand Down Expand Up @@ -895,14 +896,7 @@ protected function getSaml2OwnMetadata($serviceEntityId, $requireEncryption = tr
*/
private function hasEncryptedAssertion(Response $sspResponse)
{
$hasEncryptedAssertion = false;
foreach ($sspResponse->getAssertions() as $assertion) {
if ($assertion instanceof EncryptedAssertion) {
$hasEncryptedAssertion = true;
break;
}
}
return $hasEncryptedAssertion;
return array_any($sspResponse->getAssertions(), fn($assertion) => $assertion instanceof EncryptedAssertion);
}

/**
Expand Down
28 changes: 22 additions & 6 deletions library/EngineBlock/Saml2/AuthnRequestAnnotationDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class EngineBlock_Saml2_AuthnRequestAnnotationDecorator extends EngineBlock_Saml
/**
* @var AuthnRequest
*/
#[Override]
protected $sspMessage;

/**
Expand Down Expand Up @@ -199,30 +200,45 @@ public function setForceAuthn(bool $isForceAuthn)
/**
* @return array
*/
public function __sleep()
public function __serialize(): array
{
if ($this->sspMessage instanceof AuthnRequest) {
$this->_serializableSspMessageXml = $this->sspMessage->toUnsignedXML()->ownerDocument->saveXML();
$this->_serializableRelayState = $this->sspMessage->getRelayState();
}

return ['keyId', 'wasSigned', 'debug', 'unsolicited', 'transparent', '_serializableSspMessageXml', '_serializableRelayState'];
return [
'keyId' => $this->keyId,
'wasSigned' => $this->wasSigned,
'debug' => $this->debug,
'unsolicited' => $this->unsolicited,
'transparent' => $this->transparent,
'_serializableSspMessageXml' => $this->_serializableSspMessageXml,
'_serializableRelayState' => $this->_serializableRelayState,
];
}

public function __wakeup()
public function __unserialize(array $data): void
{
if (isset($this->_serializableSspMessageXml)) {
foreach ($data as $property => $value) {
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
}

if ($this->_serializableSspMessageXml !== null) {
$document = DOMDocumentFactory::fromString($this->_serializableSspMessageXml);
$messageDomElement = $document->getElementsByTagNameNS('urn:oasis:names:tc:SAML:2.0:protocol', 'AuthnRequest')->item(0);

if ($messageDomElement) {
$this->sspMessage = AuthnRequest::fromXML($messageDomElement);
if (isset($this->_serializableRelayState) && $this->_serializableRelayState !== null) {
if ($this->_serializableRelayState !== null) {
$this->sspMessage->setRelayState($this->_serializableRelayState);
}
}

unset($this->_serializableSspMessageXml, $this->_serializableRelayState);
$this->_serializableSspMessageXml = null;
$this->_serializableRelayState = null;
}
}
}
2 changes: 1 addition & 1 deletion library/EngineBlock/Saml2/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class EngineBlock_Saml2_Container extends AbstractContainer
/**
* The fixed length of random identifiers.
*/
const ID_LENGTH = 43;
const int ID_LENGTH = 43;

/**
* @var LoggerInterface
Expand Down
43 changes: 25 additions & 18 deletions library/EngineBlock/Saml2/ResponseAnnotationDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class EngineBlock_Saml2_ResponseAnnotationDecorator extends EngineBlock_Saml2_Me
/**
* @var Response
*/
#[Override]
protected $sspMessage;

/**
Expand Down Expand Up @@ -325,48 +326,54 @@ public function setIsTransparentErrorResponse(bool $isTransparentErrorResponse):
/**
* @return array
*/
public function __sleep()
public function __serialize(): array
{
if ($this->sspMessage instanceof Response) {
$this->_serializableSspMessageXml = $this->sspMessage->toUnsignedXML()->ownerDocument->saveXML();
$this->_serializableRelayState = $this->sspMessage->getRelayState();
}

return [
'return',
'originalIssuer',
'originalNameId',
'originalBinding',
'originalResponse',
'collabPersonId',
'customNameId',
'intendedNameId',
'pdpRequestedLoas',
'isTransparentErrorResponse',
'_serializableSspMessageXml',
'_serializableRelayState',
'SramInterruptNonce',
'return' => $this->return,
'originalIssuer' => $this->originalIssuer,
'originalNameId' => $this->originalNameId,
'originalBinding' => $this->originalBinding,
'originalResponse' => $this->originalResponse,
'collabPersonId' => $this->collabPersonId,
'customNameId' => $this->customNameId,
'intendedNameId' => $this->intendedNameId,
'pdpRequestedLoas' => $this->pdpRequestedLoas,
'isTransparentErrorResponse' => $this->isTransparentErrorResponse,
'_serializableSspMessageXml' => $this->_serializableSspMessageXml,
'_serializableRelayState' => $this->_serializableRelayState,
'SramInterruptNonce' => $this->SramInterruptNonce,
];
}

/**
* Custom deserialization to recreate $sspMessage from XML string
*/
public function __wakeup()
public function __unserialize(array $data): void
{
if (isset($this->_serializableSspMessageXml)) {
foreach ($data as $property => $value) {
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
}

if ($this->_serializableSspMessageXml !== null) {
$document = DOMDocumentFactory::fromString($this->_serializableSspMessageXml);
$messageDomElement = $document->getElementsByTagNameNS('urn:oasis:names:tc:SAML:2.0:protocol', 'Response')->item(0);

if ($messageDomElement) {
$this->sspMessage = \OpenConext\EngineBlockFunctionalTestingBundle\Saml2\Response::fromXML($messageDomElement);
}

if (isset($this->_serializableRelayState) && $this->_serializableRelayState !== null) {
if ($this->_serializableRelayState !== null) {
$this->sspMessage->setRelayState($this->_serializableRelayState);
}

unset($this->_serializableSspMessageXml);
$this->_serializableSspMessageXml = null;
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace App;

use Override;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -30,7 +31,7 @@ class Kernel extends BaseKernel
{
use MicroKernelTrait;

private const CONFIG_EXTS = '.{yaml,yml}';
private const string CONFIG_EXTS = '.{yaml,yml}';

public function registerBundles(): iterable
{
Expand All @@ -42,6 +43,7 @@ public function registerBundles(): iterable
}
}

#[Override]
public function getProjectDir(): string
{
return dirname(__DIR__);
Expand Down
2 changes: 2 additions & 0 deletions src/OpenConext/EngineBlock/Assert/Assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use Assert\Assertion as BaseAssertion;
use OpenConext\EngineBlock\Exception\InvalidArgumentException;
use Override;

/**
* @method static void nullOrNonEmptyString($value, $message = null, $propertyPath = null)
Expand All @@ -30,6 +31,7 @@ class Assertion extends BaseAssertion
const INVALID_NON_EMPTY_STRING = 1001;
const INVALID_HASHING_ALGORITHM = 1002;

#[Override]
protected static $exceptionClass = InvalidArgumentException::class;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/OpenConext/EngineBlock/Authentication/Dto/Consent.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

final class Consent
{
const CONTACT_TYPE_SUPPORT = 'support';
const string CONTACT_TYPE_SUPPORT = 'support';

/**
* @var ConsentEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ final class CollabPersonId
/**
* Required namespace prefix
*/
const URN_NAMESPACE = 'urn:collab:person';
const string URN_NAMESPACE = 'urn:collab:person';

/**
* Max length of the CollabPersonId.
*/
const MAX_LENGTH = 255;
const int MAX_LENGTH = 255;

private string $collabPersonId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
final class SchacHomeOrganization
{
const URN_MACE = 'urn:mace:terena.org:attribute-def:schacHomeOrganization';
const string URN_MACE = 'urn:mace:terena.org:attribute-def:schacHomeOrganization';

/**
* @var string
Expand Down
Loading