Skip to content

Commit

Permalink
Remove certificate data from SAML entities
Browse files Browse the repository at this point in the history
Certificate data is no longer visible on SPD, if the value is set in
Manage, SPD will not overwrite it.

In addition to Form and Command logic, some validators and other helper
utils have been removed

See: https://www.pivotaltracker.com/story/show/186341612
  • Loading branch information
MKodde committed Aug 6, 2024
1 parent a06ff6c commit 9d0745f
Show file tree
Hide file tree
Showing 28 changed files with 21 additions and 524 deletions.
76 changes: 13 additions & 63 deletions ci/qa/phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getCertData\\(\\) on Surfnet\\\\ServiceProviderDashboard\\\\Domain\\\\Entity\\\\Entity\\\\MetaData\\|null\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getContacts\\(\\) on Surfnet\\\\ServiceProviderDashboard\\\\Domain\\\\Entity\\\\Entity\\\\MetaData\\|null\\.$#',
'count' => 3,
Expand Down Expand Up @@ -702,27 +697,27 @@
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#10 \\$nameEn of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#10 \\$descriptionNl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#11 \\$descriptionNl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#11 \\$descriptionEn of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#12 \\$descriptionEn of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#12 \\$applicationUrl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#13 \\$applicationUrl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#13 \\$eulaUrl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#14 \\$eulaUrl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#19 \\$nameIdFormat of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
Expand All @@ -737,37 +732,32 @@
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#20 \\$nameIdFormat of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#20 \\$organizationNameNl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#21 \\$organizationNameNl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#21 \\$organizationNameEn of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#22 \\$organizationNameEn of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#22 \\$organizationDisplayNameNl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#23 \\$organizationDisplayNameNl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#23 \\$organizationDisplayNameEn of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#24 \\$organizationDisplayNameEn of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#24 \\$organizationUrlNl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#25 \\$organizationUrlNl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#26 \\$organizationUrlEn of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#25 \\$organizationUrlEn of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
Expand Down Expand Up @@ -802,12 +792,12 @@
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#7 \\$certificate of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#8 \\$nameNl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#9 \\$nameNl of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'message' => '#^Parameter \\#9 \\$nameEn of class Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\ViewObject\\\\EntityDetail constructor expects string, string\\|null given\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Factory/EntityDetailFactory.php',
];
Expand Down Expand Up @@ -886,11 +876,6 @@
'count' => 2,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGenerator.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getCertData\\(\\) on Surfnet\\\\ServiceProviderDashboard\\\\Domain\\\\Entity\\\\Entity\\\\MetaData\\|null\\.$#',
'count' => 4,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGenerator.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getContacts\\(\\) on Surfnet\\\\ServiceProviderDashboard\\\\Domain\\\\Entity\\\\Entity\\\\MetaData\\|null\\.$#',
'count' => 6,
Expand Down Expand Up @@ -971,11 +956,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGenerator.php',
];
$ignoreErrors[] = [
'message' => '#^Method Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\Metadata\\\\JsonGenerator\\:\\:generateCertDataMetadata\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Application/Metadata/JsonGenerator.php',
];
$ignoreErrors[] = [
'message' => '#^Method Surfnet\\\\ServiceProviderDashboard\\\\Application\\\\Metadata\\\\JsonGenerator\\:\\:generateContactMetadata\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
Expand Down Expand Up @@ -4036,26 +4016,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Validator/Constraints/ValidRedirectUrlValidator.php',
];
$ignoreErrors[] = [
'message' => '#^Property Surfnet\\\\ServiceProviderDashboard\\\\Infrastructure\\\\DashboardBundle\\\\Validator\\\\Constraints\\\\ValidSSLCertificate\\:\\:\\$message has no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Validator/Constraints/ValidSSLCertificate.php',
];
$ignoreErrors[] = [
'message' => '#^Access to an undefined property Symfony\\\\Component\\\\Validator\\\\Constraint\\:\\:\\$message\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Validator/Constraints/ValidSSLCertificateValidator.php',
];
$ignoreErrors[] = [
'message' => '#^Method Surfnet\\\\ServiceProviderDashboard\\\\Infrastructure\\\\DashboardBundle\\\\Validator\\\\Constraints\\\\ValidSSLCertificateValidator\\:\\:setCertificateEnvelope\\(\\) has parameter \\$certData with no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Validator/Constraints/ValidSSLCertificateValidator.php',
];
$ignoreErrors[] = [
'message' => '#^Method Surfnet\\\\ServiceProviderDashboard\\\\Infrastructure\\\\DashboardBundle\\\\Validator\\\\Constraints\\\\ValidSSLCertificateValidator\\:\\:stripCertificateEnvelope\\(\\) has parameter \\$certData with no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Infrastructure/DashboardBundle/Validator/Constraints/ValidSSLCertificateValidator.php',
];
$ignoreErrors[] = [
'message' => '#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#',
'count' => 1,
Expand Down Expand Up @@ -4501,11 +4461,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Infrastructure/Manage/Factory/SaveCommandFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getCertData\\(\\) on Surfnet\\\\ServiceProviderDashboard\\\\Domain\\\\Entity\\\\Entity\\\\MetaData\\|null\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Infrastructure/Manage/Factory/SaveCommandFactory.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getClientSecret\\(\\) on Surfnet\\\\ServiceProviderDashboard\\\\Domain\\\\Entity\\\\Entity\\\\OidcClientInterface\\|null\\.$#',
'count' => 3,
Expand Down Expand Up @@ -4901,11 +4856,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Infrastructure/Teams/Client/QueryClient.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'name\' on array\\|false\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/ServiceProviderDashboard/Legacy/Metadata/CertificateParser.php',
];
$ignoreErrors[] = [
'message' => '#^Method Surfnet\\\\ServiceProviderDashboard\\\\Legacy\\\\Metadata\\\\Fetcher\\:\\:__construct\\(\\) has parameter \\$timeout with no type specified\\.$#',
'count' => 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ public function getApplicationUrl(): ?string;

public function getEulaUrl(): ?string;

public function getCertificate(): ?string;

public function getLogoUrl(): ?string;

public function getComments(): ?string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,6 @@ public function getMetadataUrl(): ?string
return null;
}

public function getCertificate(): ?string
{
return null;
}

public function getNameIdFormat(): string
{
return $this->getSubjectType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,6 @@ public function getMetadataUrl(): ?string
return null;
}

public function getCertificate(): ?string
{
return null;
}

public function getNameIdFormat(): string
{
return $this->getSubjectType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,6 @@ public function getEulaUrl(): ?string
return null;
}

public function getCertificate(): ?string
{
return null;
}

public function getLogoUrl(): ?string
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ class SaveSamlEntityCommand implements SaveEntityCommandInterface
#[Assert\NotBlank]
private string $entityId;

#[SpDashboardAssert\ValidSSLCertificate()]
private ?string $certificate = null;

#[SpDashboardAssert\ValidLogo()]
#[Assert\Url]
#[Assert\NotBlank]
Expand Down Expand Up @@ -292,16 +289,6 @@ public function setEntityId(string $entityId): void
$this->entityId = $entityId;
}

public function getCertificate(): ?string
{
return $this->certificate;
}

public function setCertificate(?string $certificate): void
{
$this->certificate = $certificate;
}

public function getLogoUrl(): ?string
{
return $this->logoUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ private function mapTextFields(
'descriptionNl' => ['getDescriptionNl', 'setDescriptionNl'],
'descriptionEn' => ['getDescriptionEn', 'setDescriptionEn'],
'applicationUrlEn' => ['getApplicationUrl', 'setApplicationUrl'],
'certificate' => ['getCertificate', 'setCertificate'],
];

$this->map($map, $command, $metadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public function buildFrom(ManageEntity $manageEntity): EntityDetail
$manageEntity->getMetaData()->getAcsLocations(),
$manageEntity->getMetaData()->getEntityId(),
$manageEntity->getProtocol()->getProtocol(),
$manageEntity->getMetaData()->getCertData(),
$logo,
$manageEntity->getMetaData()->getNameNl(),
$manageEntity->getMetaData()->getNameEn(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ private function generateMetadataFields(ManageEntity $entity): array

$metadata['NameIDFormat'] = $entity->getMetaData()->getNameIdFormat();
$metadata['coin:signature_method'] = 'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256';
$metadata = array_merge($metadata, $this->generateCertDataMetadata($entity));

// When publishing to production, the coin:exclude_from_push must be present and set to '1'. This prevents the
// entity from being pushed to EngineBlock. Once the entity is checked a final time, the flag is set to 0
Expand All @@ -231,31 +230,6 @@ private function generateMetadataFields(ManageEntity $entity): array
return $metadata;
}

private function generateCertDataMetadata(ManageEntity $entity): array
{
$metadata = [];
if ($entity->getMetaData()->getCertData() !== null
&& $entity->getMetaData()->getCertData() !== ''
&& $entity->getMetaData()->getCertData() !== '0') {
$metadata['certData'] = $this->stripCertificateEnvelope(
$entity->getMetaData()->getCertData()
);
}

return $metadata;
}

/**
* Strip header and footer from certificate data.
*/
private function stripCertificateEnvelope(string $certData): string
{
$certData = str_replace('-----BEGIN CERTIFICATE-----', '', $certData);
$certData = str_replace('-----END CERTIFICATE-----', '', $certData);

return trim($certData);
}

private function generateAllContactsMetadata(ManageEntity $entity): array
{
$metadata = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public function mergeEntityCommand(
$command->getMetadataUrl(),
$command->getAcsLocations(),
$command->getNameIdFormat(),
$command->getCertificate(),
$command->getDescriptionEn(),
$command->getDescriptionNl(),
$command->getNameEn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function __construct(
private readonly array $acsLocations,
private readonly string $entityId,
private readonly string $protocol,
private readonly string $certificate,
private readonly ?string $logoUrl,
private readonly string $nameNl,
private readonly string $nameEn,
Expand Down Expand Up @@ -91,11 +90,6 @@ public function getEntityId(): string
return $this->entityId;
}

public function getCertificate(): string
{
return $this->certificate;
}

/**
* @return string
*/
Expand Down
Loading

0 comments on commit 9d0745f

Please sign in to comment.