Skip to content

Commit

Permalink
Enforce forget identity event method in projectors
Browse files Browse the repository at this point in the history
  • Loading branch information
pablothedude committed Jan 16, 2025
1 parent aa4a6e6 commit 61182e2
Show file tree
Hide file tree
Showing 24 changed files with 132 additions and 99 deletions.
75 changes: 0 additions & 75 deletions ci/qa/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2690,71 +2690,6 @@ parameters:
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Projector/WhitelistProjector.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\AuditLogRepository\\:\\:findByIdentityId\\(\\) should return array\\<Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Entity\\\\AuditLogEntry\\> but returns mixed\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuditLogRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\AuditLogRepository\\:\\:findEntriesWhereIdentityIsActorOnly\\(\\) should return array\\<Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Entity\\\\AuditLogEntry\\> but returns mixed\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuditLogRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\AuditLogRepository\\:\\:saveAll\\(\\) has parameter \\$entries with no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuditLogRepository.php

-
message: "#^Cannot access offset 'institution' on mixed\\.$#"
count: 5
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuthorizationRepository.php

-
message: "#^Cannot cast mixed to string\\.$#"
count: 3
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuthorizationRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\AuthorizationRepository\\:\\:getAllowedIdentityRoles\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuthorizationRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\AuthorizationRepository\\:\\:getAllowedInstitutionRoles\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuthorizationRepository.php

-
message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuthorizationRepository.php

-
message: "#^Parameter \\#3 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/AuthorizationRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\IdentityRepository\\:\\:findByNameIdsIndexed\\(\\) should return array\\<Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Entity\\\\Identity\\> but returns mixed\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/IdentityRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\IdentityRepository\\:\\:findOneByNameIdAndInstitution\\(\\) should return Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Entity\\\\Identity but returns mixed\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/IdentityRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\RaCandidateRepository\\:\\:findOneByIdentityId\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaCandidateRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\RaCandidateRepository\\:\\:findOneByIdentityId\\(\\) should return array\\|null but returns mixed\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaCandidateRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\RaListingRepository\\:\\:findByIdentityId\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -2775,16 +2710,6 @@ parameters:
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/RaListingRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\SraaRepository\\:\\:saveAll\\(\\) has parameter \\$sraaList with no value type specified in iterable type array\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/SraaRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\VerifiedSecondFactorRepository\\:\\:findByDate\\(\\) should return array\\<Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Entity\\\\VerifiedSecondFactor\\> but returns mixed\\.$#"
count: 1
path: ../../src/Surfnet/StepupMiddleware/ApiBundle/Identity/Repository/VerifiedSecondFactorRepository.php

-
message: "#^Method Surfnet\\\\StepupMiddleware\\\\ApiBundle\\\\Identity\\\\Repository\\\\WhitelistEntryRepository\\:\\:findEntriesByInstitutions\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down
15 changes: 15 additions & 0 deletions src/Surfnet/Stepup/Projector/Projector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Surfnet\Stepup\Projector;

use Broadway\EventHandling\EventListener;
use Broadway\ReadModel\Projector as BroadwayProjector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;

/**
* @SuppressWarnings(PHPMD.NumberOfChildren) we simply have a lot of projectors
*/
abstract class Projector extends BroadwayProjector implements EventListener
{
abstract protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Configuration\Event\AllowedSecondFactorListUpdatedEvent;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\AllowedSecondFactor;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\AllowedSecondFactorRepository;
Expand All @@ -40,4 +41,9 @@ public function applyAllowedSecondFactorListUpdatedEvent(AllowedSecondFactorList
$this->allowedSecondFactorRepository->save($allowedSecondFactor);
}
}

protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
// do nothing, no sensitive data in this projection
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Configuration\Event\InstitutionConfigurationRemovedEvent;
use Surfnet\Stepup\Configuration\Event\NewInstitutionConfigurationCreatedEvent;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\ConfiguredInstitution;
Expand All @@ -40,4 +41,9 @@ public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurati
{
$this->configuredInstitutionRepository->removeConfigurationFor($event->institution);
}

protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
// do nothing, no sensitive data in this projection
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Configuration\Event\InstitutionConfigurationRemovedEvent;
use Surfnet\Stepup\Configuration\Event\NewInstitutionConfigurationCreatedEvent;
use Surfnet\Stepup\Configuration\Event\SelectRaaOptionChangedEvent;
Expand Down Expand Up @@ -72,4 +73,9 @@ public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurati
$event->institution,
);
}

protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
// do nothing, no sensitive data in this projection
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Configuration\Event\InstitutionConfigurationRemovedEvent;
use Surfnet\Stepup\Configuration\Event\NewInstitutionConfigurationCreatedEvent;
use Surfnet\Stepup\Configuration\Event\NumberOfTokensPerIdentityOptionChangedEvent;
Expand All @@ -32,6 +33,9 @@
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\AllowedSecondFactorRepository;
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionConfigurationOptionsRepository;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
final class InstitutionConfigurationOptionsProjector extends Projector
{
public function __construct(
Expand Down Expand Up @@ -131,4 +135,9 @@ public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurati
$this->institutionConfigurationOptionsRepository->removeConfigurationOptionsFor($event->institution);
$this->allowedSecondFactorRepository->clearAllowedSecondFactorListFor($event->institution);
}

protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
// do nothing, no sensitive data in this projection
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Configuration\Event\InstitutionConfigurationRemovedEvent;
use Surfnet\Stepup\Configuration\Event\RaLocationAddedEvent;
use Surfnet\Stepup\Configuration\Event\RaLocationContactInformationChangedEvent;
Expand Down Expand Up @@ -100,4 +101,9 @@ private function fetchRaLocationById(RaLocationId $raLocationId): RaLocation

return $raLocation;
}

protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
// do nothing, no sensitive data in this projection
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;

use Broadway\Domain\DomainMessage;
use Broadway\EventHandling\EventListener;
use DateTime as CoreDateTime;
use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\DateTime\DateTime;
Expand All @@ -33,6 +32,7 @@
use Surfnet\Stepup\Identity\Value\RecoveryTokenIdentifierFactory;
use Surfnet\Stepup\Identity\Value\RecoveryTokenType;
use Surfnet\Stepup\Identity\Value\VettingType;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\StepupMiddleware\ApiBundle\Exception\RuntimeException;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\AuditLogEntry;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Identity;
Expand All @@ -42,7 +42,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AuditLogProjector implements EventListener
class AuditLogProjector extends Projector
{
public function __construct(
private readonly AuditLogRepository $auditLogRepository,
Expand Down Expand Up @@ -138,7 +138,7 @@ private function applyAuditableEvent(AuditableEvent $event, DomainMessage $domai
$this->auditLogRepository->save($entry);
}

private function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
$entries = $this->auditLogRepository->findByIdentityId($event->identityId);
foreach ($entries as $auditLogEntry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Identity\Event\IdentityCreatedEvent;
use Surfnet\Stepup\Identity\Event\IdentityEmailChangedEvent;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Identity\Event\IdentityCreatedEvent;
use Surfnet\Stepup\Identity\Event\SecondFactorVettedEvent;
use Surfnet\Stepup\Identity\Event\SecondFactorVettedWithoutTokenProofOfPossession;
Expand Down Expand Up @@ -81,4 +82,9 @@ private function determinePossessionOfToken(VettingType $vettingType, IdentityId
$identitySelfAssertedTokenOptions->possessedToken = true;
$this->repository->save($identitySelfAssertedTokenOptions);
}

protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
// do nothing, no sensitive data in this projection
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Identity\Event\IdentityCreatedEvent;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\InstitutionListingRepository;

Expand All @@ -36,4 +37,9 @@ public function applyIdentityCreatedEvent(IdentityCreatedEvent $event): void
{
$this->institutionListingRepository->addIfNotExists($event->identityInstitution);
}

protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
// do nothing, no sensitive data in this projection
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Identity\Event\AppointedAsRaaEvent;
use Surfnet\Stepup\Identity\Event\AppointedAsRaaForInstitutionEvent;
use Surfnet\Stepup\Identity\Event\AppointedAsRaEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Identity\Event\CompliedWithUnverifiedSecondFactorRevocationEvent;
use Surfnet\Stepup\Identity\Event\CompliedWithVerifiedSecondFactorRevocationEvent;
use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Identity\Event\CompliedWithRecoveryCodeRevocationEvent;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Identity\Event\PhoneRecoveryTokenPossessionProvenEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Identity\Event\CompliedWithUnverifiedSecondFactorRevocationEvent;
use Surfnet\Stepup\Identity\Event\CompliedWithVerifiedSecondFactorRevocationEvent;
use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;

use Broadway\Domain\DomainMessage;
use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Projector\Projector;
use DateTime as CoreDateTime;
use Ramsey\Uuid\Uuid;
use Surfnet\Stepup\DateTime\DateTime;
Expand Down Expand Up @@ -61,4 +62,9 @@ protected function applyCompliedWithVettedSecondFactorRevocationEvent(

$this->repository->save($revocation);
}

protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
// do nothing, no sensitive data in this projection
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Configuration\Event\SraaUpdatedEvent;
use Surfnet\Stepup\Identity\Value\NameId;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\Sraa;
Expand All @@ -41,4 +42,9 @@ public function applySraaUpdatedEvent(SraaUpdatedEvent $event): void

$this->sraaRepository->saveAll($sraaList);
}

protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
// do nothing, no sensitive data in this projection
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Identity\Event\VettingTypeHintsSavedEvent;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\VettingTypeHint;
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\VettingTypeHintRepository;
Expand All @@ -45,4 +46,9 @@ public function applyVettingTypeHintsSavedEvent(VettingTypeHintsSavedEvent $even
$entity->hints = $event->hints;
$this->vettingTypeHintRepository->save($entity);
}

protected function applyIdentityForgottenEvent(IdentityForgottenEvent $event): void
{
// do nothing, no sensitive data in this projection
}
}
Loading

0 comments on commit 61182e2

Please sign in to comment.