From 11fe5e78837e6a32db895672bd079dc8fc9392f9 Mon Sep 17 00:00:00 2001 From: parallels999 <109294935+parallels999@users.noreply.github.com> Date: Wed, 2 Aug 2023 17:38:02 -0500 Subject: [PATCH] Allow appending custom jwt token data to the request --- .../BearerTokenValidator.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/AuthorizationValidators/BearerTokenValidator.php b/src/AuthorizationValidators/BearerTokenValidator.php index 5da9ba8c6..ffd7951de 100644 --- a/src/AuthorizationValidators/BearerTokenValidator.php +++ b/src/AuthorizationValidators/BearerTokenValidator.php @@ -14,6 +14,7 @@ use Lcobucci\JWT\Configuration; use Lcobucci\JWT\Signer\Key\InMemory; use Lcobucci\JWT\Signer\Rsa\Sha256; +use Lcobucci\JWT\Token\DataSet; use Lcobucci\JWT\Validation\Constraint\LooseValidAt; use Lcobucci\JWT\Validation\Constraint\SignedWith; use Lcobucci\JWT\Validation\RequiredConstraintsViolated; @@ -124,11 +125,23 @@ public function validateAuthorization(ServerRequestInterface $request) } // Return the request with additional attributes - return $request + $request = $request ->withAttribute('oauth_access_token_id', $claims->get('jti')) ->withAttribute('oauth_client_id', $this->convertSingleRecordAudToString($claims->get('aud'))) ->withAttribute('oauth_user_id', $claims->get('sub')) ->withAttribute('oauth_scopes', $claims->get('scopes')); + + return $this->appendAttributesFromClaims($request, $claims); + } + + /** + * Configure the request instance. + * + * @return ServerRequestInterface + */ + protected function appendAttributesFromClaims(ServerRequestInterface $request, DataSet $claims) + { + return $request; } /**