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 3226b8a commit 4d1d278
Show file tree
Hide file tree
Showing 23 changed files with 148 additions and 24 deletions.
31 changes: 31 additions & 0 deletions src/Surfnet/Stepup/Projector/Projector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* Copyright 2024 SURFnet B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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
}
}
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\InstitutionsAddedToWhitelistEvent;
use Surfnet\Stepup\Identity\Event\InstitutionsRemovedFromWhitelistEvent;
use Surfnet\Stepup\Identity\Event\WhitelistCreatedEvent;
Expand Down Expand Up @@ -75,4 +76,9 @@ protected function applyInstitutionsRemovedFromWhitelistEvent(InstitutionsRemove

$this->whitelistEntryRepository->remove($whitelistEntries);
}

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 @@ -20,7 +20,8 @@

namespace Surfnet\StepupMiddleware\GatewayBundle\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\SsoOn2faOptionChangedEvent;
Expand Down Expand Up @@ -64,4 +65,9 @@ public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurati
{
$this->repository->removeFor((string)$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\GatewayBundle\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Configuration\Event\IdentityProvidersUpdatedEvent;
use Surfnet\Stepup\Configuration\Event\ServiceProvidersUpdatedEvent;
use Surfnet\StepupMiddleware\GatewayBundle\Entity\SamlEntity;
Expand Down Expand Up @@ -56,4 +57,9 @@ public function applyIdentityProvidersUpdatedEvent(IdentityProvidersUpdatedEvent

$this->samlEntityRepository->replaceAllIdps($spConfigurations);
}

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\GatewayBundle\Projector;

use Broadway\ReadModel\Projector;
use Surfnet\Stepup\Projector\Projector;
use Surfnet\Stepup\Identity\Event\CompliedWithVettedSecondFactorRevocationEvent;
use Surfnet\Stepup\Identity\Event\IdentityForgottenEvent;
use Surfnet\Stepup\Identity\Event\LocalePreferenceExpressedEvent;
Expand Down
Loading

0 comments on commit 4d1d278

Please sign in to comment.