From 057d96075bb81c288bd7aa23f6344c74e0628365 Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Tue, 2 Nov 2021 11:54:14 +0100 Subject: [PATCH] More detailed logging when the token validation fails In case the token is invalid the client only gets a generic error. During setting up the stack it would be nice if there was a way to debug potential errors, so log the causing exception by default. This includes for example if the issues ID or time is the cause of the error. --- src/Authenticator/BearerUserProvider.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Authenticator/BearerUserProvider.php b/src/Authenticator/BearerUserProvider.php index e2b85ca..1a7cf75 100644 --- a/src/Authenticator/BearerUserProvider.php +++ b/src/Authenticator/BearerUserProvider.php @@ -47,6 +47,7 @@ class BearerUserProvider implements BearerUserProviderInterface, LoggerAwareInte try { $jwt = $validator->validate($accessToken); } catch (TokenValidationException $e) { + $this->logger->info('Invalid token:', ['exception' => $e]); throw new AuthenticationException('Invalid token'); } @@ -54,6 +55,7 @@ class BearerUserProvider implements BearerUserProviderInterface, LoggerAwareInte try { $validator::checkAudience($jwt, $config['required_audience']); } catch (TokenValidationException $e) { + $this->logger->info('Invalid audience:', ['exception' => $e]); throw new AuthenticationException('Invalid token audience'); } } -- GitLab