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
6 changes: 6 additions & 0 deletions config/packages/dev/monolog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ monolog:
handler: nested
level: debug
channels: ["!authentication"]
critical:
type: stream
level: error
path: "%kernel.logs_dir%/error.log"
formatter: monolog.formatter.line
channels: [ "!event" ]
nested:
type: stream
level: debug
Expand Down
10 changes: 10 additions & 0 deletions config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ doctrine:
engineblock_collab_person_uuid: OpenConext\EngineBlockBundle\Doctrine\Type\CollabPersonUuidType
engineblock_metadata_coins: OpenConext\EngineBlockBundle\Doctrine\Type\MetadataCoinType
engineblock_metadata_mdui: OpenConext\EngineBlockBundle\Doctrine\Type\MetadataMduiType
engineblock_certificate_array: OpenConext\EngineBlockBundle\Doctrine\Type\CertificateArrayType
engineblock_attribute_release_policy: OpenConext\EngineBlockBundle\Doctrine\Type\AttributeReleasePolicyType
engineblock_contact_person_array: OpenConext\EngineBlockBundle\Doctrine\Type\ContactPersonArrayType
engineblock_indexed_service_array: OpenConext\EngineBlockBundle\Doctrine\Type\IndexedServiceArrayType
engineblock_logo: OpenConext\EngineBlockBundle\Doctrine\Type\LogoType
engineblock_organization: OpenConext\EngineBlockBundle\Doctrine\Type\OrganizationType
engineblock_requested_attribute_array: OpenConext\EngineBlockBundle\Doctrine\Type\RequestedAttributeArrayType
engineblock_service: OpenConext\EngineBlockBundle\Doctrine\Type\ServiceType
engineblock_service_array: OpenConext\EngineBlockBundle\Doctrine\Type\ServiceArrayType
engineblock_shib_md_scope_array: OpenConext\EngineBlockBundle\Doctrine\Type\ShibMdScopeArrayType

array: OpenConext\EngineBlockBundle\Doctrine\Type\SerializedArrayType
object: OpenConext\EngineBlockBundle\Doctrine\Type\SerializedObjectType
Expand Down
114 changes: 52 additions & 62 deletions config/reference.php

Large diffs are not rendered by default.

15 changes: 5 additions & 10 deletions migrations/DoctrineMigrations/Version20260210000000.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,14 @@ public function getDescription(): string
return 'Baseline migration: Creates all database tables (consent, saml_persistent_id, service_provider_uuid, sso_provider_roles_eb5, user). Skips if tables already exist.';
}

public function preUp(Schema $schema): void
public function up(Schema $schema): void
{
parent::preUp($schema);

$tables = $this->sm->listTableNames();
$this->skipIf(
in_array('sso_provider_roles_eb5', $tables, true),
'Database schema already exists (found sso_provider_roles_eb5 table). Skipping baseline migration.'
);
}
// Database schema already exists (found sso_provider_roles_eb5 table). Skipping baseline migration
if (in_array('sso_provider_roles_eb5', $tables, true)) {
return;
}

public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE `consent` (
`consent_date` datetime NOT NULL,
`hashed_user_id` varchar(80) NOT NULL,
Expand Down
23 changes: 13 additions & 10 deletions migrations/DoctrineMigrations/Version20260224000000.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@ public function getDescription(): string
return 'Patch migration: Removes the deleted_at index from the consent table. Skips if the index does not exist.';
}

public function preUp(Schema $schema): void
public function up(Schema $schema): void
{
parent::preUp($schema);
$indexes = $this->connection
->createSchemaManager()
->introspectTableIndexes(
new OptionallyQualifiedName(
Identifier::unquoted('consent'),
null
)
);

$indexes = $this->connection->createSchemaManager()->introspectTableIndexes(new OptionallyQualifiedName(Identifier::unquoted('consent'), null));
$deletedAtIndex = array_filter(
$indexes,
static fn(Index $index) => $index->getObjectName()->equals(
Expand All @@ -53,14 +59,11 @@ public function preUp(Schema $schema): void
)
);

$this->skipIf(
count($deletedAtIndex) === 0,
'Index deleted_at on consent table does not exist. Skipping.'
);
}
// Index deleted_at on consent table does not exist. Skipping
if (count($deletedAtIndex) === 0) {
return;
}

public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE `consent` DROP INDEX `deleted_at`');
}

Expand Down
80 changes: 80 additions & 0 deletions migrations/DoctrineMigrations/Version20260817133323.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

declare(strict_types=1);

namespace OpenConext\EngineBlock\Doctrine\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20260817133323 extends AbstractMigration
{
public function getDescription(): string
{
return 'Create sso_provider_roles_eb6 table that no longer contains serialized objects';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
CREATE TABLE sso_provider_roles_eb6 (
id INT AUTO_INCREMENT NOT NULL,
entity_id VARCHAR(255) NOT NULL,
name_nl VARCHAR(255),
name_en VARCHAR(255),
name_pt VARCHAR(255),
description_nl VARCHAR(255),
description_en VARCHAR(255),
description_pt VARCHAR(255),
display_name_nl VARCHAR(255),
display_name_en VARCHAR(255),
display_name_pt VARCHAR(255),
logo JSON,
organization_nl_name JSON DEFAULT NULL,
organization_en_name JSON DEFAULT NULL,
organization_pt_name JSON DEFAULT NULL,
keywords_nl VARCHAR(255),
keywords_en VARCHAR(255),
keywords_pt VARCHAR(255),
certificates JSON,
workflow_state VARCHAR(255) NOT NULL,
contact_persons JSON,
name_id_format VARCHAR(255) DEFAULT NULL,
name_id_formats JSON NOT NULL,
single_logout_service JSON DEFAULT NULL,
requests_must_be_signed TINYINT NOT NULL,
manipulation TEXT,
coins JSON NOT NULL,
mdui JSON NOT NULL,
type VARCHAR(255) NOT NULL,
attribute_release_policy JSON DEFAULT NULL,
assertion_consumer_services JSON DEFAULT NULL,
allowed_idp_entity_ids JSON DEFAULT NULL,
allow_all TINYINT DEFAULT NULL,
requested_attributes JSON DEFAULT NULL,
support_url_en VARCHAR(255) DEFAULT NULL,
support_url_nl VARCHAR(255) DEFAULT NULL,
support_url_pt VARCHAR(255) DEFAULT NULL,
enabled_in_wayf TINYINT DEFAULT NULL,
single_sign_on_services JSON DEFAULT NULL,
consent_settings LONGTEXT DEFAULT NULL,
shib_md_scopes JSON DEFAULT NULL,
idp_discoveries JSON DEFAULT NULL,
INDEX idx_sso_provider_roles_type (type),
INDEX idx_sso_provider_roles_entity_id (entity_id),
UNIQUE INDEX idx_sso_provider_roles_entity_id_type (type, entity_id),
PRIMARY KEY (id)
) DEFAULT CHARACTER SET UTF8
SQL);
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE sso_provider_roles_eb6');
}
}
45 changes: 20 additions & 25 deletions src/OpenConext/EngineBlock/Metadata/AttributeReleasePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

class AttributeReleasePolicy
{
const WILDCARD_CHARACTER = '*';
const string WILDCARD_CHARACTER = '*';

/**
* Holds attribute rule values with optional 'source'.
Expand All @@ -40,11 +40,8 @@ class AttributeReleasePolicy
*
* @var array
*/
private $attributeRules;
private array $attributeRules;

/**
* @param array $attributeRules
*/
public function __construct(array $attributeRules)
{
foreach ($attributeRules as $key => $rules) {
Expand All @@ -67,11 +64,9 @@ public function __construct(array $attributeRules)
}

/**
* @param string $key
* @param mixed $rule
* @throws InvalidArgumentException
*/
private function validateRule($key, $rule)
private function validateRule(string $key, mixed $rule): void
{
if (is_array($rule)) {
if (!isset($rule['value'])) {
Expand Down Expand Up @@ -110,8 +105,6 @@ private function validateRule($key, $rule)
* Return all attribute rules eligible for attribute aggregation.
*
* A rule is eligible for attribute aggregation if it contains a source.
*
* @return array
*/
public function getRulesWithSourceSpecification(): array
{
Expand Down Expand Up @@ -160,10 +153,7 @@ public function findNameIdSubstitute(): ?string
return null;
}

/**
* @return array
*/
public function getAttributeNames()
public function getAttributeNames(): array
{
return array_keys($this->attributeRules);
}
Expand All @@ -172,7 +162,7 @@ public function getAttributeNames()
* @param $attributeName
* @return bool
*/
public function hasAttribute($attributeName)
public function hasAttribute($attributeName): bool
{
return isset($this->attributeRules[$attributeName]);
}
Expand All @@ -182,7 +172,7 @@ public function hasAttribute($attributeName)
* @param $attributeValue
* @return bool
*/
public function isAllowed($attributeName, $attributeValue)
public function isAllowed($attributeName, $attributeValue): bool
{
if (!$this->hasAttribute($attributeName)) {
return false;
Expand Down Expand Up @@ -224,7 +214,7 @@ public function isAllowed($attributeName, $attributeValue)
* @param $rule
* @return string
*/
private function getRuleValue($rule)
private function getRuleValue($rule): string
{
if (isset($rule['value'])) {
return (string) $rule['value'];
Expand All @@ -237,16 +227,16 @@ private function getRuleValue($rule)
* Loads the motivation text for an attribute.
*
* @param $attributeName
* @return string
* @return ?string
*/
public function getMotivation($attributeName)
public function getMotivation($attributeName): ?string
{
if (!$this->hasAttribute($attributeName)) {
return;
return null;
}

if (empty($this->attributeRules[$attributeName][0]['motivation'])) {
return;
return null;
}

return $this->attributeRules[$attributeName][0]['motivation'];
Expand All @@ -258,19 +248,24 @@ public function getMotivation($attributeName)
* @param $attributeName
* @return string
*/
public function getSource($attributeName)
public function getSource($attributeName): string
{
if ($this->hasAttribute($attributeName) && isset($this->attributeRules[$attributeName][0]['source'])) {
return $this->attributeRules[$attributeName][0]['source'];
}
return 'idp';
}

public function getAttributeRules(): array
{
return $this->attributeRules;
}

/**
* @return array
* A convenience static constructor for the AttributeReleasePolicy.
*/
public function getAttributeRules()
public static function fromArray(array $attributeReleasePolicy): AttributeReleasePolicy
{
return $this->attributeRules;
return new self($attributeReleasePolicy);
}
}
42 changes: 35 additions & 7 deletions src/OpenConext/EngineBlock/Metadata/ContactPerson.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,31 @@
*/
class ContactPerson
{
public $contactType;
public $emailAddress = '';
public $telephoneNumber = '';
public $givenName = '';
public $surName = '';
public string $contactType;
public string $emailAddress;
public string $telephoneNumber;
public string $givenName;
public string $surName;

/**
* @param $contactType
* @param string $emailAddress
* @param string $telephoneNumber
* @param string $givenName
* @param string $surName
*/
public function __construct($contactType)
{
public function __construct(
$contactType,
string $emailAddress = '',
string $telephoneNumber = '',
string $givenName = '',
string $surName = ''
) {
$this->contactType = $contactType;
$this->emailAddress = $emailAddress;
$this->telephoneNumber = $telephoneNumber;
$this->givenName = $givenName;
$this->surName = $surName;
}

/**
Expand All @@ -61,4 +74,19 @@ public static function from(
$contact->telephoneNumber = $telephoneNumber;
return $contact;
}


/**
* A convenience static constructor for the contact person.
*/
public static function fromArray(array $contactPerson): ContactPerson
{
return new self(
$contactPerson["contactType"],
$contactPerson["emailAddress"],
$contactPerson["telephoneNumber"],
$contactPerson["givenName"],
$contactPerson["surName"]
);
}
}
Loading