-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PPF-523 Deleting integration should block keycloak clients #1211
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
namespace App\Keycloak\Listeners; | ||
|
||
use App\Domain\Integrations\Events\IntegrationBlocked; | ||
use App\Domain\Integrations\Repositories\IntegrationRepository; | ||
use App\Domain\Integrations\Events\IntegrationDeleted; | ||
use App\Keycloak\Client\ApiClient; | ||
use App\Keycloak\Exception\KeyCloakApiFailed; | ||
use App\Keycloak\Repositories\KeycloakClientRepository; | ||
|
@@ -19,24 +19,22 @@ final class BlockClients implements ShouldQueue | |
use Queueable; | ||
|
||
public function __construct( | ||
private readonly IntegrationRepository $integrationRepository, | ||
private readonly KeycloakClientRepository $keycloakClientRepository, | ||
private readonly ApiClient $client, | ||
private readonly LoggerInterface $logger | ||
) { | ||
} | ||
|
||
public function handle(IntegrationBlocked $integrationBlocked): void | ||
public function handle(IntegrationBlocked|IntegrationDeleted $integrationBlocked): void | ||
{ | ||
$integration = $this->integrationRepository->getById($integrationBlocked->id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: it's fine like it is now, but there is a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, thank you for that info, but we also don't use anything from the integration except the id so fetching it doesn't have any added value. |
||
$keycloakClients = $this->keycloakClientRepository->getByIntegrationId($integrationBlocked->id); | ||
|
||
foreach ($keycloakClients as $keycloakClient) { | ||
try { | ||
$this->client->blockClient($keycloakClient); | ||
|
||
$this->logger->info('Keycloak client blocked', [ | ||
'integration_id' => $integration->id->toString(), | ||
'integration_id' => $integrationBlocked->id->toString(), | ||
'client_id' => $keycloakClient->id->toString(), | ||
'environment' => $keycloakClient->environment->value, | ||
]); | ||
|
@@ -46,7 +44,7 @@ public function handle(IntegrationBlocked $integrationBlocked): void | |
} | ||
} | ||
|
||
public function failed(IntegrationBlocked $integrationBlocked, Throwable $throwable): void | ||
public function failed(IntegrationBlocked|IntegrationDeleted $integrationBlocked, Throwable $throwable): void | ||
{ | ||
$this->logger->error('Failed to block Keycloak client(s)', [ | ||
'integration_id' => $integrationBlocked->id->toString(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use a more generic name for the parameter?