accessTokenRepository = $accessTokenRepository; if (!$publicKey instanceof CryptKey) { $publicKey = new CryptKey($publicKey); } $this->publicKey = $publicKey; $this->authorizationValidator = $authorizationValidator; } /** * @return \League\OAuth2\Server\AuthorizationValidators\AuthorizationValidatorInterface */ protected function getAuthorizationValidator() { if (!$this->authorizationValidator instanceof AuthorizationValidatorInterface) { $this->authorizationValidator = new BearerTokenValidator($this->accessTokenRepository); } $this->authorizationValidator->setPublicKey($this->publicKey); return $this->authorizationValidator; } /** * Determine the access token validity. * * @param \Psr\Http\Message\ServerRequestInterface $request * * @throws \League\OAuth2\Server\Exception\OAuthServerException * * @return \Psr\Http\Message\ServerRequestInterface */ public function validateAuthenticatedRequest(ServerRequestInterface $request) { return $this->getAuthorizationValidator()->validateAuthorization($request); } }