thephpleague /
oauth2-server
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | /** |
||||||
| 4 | * @author Alex Bilbie <[email protected]> |
||||||
| 5 | * @copyright Copyright (c) Alex Bilbie |
||||||
| 6 | * @license http://mit-license.org/ |
||||||
| 7 | * |
||||||
| 8 | * @link https://github.com/thephpleague/oauth2-server |
||||||
| 9 | */ |
||||||
| 10 | |||||||
| 11 | declare(strict_types=1); |
||||||
| 12 | |||||||
| 13 | namespace League\OAuth2\Server; |
||||||
| 14 | |||||||
| 15 | use League\OAuth2\Server\AuthorizationValidators\AuthorizationValidatorInterface; |
||||||
| 16 | use League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator; |
||||||
| 17 | use League\OAuth2\Server\Exception\OAuthServerException; |
||||||
| 18 | use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; |
||||||
| 19 | use Psr\Http\Message\ServerRequestInterface; |
||||||
| 20 | |||||||
| 21 | class ResourceServer |
||||||
| 22 | { |
||||||
| 23 | private CryptKeyInterface $publicKey; |
||||||
| 24 | |||||||
| 25 | 4 | public function __construct( |
|||||
| 26 | private AccessTokenRepositoryInterface $accessTokenRepository, |
||||||
| 27 | CryptKeyInterface|string $publicKey, |
||||||
| 28 | private ?AuthorizationValidatorInterface $authorizationValidator = null |
||||||
| 29 | ) { |
||||||
| 30 | 4 | if ($publicKey instanceof CryptKeyInterface === false) { |
|||||
| 31 | 4 | $publicKey = new CryptKey($publicKey); |
|||||
| 32 | } |
||||||
| 33 | 4 | $this->publicKey = $publicKey; |
|||||
| 34 | } |
||||||
| 35 | |||||||
| 36 | 4 | protected function getAuthorizationValidator(): AuthorizationValidatorInterface |
|||||
| 37 | { |
||||||
| 38 | 4 | if ($this->authorizationValidator instanceof AuthorizationValidatorInterface === false) { |
|||||
| 39 | 4 | $this->authorizationValidator = new BearerTokenValidator($this->accessTokenRepository); |
|||||
| 40 | } |
||||||
| 41 | |||||||
| 42 | 4 | if ($this->authorizationValidator instanceof BearerTokenValidator === true) { |
|||||
| 43 | 4 | $this->authorizationValidator->setPublicKey($this->publicKey); |
|||||
|
0 ignored issues
–
show
The method
setPublicKey() does not exist on League\OAuth2\Server\Aut...ationValidatorInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to League\OAuth2\Server\Aut...ationValidatorInterface.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 44 | } |
||||||
| 45 | |||||||
| 46 | 4 | return $this->authorizationValidator; |
|||||
| 47 | } |
||||||
| 48 | |||||||
| 49 | /** |
||||||
| 50 | * Determine the access token validity. |
||||||
| 51 | * |
||||||
| 52 | * @throws OAuthServerException |
||||||
| 53 | */ |
||||||
| 54 | 4 | public function validateAuthenticatedRequest(ServerRequestInterface $request): ServerRequestInterface |
|||||
| 55 | { |
||||||
| 56 | 4 | return $this->getAuthorizationValidator()->validateAuthorization($request); |
|||||
| 57 | } |
||||||
| 58 | } |
||||||
| 59 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.