Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Sephster committed Oct 13, 2023
1 parent 6720d77 commit abfa828
Show file tree
Hide file tree
Showing 44 changed files with 38 additions and 271 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Authorization Request objects are now created through the factory method, `createAuthorizationRequest()` (PR #1111)
- Changed parameters for `finalizeScopes()` to allow a reference to an auth code ID (PR #1112)

### Removed
- Removed message property from OAuthException HTTP response. Now just use error_description as per the OAuth 2 spec (PR #1375)

### [8.3.6] - released 2022-11-14
### Fixed
- Use LooseValidAt instead of StrictValidAt so that users aren't forced to use claims such as NBF in their JWT tokens (PR #1312)
Expand Down
4 changes: 4 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ parameters:
- src
- tests
ignoreErrors:
-
message: '#Call to an undefined method League\\OAuth2\\Server\\ResponseTypes\\ResponseTypeInterface::getAccessToken\(\)\.#'
path: tests/Grant/ClientCredentialsGrantTest.php
- '#Return type \(League\\Event\\EmitterInterface\|null\) of method LeagueTests\\Stubs\\GrantType::getEmitter\(\) should be covariant with return type \(League\\Event\\EmitterInterface\) of method League\\Event\\EmitterAwareInterface::getEmitter\(\)#'
- '#Method League\\OAuth2\\Server\\Grant\\AbstractGrant::issueAccessToken\(\) should return League\\OAuth2\\Server\\Entities\\AccessTokenEntityInterface but return statement is missing\.#'
- '#Method League\\OAuth2\\Server\\Grant\\AbstractGrant::issueAuthCode\(\) should return League\\OAuth2\\Server\\Entities\\AuthCodeEntityInterface but return statement is missing\.#'
- '#Method League\\OAuth2\\Server\\Grant\\AbstractGrant::issueRefreshToken\(\) should return League\\OAuth2\\Server\\Entities\\RefreshTokenEntityInterface\|null but return statement is missing\.#'
15 changes: 3 additions & 12 deletions src/AuthorizationServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ class AuthorizationServer implements EmitterAwareInterface

protected ResponseTypeInterface $responseType;

private ClientRepositoryInterface $clientRepository;

private AccessTokenRepositoryInterface $accessTokenRepository;

private ScopeRepositoryInterface $scopeRepository;

private string|Key $encryptionKey;

private string $defaultScope = '';
Expand All @@ -64,16 +58,13 @@ class AuthorizationServer implements EmitterAwareInterface
* New server instance
*/
public function __construct(
ClientRepositoryInterface $clientRepository,
AccessTokenRepositoryInterface $accessTokenRepository,
ScopeRepositoryInterface $scopeRepository,
private ClientRepositoryInterface $clientRepository,
private AccessTokenRepositoryInterface $accessTokenRepository,
private ScopeRepositoryInterface $scopeRepository,
CryptKeyInterface|string $privateKey,
Key|string $encryptionKey,
ResponseTypeInterface|null $responseType = null
) {
$this->clientRepository = $clientRepository;
$this->accessTokenRepository = $accessTokenRepository;
$this->scopeRepository = $scopeRepository;

if ($privateKey instanceof CryptKeyInterface === false) {
$privateKey = new CryptKey($privateKey);
Expand Down
9 changes: 3 additions & 6 deletions src/AuthorizationValidators/BearerTokenValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,16 @@ class BearerTokenValidator implements AuthorizationValidatorInterface
{
use CryptTrait;

private AccessTokenRepositoryInterface $accessTokenRepository;

protected CryptKeyInterface $publicKey;

private Configuration $jwtConfiguration;

public function __construct(AccessTokenRepositoryInterface $accessTokenRepository)
public function __construct(private AccessTokenRepositoryInterface $accessTokenRepository)
{
$this->accessTokenRepository = $accessTokenRepository;
}

/**
* Set the public key
*
*/
public function setPublicKey(CryptKeyInterface $key): void
{
Expand Down Expand Up @@ -113,7 +109,7 @@ public function validateAuthorization(ServerRequestInterface $request): ServerRe
throw OAuthServerException::accessDenied('Access token could not be verified');
}

if (! $token instanceof UnencryptedToken) {
if (!$token instanceof UnencryptedToken) {
throw OAuthServerException::accessDenied('Access token is not an instance of UnencryptedToken');
}

Expand All @@ -135,6 +131,7 @@ public function validateAuthorization(ServerRequestInterface $request): ServerRe
/**
* Convert single record arrays into strings to ensure backwards compatibility between v4 and v3.x of lcobucci/jwt
*
* TODO: Investigate as I don't think we need this any more
*
* @return array<string>|string
*/
Expand Down
3 changes: 0 additions & 3 deletions src/CodeChallengeVerifiers/CodeChallengeVerifierInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ interface CodeChallengeVerifierInterface
{
/**
* Return code challenge method.
*
*/
public function getMethod(): string;

/**
* Verify the code challenge.
*
*
*/
public function verifyCodeChallenge(string $codeVerifier, string $codeChallenge): bool;
}
3 changes: 0 additions & 3 deletions src/CodeChallengeVerifiers/PlainVerifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class PlainVerifier implements CodeChallengeVerifierInterface
{
/**
* Return code challenge method.
*
*/
public function getMethod(): string
{
Expand All @@ -27,8 +26,6 @@ public function getMethod(): string

/**
* Verify the code challenge.
*
*
*/
public function verifyCodeChallenge(string $codeVerifier, string $codeChallenge): bool
{
Expand Down
3 changes: 0 additions & 3 deletions src/CodeChallengeVerifiers/S256Verifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class S256Verifier implements CodeChallengeVerifierInterface
{
/**
* Return code challenge method.
*
*/
public function getMethod(): string
{
Expand All @@ -31,8 +30,6 @@ public function getMethod(): string

/**
* Verify the code challenge.
*
*
*/
public function verifyCodeChallenge(string $codeVerifier, string $codeChallenge): bool
{
Expand Down
7 changes: 1 addition & 6 deletions src/CryptKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,8 @@ class CryptKey implements CryptKeyInterface

protected string $keyPath;

protected ?string $passPhrase = null;

public function __construct(string $keyPath, ?string $passPhrase = null, bool $keyPermissionsCheck = true)
public function __construct(string $keyPath, protected ?string $passPhrase = null, bool $keyPermissionsCheck = true)
{
$this->passPhrase = $passPhrase;

if (strpos($keyPath, self::FILE_PREFIX) !== 0 && $this->isValidKey($keyPath, $this->passPhrase ?? '')) {
$this->keyContents = $keyPath;
Expand Down Expand Up @@ -103,8 +100,6 @@ public function getKeyContents(): string

/**
* Validate key contents.
*
*
*/
private function isValidKey(string $contents, string $passPhrase): bool
{
Expand Down
4 changes: 0 additions & 4 deletions src/CryptTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ trait CryptTrait
/**
* Encrypt data with encryptionKey.
*
*
* @throws LogicException
*
*/
protected function encrypt(string $unencryptedData): string
{
Expand All @@ -52,9 +50,7 @@ protected function encrypt(string $unencryptedData): string
/**
* Decrypt data with encryptionKey.
*
*
* @throws LogicException
*
*/
protected function decrypt(string $encryptedData): string
{
Expand Down
8 changes: 2 additions & 6 deletions src/Entities/ClientEntityInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,24 @@ interface ClientEntityInterface
{
/**
* Get the client's identifier.
*
*/
public function getIdentifier(): string;

/**
* Get the client's name.
*
*/
public function getName(): string;

/**
* Returns the registered redirect URI (as a string).
*
* Alternatively return an indexed array of redirect URIs.
* Returns the registered redirect URI (as a string). Alternatively return
* an indexed array of redirect URIs.
*
* @return string|string[]
*/
public function getRedirectUri(): string|array;

/**
* Returns true if the client is confidential.
*
*/
public function isConfidential(): bool;
}
1 change: 0 additions & 1 deletion src/Entities/RefreshTokenEntityInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface RefreshTokenEntityInterface
{
/**
* Get the token's identifier.
*
*/
public function getIdentifier(): string;

Expand Down
1 change: 0 additions & 1 deletion src/Entities/ScopeEntityInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface ScopeEntityInterface extends JsonSerializable
{
/**
* Get the scope's identifier.
*
*/
public function getIdentifier(): string;
}
2 changes: 0 additions & 2 deletions src/Entities/TokenInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ interface TokenInterface
{
/**
* Get the token's identifier.
*
*/
public function getIdentifier(): string;

Expand All @@ -29,7 +28,6 @@ public function setIdentifier(mixed $identifier): void;

/**
* Get the token's expiry date time.
*
*/
public function getExpiryDateTime(): DateTimeImmutable;

Expand Down
3 changes: 2 additions & 1 deletion src/Entities/Traits/AccessTokenTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function initJwtConfiguration(): void

/**
* Generate a JWT from the access token
*
*/
private function convertToJWT(): Token
{
Expand All @@ -75,6 +74,8 @@ private function convertToJWT(): Token

/**
* Generate a string representation from the access token
*
* TODO: Want to remove this function.
*/
public function __toString(): string
{
Expand Down
6 changes: 2 additions & 4 deletions src/Entities/Traits/ClientTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ public function getName(): string
}

/**
* Returns the registered redirect URI (as a string).
*
* Alternatively return an indexed array of redirect URIs.
* Returns the registered redirect URI (as a string). Alternatively return
* an indexed array of redirect URIs.
*
* @return string|string[]
*/
Expand All @@ -47,7 +46,6 @@ public function getRedirectUri(): string|array

/**
* Returns true if the client is confidential.
*
*/
public function isConfidential(): bool
{
Expand Down
1 change: 0 additions & 1 deletion src/Entities/Traits/ScopeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ trait ScopeTrait
{
/**
* Serialize the object to the scopes string identifier when using json_encode().
*
*/
public function jsonSerialize(): string
{
Expand Down
2 changes: 0 additions & 2 deletions src/Entities/Traits/TokenEntityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ trait TokenEntityTrait

/**
* Associate a scope with the token.
*
*/
public function addScope(ScopeEntityInterface $scope): void
{
Expand Down Expand Up @@ -78,7 +77,6 @@ public function setUserIdentifier(string|int|null $identifier): void

/**
* Get the token user's identifier.
*
*/
public function getUserIdentifier(): string|int|null
{
Expand Down
1 change: 0 additions & 1 deletion src/Entities/UserEntityInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface UserEntityInterface
{
/**
* Return the user's identifier.
*
*/
public function getIdentifier(): mixed;
}
Loading

0 comments on commit abfa828

Please sign in to comment.