feat: proper logging to dedicated audit channel

This commit is contained in:
Björn Fromme committed 2026-08-12 10:34:41 +02:00
1 parent 898a7c7505
commit 74ebefcf65
4 files changed
+49 -15

No files matched your search

+8 -2
View File
@@ -6,6 +6,7 @@ use League\OAuth2\Client\Provider\AbstractProvider;
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
use League\OAuth2\Client\Provider\GenericProvider;
use League\OAuth2\Client\Token\AccessTokenInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -14,8 +15,11 @@ class MyEpClient
{
private array $config;
public function __construct(private readonly UrlGeneratorInterface $urlGenerator, array $options)
{
public function __construct(
private readonly UrlGeneratorInterface $urlGenerator,
private readonly LoggerInterface $logger,
array $options,
) {
$this->config = $this->resolveConfig($options);
}
@@ -26,6 +30,7 @@ class MyEpClient
public function fetchAccessToken(Request $request): AccessTokenInterface
{
if (null === $code = $request->query->get('code')) {
$this->logger->error('OAuth2 login request missing code');
throw new AuthorizationRequestException('Missing code', 400, $request);
}
@@ -36,6 +41,7 @@ class MyEpClient
|| $request->query->get('state') !== $session->get('oauth2state')
) {
$session->remove('oauth2state');
$this->logger->error('OAuth2 login request missing state or mismatch');
throw new AuthorizationRequestException('Missing state or mismatch', 400, $request);
}