diff --git a/api/components/Tokens/TokenReader.php b/api/components/Tokens/TokenReader.php index 70b5bf5..2305c90 100644 --- a/api/components/Tokens/TokenReader.php +++ b/api/components/Tokens/TokenReader.php @@ -31,12 +31,12 @@ final readonly class TokenReader { } /** - * @return list|null + * @return list|null */ public function getScopes(): ?array { $scopes = $this->token->claims()->get('scope', false); if ($scopes !== false) { - return explode(' ', (string)$scopes); + return self::splitScopes((string)$scopes, ' '); } // Handle legacy tokens, which used "ely-scopes" claim and was delimited with comma @@ -45,7 +45,14 @@ final readonly class TokenReader { return null; } - return explode(',', (string)$scopes); + return self::splitScopes((string)$scopes, ','); + } + + /** + * @param non-empty-string $scope + */ + public function hasScope(string $scope): bool { + return in_array($scope, $this->getScopes() ?? [], true); } public function getMinecraftClientToken(): ?string { @@ -61,4 +68,12 @@ final readonly class TokenReader { return Yii::$app->tokens->decryptValue($encodedClientToken); } + /** + * @param non-empty-string $delimiter + * @return list + */ + private static function splitScopes(string $scopes, string $delimiter): array { + return array_values(array_filter(explode($delimiter, $scopes), fn(string $scope): bool => !empty($scope))); + } + } diff --git a/api/components/User/JwtIdentity.php b/api/components/User/JwtIdentity.php index 9a023dc..ab026cd 100644 --- a/api/components/User/JwtIdentity.php +++ b/api/components/User/JwtIdentity.php @@ -10,6 +10,7 @@ use common\models\Account; use common\models\OauthClient; use common\models\OauthSession; use DateTimeImmutable; +use DateTimeInterface; use Exception; use Lcobucci\JWT\UnencryptedToken; use Lcobucci\JWT\Validation\Constraint\LooseValidAt; @@ -101,9 +102,13 @@ class JwtIdentity implements IdentityInterface { throw new NotSupportedException('This method used for cookie auth, except we using Bearer auth'); } - private static function isRevoked(int $accountId, string $clientId, DateTimeImmutable $iat): bool { + private static function isRevoked(int $accountId, string $clientId, DateTimeInterface $iat): bool { $session = OauthSession::findOne(['account_id' => $accountId, 'client_id' => $clientId]); - return $session !== null && $session->revoked_at !== null && $session->revoked_at > $iat->getTimestamp(); + if ($session === null) { + return true; + } + + return $session->isRevokedForTokenIssuedAt($iat); } /** @codeCoverageIgnoreEnd */ diff --git a/api/tests/functional/oauth/AccessTokenCest.php b/api/tests/functional/oauth/AccessTokenCest.php index b4d66c0..31fcebb 100644 --- a/api/tests/functional/oauth/AccessTokenCest.php +++ b/api/tests/functional/oauth/AccessTokenCest.php @@ -92,4 +92,34 @@ final class AccessTokenCest { ]); } + public function issueTokenWithoutClientSecret(OauthSteps $I): void { + $authCode = $I->obtainAuthCode(); + $I->sendPOST('/api/oauth2/v1/token', [ + 'grant_type' => 'authorization_code', + 'code' => $authCode, + 'client_id' => 'ely', + // no client_secret + 'redirect_uri' => 'http://ely.by', + ]); + $I->canSeeResponseCodeIs(401); + $I->canSeeResponseContainsJson([ + 'error' => 'invalid_client', + ]); + $I->cantSeeResponseJsonMatchesJsonPath('$.access_token'); + } + + public function issueTokenByPassingTheSameAuthCodeTwice(OauthSteps $I): void { + $authCode = $I->obtainAuthCode(); + $I->issueToken($authCode); + $I->canSeeResponseCodeIs(200); + $I->canSeeResponseJsonMatchesJsonPath('$.access_token'); + + $I->issueToken($authCode); + $I->canSeeResponseCodeIs(400); + $I->canSeeResponseContainsJson([ + 'error' => 'invalid_grant', + ]); + $I->cantSeeResponseJsonMatchesJsonPath('$.access_token'); + } + } diff --git a/api/tests/functional/oauth/ClientCredentialsCest.php b/api/tests/functional/oauth/ClientCredentialsCest.php index 278d947..cf3cc95 100644 --- a/api/tests/functional/oauth/ClientCredentialsCest.php +++ b/api/tests/functional/oauth/ClientCredentialsCest.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace api\tests\functional\oauth; use api\tests\FunctionalTester; +use Codeception\Attribute\Examples; +use Codeception\Example; class ClientCredentialsCest { @@ -73,6 +75,31 @@ class ClientCredentialsCest { ]); } + /** + * @param Example $case + */ + #[Examples(null)] + #[Examples('')] + public function issueTokenWithoutClientSecret(FunctionalTester $I, Example $case): void { + $I->wantToTest('that the client must be authenticated by its secret'); + $params = [ + 'grant_type' => 'client_credentials', + 'client_id' => 'trusted-client', + // no client_secret + 'scope' => 'block_account', + ]; + if ($case[0] !== null) { + $params['client_secret'] = $case[0]; + } + + $I->sendPOST('/api/oauth2/v1/token', $params); + $I->canSeeResponseCodeIs(401); + $I->canSeeResponseContainsJson([ + 'error' => 'invalid_client', + ]); + $I->cantSeeResponseJsonMatchesJsonPath('$.access_token'); + } + private function assertSuccessResponse(FunctionalTester $I): void { $I->canSeeResponseCodeIs(200); $I->canSeeResponseContainsJson([ diff --git a/api/tests/functional/oauth/DeviceCodeCest.php b/api/tests/functional/oauth/DeviceCodeCest.php index 500c765..0137329 100644 --- a/api/tests/functional/oauth/DeviceCodeCest.php +++ b/api/tests/functional/oauth/DeviceCodeCest.php @@ -28,6 +28,7 @@ final class DeviceCodeCest { $I->sendPOST('/api/oauth2/v1/token', [ 'grant_type' => 'urn:ietf:params:oauth:grant-type:device_code', 'client_id' => 'ely', + 'client_secret' => 'ZuM1vGchJz-9_UZ5HC3H3Z9Hg5PzdbkM', 'device_code' => 'nKuYFfwckZywqU8iUKv3ek4VtiMiMCkiC0YTZFPbWycSxdRpHiYP2wnv3S0KHBgYky8fRDqfhhCqzke7', ]); $I->canSeeResponseCodeIs(400); @@ -36,10 +37,24 @@ final class DeviceCodeCest { ]); } + public function pollDeviceCodeWithoutClientSecret(FunctionalTester $I): void { + $I->wantToTest('that the confidential client must be authenticated by its secret during polling'); + $I->sendPOST('/api/oauth2/v1/token', [ + 'grant_type' => 'urn:ietf:params:oauth:grant-type:device_code', + 'client_id' => 'ely', + 'device_code' => 'nKuYFfwckZywqU8iUKv3ek4VtiMiMCkiC0YTZFPbWycSxdRpHiYP2wnv3S0KHBgYky8fRDqfhhCqzke7', + ]); + $I->canSeeResponseCodeIs(401); + $I->canSeeResponseContainsJson([ + 'error' => 'invalid_client', + ]); + } + public function pollExpiredDeviceCode(FunctionalTester $I): void { $I->sendPOST('/api/oauth2/v1/token', [ 'grant_type' => 'urn:ietf:params:oauth:grant-type:device_code', 'client_id' => 'ely', + 'client_secret' => 'ZuM1vGchJz-9_UZ5HC3H3Z9Hg5PzdbkM', 'device_code' => 'ZFPbWycSxdRpHiYP2wnv3S0KHBgYky8fRDqfhhCqzke7nKuYFfwckZywqU8iUKv3ek4VtiMiMCkiC0YT', ]); $I->canSeeResponseCodeIs(400); @@ -75,6 +90,7 @@ final class DeviceCodeCest { $I->sendPOST('/api/oauth2/v1/token', [ 'grant_type' => 'urn:ietf:params:oauth:grant-type:device_code', 'client_id' => 'ely', + 'client_secret' => 'ZuM1vGchJz-9_UZ5HC3H3Z9Hg5PzdbkM', 'device_code' => $deviceCode, ]); if ($case[0]) { diff --git a/api/tests/functional/oauth/RefreshTokenCest.php b/api/tests/functional/oauth/RefreshTokenCest.php index b222fb4..937dc9f 100644 --- a/api/tests/functional/oauth/RefreshTokenCest.php +++ b/api/tests/functional/oauth/RefreshTokenCest.php @@ -5,6 +5,7 @@ namespace api\tests\functional\oauth; use api\tests\functional\_steps\OauthSteps; use api\tests\FunctionalTester; +use common\models\OauthSession; class RefreshTokenCest { @@ -98,6 +99,89 @@ class RefreshTokenCest { ]); } + public function refreshTokenWithoutClientSecret(OauthSteps $I): void { + $I->wantToTest('that the confidential client must be authenticated by its secret'); + $refreshToken = $I->getRefreshToken(); + $I->sendPOST('/api/oauth2/v1/token', [ + 'grant_type' => 'refresh_token', + 'refresh_token' => $refreshToken, + 'client_id' => 'ely', + // no client_secret + ]); + $I->canSeeResponseCodeIs(401); + $I->canSeeResponseContainsJson([ + 'error' => 'invalid_client', + ]); + } + + public function refreshTokenByAnotherClient(OauthSteps $I): void { + $I->wantToTest('that the refresh token can be used only by the client it was issued to'); + $refreshToken = $I->getRefreshToken(); + $I->sendPOST('/api/oauth2/v1/token', [ + 'grant_type' => 'refresh_token', + 'refresh_token' => $refreshToken, + 'client_id' => 'tlauncher', + 'client_secret' => 'HsX-xXzdGiz3mcsqeEvrKHF47sqiaX94', + ]); + $this->canSeeInvalidRefreshToken($I); + } + + public function refreshAccessTokenWithoutOfflineAccess(OauthSteps $I): void { + $I->wantToTest('that the access token, issued without offline_access scope, can\'t be used as a refresh token'); + $accessToken = $I->getAccessToken(['account_info']); + $I->sendPOST('/api/oauth2/v1/token', [ + 'grant_type' => 'refresh_token', + 'refresh_token' => $accessToken, + 'client_id' => 'ely', + 'client_secret' => 'ZuM1vGchJz-9_UZ5HC3H3Z9Hg5PzdbkM', + ]); + $this->canSeeInvalidRefreshToken($I); + } + + public function refreshTokenAfterSessionRevocation(OauthSteps $I): void { + $I->wantToTest('that the refresh token stops working after the user revoked the access'); + $refreshToken = $I->getRefreshToken(['account_info']); + /** @var OauthSession $session */ + $session = OauthSession::findOne(['account_id' => 1, 'client_id' => 'ely']); + $session->revoked_at = time() + 1; + $session->save(); + + $I->sendPOST('/api/oauth2/v1/token', [ + 'grant_type' => 'refresh_token', + 'refresh_token' => $refreshToken, + 'client_id' => 'ely', + 'client_secret' => 'ZuM1vGchJz-9_UZ5HC3H3Z9Hg5PzdbkM', + ]); + $this->canSeeInvalidRefreshToken($I); + } + + public function refreshMinecraftAuthserverToken(FunctionalTester $I): void { + $I->wantToTest('that the authserver token can\'t be exchanged for the OAuth2 token'); + $I->sendPOST('/api/authserver/authentication/authenticate', [ + 'username' => 'admin', + 'password' => 'password_0', + 'clientToken' => 'ebc0a2a9-7f0b-4ff1-9b3b-7a0d1b6a9c0e', + ]); + $I->canSeeResponseCodeIs(200); + [$accessToken] = $I->grabDataFromResponseByJsonPath('$.accessToken'); + + $I->sendPOST('/api/oauth2/v1/token', [ + 'grant_type' => 'refresh_token', + 'refresh_token' => $accessToken, + 'client_id' => 'ely', + 'client_secret' => 'ZuM1vGchJz-9_UZ5HC3H3Z9Hg5PzdbkM', + ]); + $this->canSeeInvalidRefreshToken($I); + } + + private function canSeeInvalidRefreshToken(FunctionalTester $I): void { + $I->canSeeResponseCodeIs(400); + $I->canSeeResponseContainsJson([ + 'error' => 'invalid_grant', + ]); + $I->cantSeeResponseJsonMatchesJsonPath('$.access_token'); + } + private function canSeeRefreshTokenSuccess(FunctionalTester $I): void { $I->canSeeResponseCodeIs(200); $I->canSeeResponseContainsJson([ diff --git a/api/tests/functional/oauth/ValidateCest.php b/api/tests/functional/oauth/ValidateCest.php index 2fd82f4..b036e66 100644 --- a/api/tests/functional/oauth/ValidateCest.php +++ b/api/tests/functional/oauth/ValidateCest.php @@ -4,6 +4,8 @@ declare(strict_types=1); namespace api\tests\functional\oauth; use api\tests\FunctionalTester; +use Codeception\Attribute\Examples; +use Codeception\Example; final class ValidateCest { @@ -95,6 +97,28 @@ final class ValidateCest { ]); } + /** + * @param Example $case + */ + #[Examples('http://ely.by.evil.com/callback')] + #[Examples('http://ely.by@evil.com/callback')] + #[Examples('http://ely.by:8080/callback')] + #[Examples('https://ely.by/callback')] + public function passRedirectUriThatOnlyStartsWithTheRegisteredOne(FunctionalTester $I, Example $case): void { + $I->sendGET('/api/oauth2/v1/validate', [ + 'client_id' => 'ely', + 'redirect_uri' => $case[0], + 'response_type' => 'code', + 'scope' => 'account_info', + ]); + $I->canSeeResponseCodeIs(401); + $I->canSeeResponseContainsJson([ + 'success' => false, + 'error' => 'invalid_client', + 'statusCode' => 401, + ]); + } + public function invalidCodeForDeviceCode(FunctionalTester $I): void { $I->sendGET('/api/oauth2/v1/validate', [ 'user_code' => 'XXXXXXXX', diff --git a/api/tests/unit/components/OAuth2/Grants/ValidateRedirectUriTraitTest.php b/api/tests/unit/components/OAuth2/Grants/ValidateRedirectUriTraitTest.php new file mode 100644 index 0000000..6dbbbc2 --- /dev/null +++ b/api/tests/unit/components/OAuth2/Grants/ValidateRedirectUriTraitTest.php @@ -0,0 +1,135 @@ + + */ + public static function webApplicationRedirectUris(): iterable { + // Allowed + yield ['http://ely.by', 'http://ely.by', true]; + yield ['http://ely.by', 'http://ely.by/', true]; + yield ['http://ely.by', 'http://ely.by/oauth/callback', true]; + yield ['http://ely.by', 'http://ely.by?param=value', true]; + yield ['http://ely.by', 'HTTP://ELY.BY/callback', true]; + yield ['http://ely.by', 'http://ely.by:80/callback', true]; + yield ['https://example.com/oauth/ely', 'https://example.com/oauth/ely', true]; + yield ['https://example.com/oauth/ely', 'https://example.com/oauth/ely/', true]; + yield ['https://example.com/oauth/ely', 'https://example.com/oauth/ely/callback', true]; + yield ['https://example.com/oauth/ely', 'https://example.com/oauth/ely?param=value', true]; + yield ['https://example.com/oauth/ely/', 'https://example.com/oauth/ely/callback', true]; + yield ['https://example.com/cb?a=1', 'https://example.com/cb?a=1', true]; + yield ['https://example.com/cb?a=1', 'https://example.com/cb?a=1&b=2', true]; + yield ['https://пример.рф/cb', 'https://xn--e1afmkfd.xn--p1ai/cb/callback', true]; + yield ['https://xn--e1afmkfd.xn--p1ai/cb', 'https://пример.рф/cb/callback', true]; + // The uri is normalized the same way the browser does it, so the validation is made against the actual destination + yield ['http://ely.by', 'http://ely.by\\@evil.com', true]; // Browser goes to http://ely.by/@evil.com + yield ['http://ely.by', "http://ely.by/\ncallback", true]; // Browser goes to http://ely.by/callback + yield ['http://ely.by', ' http://ely.by/callback ', true]; + yield ['https://example.com/oauth/ely', 'https://example.com/oauth/ely/sub/../callback', true]; + yield ['https://example.com/oauth/ely', 'https://example.com/oauth/ely/%2e/callback', true]; + + // Denied + yield ['http://ely.by', 'http://ely.by.evil.com', false]; + yield ['http://ely.by', 'http://ely.by.evil.com/callback', false]; + yield ['http://ely.by', 'http://ely.by@evil.com', false]; + yield ['http://ely.by', 'http://ely.by:password@evil.com', false]; + yield ['http://ely.by', 'http://ely.by:8080', false]; + yield ['http://ely.by', 'https://ely.by', false]; + yield ['http://ely.by', '//ely.by', false]; + yield ['http://ely.by', 'http://ely.by/#fragment', false]; + yield ['http://ely.by', 'http://ely.by/#', false]; + yield ['http://ely.by', 'http://evil.com\\.ely.by/callback', false]; + yield ['http://ely.by', '', false]; + yield ['https://example.com/oauth/ely', 'https://example.com/oauth/elyevil', false]; + yield ['https://example.com/oauth/ely', 'https://example.com/oauth', false]; + yield ['https://example.com/oauth/ely', 'https://example.com/oauth/ely/../../evil', false]; + yield ['https://example.com/oauth/ely', 'https://example.com/oauth/ely/%2e%2e/evil', false]; + yield ['https://example.com/oauth/ely', 'https://example.com/oauth/ely%2Fevil', false]; + yield ['https://example.com/cb?a=1', 'https://example.com/cb?a=10', false]; + yield ['https://example.com/cb?a=1', 'https://example.com/cb/other?a=1', false]; + } + + /** + * @dataProvider webApplicationRedirectUris + */ + public function testWebApplication(string $registeredUri, string $redirectUri, bool $expected): void { + $client = new OauthClient(); + $client->type = OauthClient::TYPE_WEB_APPLICATION; + $this->assertValidation(new ClientEntity('ely', 'Ely.by', $registeredUri, model: $client), $redirectUri, $expected); + } + + /** + * @return iterable + */ + public static function desktopApplicationRedirectUris(): iterable { + // Allowed + yield ['http://localhost', true]; + yield ['http://localhost:51234/callback', true]; + yield ['http://127.0.0.1:51234/callback', true]; + yield ['http://[::1]:51234/callback', true]; + yield ['https://localhost/callback', true]; + yield ['com.example.app:/oauth2redirect', true]; + yield ['my-app://callback', true]; + yield ['http://LOCALHOST:51234/callback', true]; + yield ['http://0x7f.1:51234/callback', true]; // Browser treats it as 127.0.0.1 + + // Denied + yield ['http://example.com/callback', false]; + yield ['http://localhost@evil.com/callback', false]; + yield ['http://localhost.evil.com/callback', false]; + yield ['//evil.com/callback', false]; + yield ['/callback', false]; + yield ['javascript:alert(1)', false]; + yield ['JavaScript:alert(1)', false]; + yield ['data:text/html,test', false]; + yield ['file:///etc/passwd', false]; + yield ['my-app://callback#fragment', false]; + yield ['my-app://user@callback', false]; + yield ['http://localhost.:51234/callback', false]; + yield ['', false]; + } + + /** + * @dataProvider desktopApplicationRedirectUris + */ + public function testDesktopApplication(string $redirectUri, bool $expected): void { + $client = new OauthClient(); + $client->type = OauthClient::TYPE_DESKTOP_APPLICATION; + $this->assertValidation(new ClientEntity('desktop', 'Desktop', '', model: $client), $redirectUri, $expected); + } + + private function assertValidation(ClientEntity $client, string $redirectUri, bool $expected): void { + $validator = new class { + use ValidateRedirectUriTrait { + validateRedirectUri as public; + } + + public function getEmitter(): EventEmitter { + return new EventEmitter(); + } + }; + + try { + $validator->validateRedirectUri($redirectUri, $client, new ServerRequest('GET', 'http://localhost')); + $isValid = true; + } catch (OAuthServerException $e) { + $this->assertSame('invalid_client', $e->getErrorType()); + $isValid = false; + } + + $this->assertSame($expected, $isValid, "Redirect uri \"{$redirectUri}\" validation result is unexpected"); + } + +} diff --git a/api/tests/unit/components/Tokens/TokenReaderTest.php b/api/tests/unit/components/Tokens/TokenReaderTest.php index 31738a1..089edfe 100644 --- a/api/tests/unit/components/Tokens/TokenReaderTest.php +++ b/api/tests/unit/components/Tokens/TokenReaderTest.php @@ -49,9 +49,39 @@ class TokenReaderTest extends TestCase { public function getScopesTestCases(): iterable { yield [['scope' => 'scope1 scope2'], ['scope1', 'scope2']]; yield [['ely-scopes' => 'scope1,scope2'], ['scope1', 'scope2']]; + yield [['scope' => ' scope1 scope2 '], ['scope1', 'scope2']]; + yield [['ely-scopes' => ',scope1,,scope2,'], ['scope1', 'scope2']]; + yield [['scope' => ' '], []]; yield [[], null]; } + /** + * @dataProvider hasScopeTestCases + * + * @param array $claims + * @param non-empty-string $scope + */ + public function testHasScope(array $claims, string $scope, bool $expectedResult): void { + $this->assertSame($expectedResult, $this->createReader($claims)->hasScope($scope)); + } + + /** + * @return iterable, non-empty-string, bool}> + */ + public function hasScopeTestCases(): iterable { + yield 'first scope' => [['scope' => 'scope1 scope2'], 'scope1', true]; + yield 'last scope' => [['scope' => 'scope1 scope2'], 'scope2', true]; + yield 'single scope' => [['scope' => 'scope1'], 'scope1', true]; + yield 'missing scope' => [['scope' => 'scope1 scope2'], 'scope3', false]; + yield 'partial match' => [['scope' => 'scope1 scope2'], 'scope', false]; + yield 'case sensitive' => [['scope' => 'scope1 scope2'], 'SCOPE1', false]; + yield 'legacy claim' => [['ely-scopes' => 'scope1,scope2'], 'scope2', true]; + yield 'legacy claim, missing scope' => [['ely-scopes' => 'scope1,scope2'], 'scope3', false]; + yield 'legacy claim is not delimited by space' => [['ely-scopes' => 'scope1 scope2'], 'scope2', false]; + yield 'scope claim takes precedence' => [['scope' => 'scope1', 'ely-scopes' => 'scope2'], 'scope2', false]; + yield 'no scopes claims' => [[], 'scope1', false]; + } + /** * @dataProvider getMinecraftClientTokenTestCases */ diff --git a/common/components/OAuth2/Grants/RefreshTokenGrant.php b/common/components/OAuth2/Grants/RefreshTokenGrant.php index b60c74d..fd87c76 100644 --- a/common/components/OAuth2/Grants/RefreshTokenGrant.php +++ b/common/components/OAuth2/Grants/RefreshTokenGrant.php @@ -6,7 +6,9 @@ namespace common\components\OAuth2\Grants; use api\components\Tokens\TokenReader; use Carbon\FactoryImmutable; use common\components\OAuth2\CryptTrait; +use common\components\OAuth2\Repositories\PublicScopeRepository; use common\models\OauthSession; +use DateTimeImmutable; use InvalidArgumentException; use Lcobucci\JWT\Validation\Constraint\LooseValidAt; use Lcobucci\JWT\Validation\Validator; @@ -18,24 +20,36 @@ use Psr\Http\Message\ServerRequestInterface; use Throwable; use Yii; +/** + * Access tokens don't expire and can only be revoked, so there are no separate refresh tokens. + * For backward compatibility, when the offline_access scope is requested, the access_token + * is also returned as the refresh_token (see OauthProcess::getToken()). + * + * This grant is overridden to accept such a token as the refresh_token and issue a new access token from it, + * as long as the token was issued to the same client with the offline_access scope + * and the user hasn't revoked the access since then. + */ final class RefreshTokenGrant extends BaseRefreshTokenGrant { use CryptTrait; use ValidateRedirectUriTrait; /** - * Previously, refresh tokens were stored in Redis. - * If received refresh token is matches the legacy token template, - * restore the information from the legacy storage. + * The original implementation decrypts the refresh token payload, but we use the access token + * as the refresh token, so it's validated as a JWT instead. * * @inheritDoc */ protected function validateOldRefreshToken(ServerRequestInterface $request, string $clientId): array { $refreshToken = $this->getRequestParameter('refresh_token', $request); - if ($refreshToken !== null && mb_strlen($refreshToken) === 40) { - return $this->validateLegacyRefreshToken($refreshToken); + if ($refreshToken === null) { + throw OAuthServerException::invalidRequest('refresh_token'); } - return $this->validateAccessToken($refreshToken); + if (mb_strlen($refreshToken) === 40) { + return $this->validateLegacyRefreshToken($refreshToken, $clientId); + } + + return $this->validateAccessToken($refreshToken, $clientId); } /** @@ -51,7 +65,7 @@ final class RefreshTokenGrant extends BaseRefreshTokenGrant { * @return array * @throws OAuthServerException */ - private function validateLegacyRefreshToken(string $refreshToken): array { + private function validateLegacyRefreshToken(string $refreshToken, string $clientId): array { $result = Yii::$app->redis->get("oauth:refresh:tokens:{$refreshToken}"); if ($result === null) { throw OAuthServerException::invalidRefreshToken('Token has been revoked'); @@ -68,10 +82,14 @@ final class RefreshTokenGrant extends BaseRefreshTokenGrant { /** @var OauthSession|null $relatedSession */ $relatedSession = OauthSession::findOne(['legacy_id' => $sessionId]); - if ($relatedSession === null) { + if ($relatedSession === null || $relatedSession->revoked_at !== null) { throw OAuthServerException::invalidRefreshToken('Token has been revoked'); } + if ($relatedSession->client_id !== $clientId) { + throw OAuthServerException::invalidRefreshToken('Token is not linked to client'); + } + return [ 'client_id' => $relatedSession->client_id, 'refresh_token_id' => $refreshToken, @@ -86,7 +104,7 @@ final class RefreshTokenGrant extends BaseRefreshTokenGrant { * @return array * @throws OAuthServerException */ - private function validateAccessToken(string $jwt): array { + private function validateAccessToken(string $jwt, string $clientId): array { try { $token = Yii::$app->tokens->parse($jwt); } catch (InvalidArgumentException $e) { @@ -102,13 +120,37 @@ final class RefreshTokenGrant extends BaseRefreshTokenGrant { } $reader = new TokenReader($token); + $tokenClientId = $reader->getClientId(); + $accountId = $reader->getAccountId(); + if ($tokenClientId === null || $accountId === null) { + throw OAuthServerException::invalidRefreshToken('Token is not a refresh token'); + } + + if ($tokenClientId !== $clientId) { + throw OAuthServerException::invalidRefreshToken('Token is not linked to client'); + } + + // Since refresh_token is the same value as the access_token, the token can be used as a refresh token + // only when the offline_access scope was requested + if (!$reader->hasScope(PublicScopeRepository::OFFLINE_ACCESS)) { + throw OAuthServerException::invalidRefreshToken('Token is not a refresh token'); + } + + /** @var DateTimeImmutable $iat */ + $iat = $token->claims()->get('iat'); + /** @var OauthSession|null $session */ + $session = OauthSession::findOne(['account_id' => $accountId, 'client_id' => $clientId]); + // Session is always created when the user grants access, so its absence means that it was revoked + if ($session === null || $session->isRevokedForTokenIssuedAt($iat)) { + throw OAuthServerException::invalidRefreshToken('Token has been revoked'); + } return [ - 'client_id' => $reader->getClientId(), + 'client_id' => $tokenClientId, 'refresh_token_id' => '', // This value used only to invalidate old token 'access_token_id' => '', // This value used only to invalidate old token 'scopes' => $reader->getScopes(), - 'user_id' => $reader->getAccountId(), + 'user_id' => $accountId, 'expire_time' => null, ]; } diff --git a/common/components/OAuth2/Grants/ValidateRedirectUriTrait.php b/common/components/OAuth2/Grants/ValidateRedirectUriTrait.php index 2047ffa..fadacbc 100644 --- a/common/components/OAuth2/Grants/ValidateRedirectUriTrait.php +++ b/common/components/OAuth2/Grants/ValidateRedirectUriTrait.php @@ -10,7 +10,7 @@ use League\OAuth2\Server\EventEmitting\EventEmitter; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\RequestEvent; use Psr\Http\Message\ServerRequestInterface; -use yii\helpers\StringHelper; +use Uri\WhatWg\Url; trait ValidateRedirectUriTrait { @@ -18,6 +18,7 @@ trait ValidateRedirectUriTrait { /** * Override the original method since we need a custom validation logic based on the client type. + * * @inheritDoc */ protected function validateRedirectUri( @@ -25,25 +26,17 @@ trait ValidateRedirectUriTrait { ClientEntityInterface $client, ServerRequestInterface $request, ): void { - if ($client instanceof ClientEntity && $client->model?->type === OauthClient::TYPE_DESKTOP_APPLICATION) { - $uri = parse_url($redirectUri); - if ($uri) { - // Allow any custom scheme, that is not http - if ($uri['scheme'] !== 'http' && $uri['scheme'] !== 'https') { + $url = self::parseRedirectUri($redirectUri); + if ($url !== null) { + if ($client instanceof ClientEntity && $client->model?->type === OauthClient::TYPE_DESKTOP_APPLICATION) { + if (self::isAllowedDesktopRedirectUri($url)) { return; } - - // If it's a http, than should allow only redirection to the local machine - if (in_array($uri['host'], ['localhost', '127.0.0.1', '[::1]'])) { - return; - } - } - } else { - // The original implementation checks url too strictly (port and path must exactly match). - // It's nice to have, but we made it this way earlier and so we must keep the same behavior as long as possible - foreach ((array)$client->getRedirectUri() as $allowedRedirectUri) { - if (StringHelper::startsWith($redirectUri, $allowedRedirectUri)) { - return; + } else { + foreach ((array)$client->getRedirectUri() as $allowedRedirectUri) { + if (self::isMatchingRegisteredRedirectUri($url, (string)$allowedRedirectUri)) { + return; + } } } } @@ -53,4 +46,78 @@ trait ValidateRedirectUriTrait { throw OAuthServerException::invalidClient($request); } + private static function parseRedirectUri(string $redirectUri): ?Url { + $url = Url::parse($redirectUri); + if ($url === null) { + return null; + } + + // The redirection endpoint URI MUST NOT include a fragment component (RFC 6749 section 3.1.2) + if ($url->getFragment() !== null) { + return null; + } + + // There is no legitimate reason to pass credentials within the redirect uri + if ($url->getUsername() !== null || $url->getPassword() !== null) { + return null; + } + + return $url; + } + + /** + * Desktop applications are allowed to use any custom URI scheme (RFC 8252 section 7.1) + * or the loopback interface with any port (RFC 8252 section 7.3). + */ + private static function isAllowedDesktopRedirectUri(Url $url): bool { + $scheme = $url->getScheme(); + if ($scheme === 'http' || $scheme === 'https') { + return in_array($url->getAsciiHost(), ['localhost', '127.0.0.1', '[::1]'], true); + } + + // Schemes that are able to execute code or to read local data in the browser + return !in_array($scheme, ['javascript', 'data', 'vbscript', 'file', 'blob', 'about', 'filesystem'], true); + } + + /** + * The original library implementation requires an exact match. Historically we allowed any redirect uri, + * which starts with the registered one, so to keep the compatibility we still allow to extend the registered + * path and query, but the scheme, the host and the port must match exactly and the path can be extended + * only on the segment boundary. + */ + private static function isMatchingRegisteredRedirectUri(Url $url, string $registeredRedirectUri): bool { + $registered = Url::parse($registeredRedirectUri); + if ($registered === null || $registered->getAsciiHost() === null) { + return false; + } + + // The default port is normalized to null, so it is handled correctly here + if ($url->getScheme() !== $registered->getScheme() + || $url->getAsciiHost() !== $registered->getAsciiHost() + || $url->getPort() !== $registered->getPort() + ) { + return false; + } + + $path = $url->getPath(); + $registeredPath = rtrim($registered->getPath(), '/'); + if ($path !== $registeredPath && !str_starts_with($path, $registeredPath . '/')) { + return false; + } + + $registeredQuery = $registered->getQuery(); + if ($registeredQuery !== null && $registeredQuery !== '') { + if ($path !== $registered->getPath()) { + return false; + } + + $query = $url->getQuery() ?? ''; + if ($query !== $registeredQuery && !str_starts_with($query, $registeredQuery . '&')) { + return false; + } + } + + return true; + } + } diff --git a/common/components/OAuth2/Repositories/AuthCodeRepository.php b/common/components/OAuth2/Repositories/AuthCodeRepository.php index 324c5d6..4f866bd 100644 --- a/common/components/OAuth2/Repositories/AuthCodeRepository.php +++ b/common/components/OAuth2/Repositories/AuthCodeRepository.php @@ -6,9 +6,20 @@ namespace common\components\OAuth2\Repositories; use common\components\OAuth2\Entities\AuthCodeEntity; use League\OAuth2\Server\Entities\AuthCodeEntityInterface; use League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface; +use Yii; +/** + * Auth codes are self-contained encrypted values, so there is no need to store them. + * But the code must be used only once (RFC 6749 section 4.1.2), so the used codes ids are stored + * until the code is expired. + */ final class AuthCodeRepository implements AuthCodeRepositoryInterface { + /** + * Must be greater than the auth code TTL + */ + private const int USED_CODE_TTL = 60 * 60; + public function getNewAuthCode(): AuthCodeEntityInterface { return new AuthCodeEntity(); } @@ -17,10 +28,19 @@ final class AuthCodeRepository implements AuthCodeRepositoryInterface { } public function revokeAuthCode(string $codeId): void { + Yii::$app->redis->setex($this->buildKey($codeId), self::USED_CODE_TTL, '1'); } + /** + * The library checks the code at the beginning of the exchange and revokes it only at the end. + * To prevent the concurrent exchange of the same code, the code is atomically marked as used during the check. + */ public function isAuthCodeRevoked(string $codeId): bool { - return false; + return Yii::$app->redis->set($this->buildKey($codeId), '1', 'EX', self::USED_CODE_TTL, 'NX') !== true; + } + + private function buildKey(string $codeId): string { + return "oauth:auth-codes:used:{$codeId}"; } } diff --git a/common/components/OAuth2/Repositories/ClientRepository.php b/common/components/OAuth2/Repositories/ClientRepository.php index 0709225..3857596 100644 --- a/common/components/OAuth2/Repositories/ClientRepository.php +++ b/common/components/OAuth2/Repositories/ClientRepository.php @@ -29,8 +29,15 @@ final class ClientRepository implements ClientRepositoryInterface { return false; } - if ($client->type === OauthClient::TYPE_WEB_APPLICATION && !empty($clientSecret) && $clientSecret !== $client->secret) { - return false; + if ($client->type !== OauthClient::TYPE_DESKTOP_APPLICATION) { + // The library passes an empty string when the secret wasn't provided at all + if (empty($clientSecret) || empty($client->secret)) { + return false; + } + + if (!hash_equals($client->secret, $clientSecret)) { + return false; + } } return true; diff --git a/common/models/OauthSession.php b/common/models/OauthSession.php index c87b93b..52bc780 100644 --- a/common/models/OauthSession.php +++ b/common/models/OauthSession.php @@ -3,6 +3,8 @@ declare(strict_types=1); namespace common\models; +use Carbon\Carbon; +use DateTimeInterface; use Yii; use yii\behaviors\TimestampBehavior; use yii\db\ActiveQuery; @@ -41,7 +43,11 @@ class OauthSession extends ActiveRecord { } public function isRevoked(): bool { - return $this->revoked_at > $this->last_used_at; + return $this->isRevokedForTokenIssuedAt(Carbon::createFromTimestamp($this->last_used_at)); + } + + public function isRevokedForTokenIssuedAt(DateTimeInterface $issuedAt): bool { + return $this->revoked_at !== null && $this->revoked_at > $issuedAt->getTimestamp(); } public function getClient(): ActiveQuery { diff --git a/common/tests/fixtures/data/oauth-sessions.php b/common/tests/fixtures/data/oauth-sessions.php index 6cbbce0..2c6eef7 100644 --- a/common/tests/fixtures/data/oauth-sessions.php +++ b/common/tests/fixtures/data/oauth-sessions.php @@ -54,4 +54,13 @@ return [ 'revoked_at' => null, 'last_used_at' => 1519511568, ], + 'deleted-account-ely' => [ + 'account_id' => 15, + 'client_id' => 'ely', + 'legacy_id' => null, + 'scopes' => null, + 'created_at' => 1518334743, + 'revoked_at' => null, + 'last_used_at' => 1518334743, + ], ]; diff --git a/composer.json b/composer.json index b8267f6..3e7465b 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "guzzlehttp/guzzle": "^6|^7", "lcobucci/jwt": "^5.4", "league/oauth2-server": "dev-master#03dcdd7 as 9.2.0", + "league/uri-polyfill": "^7.9", "nesbot/carbon": "^3", "nohnaimer/yii2-sentry": "^2.0", "paragonie/constant_time_encoding": "^3", diff --git a/composer.lock b/composer.lock index 00e4594..c070aa6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3e64cde444aa504866e55aca9c75365a", + "content-hash": "935b738a331c0e10ef2086de3f2787b6", "packages": [ { "name": "altcha-org/altcha", @@ -176,16 +176,16 @@ }, { "name": "brick/math", - "version": "0.12.1", + "version": "0.12.3", "source": { "type": "git", "url": "https://github.com/brick/math.git", - "reference": "f510c0a40911935b77b86859eb5223d58d660df1" + "reference": "866551da34e9a618e64a819ee1e01c20d8a588ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/f510c0a40911935b77b86859eb5223d58d660df1", - "reference": "f510c0a40911935b77b86859eb5223d58d660df1", + "url": "https://api.github.com/repos/brick/math/zipball/866551da34e9a618e64a819ee1e01c20d8a588ba", + "reference": "866551da34e9a618e64a819ee1e01c20d8a588ba", "shasum": "" }, "require": { @@ -194,7 +194,7 @@ "require-dev": { "php-coveralls/php-coveralls": "^2.2", "phpunit/phpunit": "^10.1", - "vimeo/psalm": "5.16.0" + "vimeo/psalm": "6.8.8" }, "type": "library", "autoload": { @@ -224,7 +224,7 @@ ], "support": { "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.12.1" + "source": "https://github.com/brick/math/tree/0.12.3" }, "funding": [ { @@ -232,7 +232,7 @@ "type": "github" } ], - "time": "2023-11-29T23:19:16+00:00" + "time": "2025-02-28T13:11:00+00:00" }, { "name": "carbonphp/carbon-doctrine-types", @@ -1629,22 +1629,21 @@ }, { "name": "league/uri-interfaces", - "version": "7.4.1", + "version": "7.9.1", "source": { "type": "git", "url": "https://github.com/thephpleague/uri-interfaces.git", - "reference": "8d43ef5c841032c87e2de015972c06f3865ef718" + "reference": "994300a79e17f179112dc259f8df0c4de982f736" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/8d43ef5c841032c87e2de015972c06f3865ef718", - "reference": "8d43ef5c841032c87e2de015972c06f3865ef718", + "url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/994300a79e17f179112dc259f8df0c4de982f736", + "reference": "994300a79e17f179112dc259f8df0c4de982f736", "shasum": "" }, "require": { "ext-filter": "*", "php": "^8.1", - "psr/http-factory": "^1", "psr/http-message": "^1.1 || ^2.0" }, "suggest": { @@ -1652,6 +1651,7 @@ "ext-gmp": "to improve IPV4 host parsing", "ext-intl": "to handle IDN host with the best performance", "php-64bit": "to improve IPV4 host parsing", + "rowbot/url": "to handle URLs using the WHATWG URL Living Standard specification", "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present" }, "type": "library", @@ -1676,7 +1676,7 @@ "homepage": "https://nyamsprod.com" } ], - "description": "Common interfaces and classes for URI representation and interaction", + "description": "Common tools for parsing and resolving RFC3987/RFC3986 URI", "homepage": "https://uri.thephpleague.com", "keywords": [ "data-uri", @@ -1701,7 +1701,7 @@ "docs": "https://uri.thephpleague.com", "forum": "https://thephpleague.slack.com", "issues": "https://github.com/thephpleague/uri-src/issues", - "source": "https://github.com/thephpleague/uri-interfaces/tree/7.4.1" + "source": "https://github.com/thephpleague/uri-interfaces/tree/7.9.1" }, "funding": [ { @@ -1709,7 +1709,91 @@ "type": "github" } ], - "time": "2024-03-23T07:42:40+00:00" + "time": "2026-10-27T07:14:23+00:00" + }, + { + "name": "league/uri-polyfill", + "version": "7.9.1", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/uri-polyfill.git", + "reference": "18c5b081ea19a358648c7b9acefe8856ee539012" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/uri-polyfill/zipball/18c5b081ea19a358648c7b9acefe8856ee539012", + "reference": "18c5b081ea19a358648c7b9acefe8856ee539012", + "shasum": "" + }, + "require": { + "league/uri-interfaces": ">=7.9.1", + "php": ">=8.1", + "rowbot/url": "^4.1.0" + }, + "provide": { + "ext-uri": "*" + }, + "suggest": { + "ext-intl": "to handle IDN host with the best performance", + "jeremykendall/php-domain-parser": "to further parse the URI host and resolve its Public Suffix and Top Level Domain", + "league/uri-components": "to provide additional tools to manipulate URI objects components", + "php-64bit": "to improve IPV4 host parsing", + "symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present", + "symfony/polyfill-php82": "to use the SensitiveParameter polyfill in PHP8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.x-dev" + } + }, + "autoload": { + "files": [ + "lib/Rfc3986/functions.php", + "lib/WhatWg/functions.php" + ], + "psr-4": { + "League\\Uri\\": "" + }, + "classmap": [ + "lib" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignace Nyamagana Butera", + "email": "nyamsprod@gmail.com", + "homepage": "https://github.com/nyamsprod/", + "role": "Developer" + } + ], + "description": "Polyfill backporting PHP 8.5+ native RFC3986/WHATWG URI features to lower PHP versions", + "keywords": [ + "WHATWG", + "compatibiliy", + "equivalence", + "parser", + "polyfill", + "portable", + "resolver", + "rfc3986", + "uri", + "url" + ], + "support": { + "source": "https://github.com/thephpleague/uri-polyfill/tree/7.9.1" + }, + "funding": [ + { + "url": "https://github.com/nyamsprod", + "type": "github" + } + ], + "time": "2026-10-27T07:14:23+00:00" }, { "name": "nesbot/carbon", @@ -2902,6 +2986,185 @@ ], "time": "2024-04-27T21:32:50+00:00" }, + { + "name": "rowbot/idna", + "version": "0.3.0", + "source": { + "type": "git", + "url": "https://github.com/TRowbotham/idna.git", + "reference": "504900acc8e465a17668a61ae30391d1aebbb4f2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/TRowbotham/idna/zipball/504900acc8e465a17668a61ae30391d1aebbb4f2", + "reference": "504900acc8e465a17668a61ae30391d1aebbb4f2", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=8.1", + "rowbot/punycode": "^1.0", + "symfony/polyfill-intl-normalizer": "^1.18" + }, + "require-dev": { + "guzzlehttp/guzzle": "^6.5 || ^7.0", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^10.0 || ^11.0 || ^12.0", + "squizlabs/php_codesniffer": "^3.7.1", + "symfony/cache": "^5.0 || ^6.0 || ^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Rowbot\\Idna\\": "src/", + "Rowbot\\Idna\\Resource\\": "resources/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Trevor Rowbotham" + } + ], + "description": "An implementation of UTS#46 Unicode IDNA Compatibility Processing.", + "keywords": [ + "idn", + "idna", + "international domain names", + "iri", + "tr46", + "unicode", + "uts46" + ], + "support": { + "issues": "https://github.com/TRowbotham/idna/issues", + "source": "https://github.com/TRowbotham/idna/tree/0.3.0" + }, + "time": "2025-09-19T00:30:13+00:00" + }, + { + "name": "rowbot/punycode", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/TRowbotham/punycode.git", + "reference": "ec116e99cb089a25d45147813d61bfa2deb29328" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/TRowbotham/punycode/zipball/ec116e99cb089a25d45147813d61bfa2deb29328", + "reference": "ec116e99cb089a25d45147813d61bfa2deb29328", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "require-dev": { + "ext-mbstring": "*", + "phpstan/phpstan": "^1.2", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "squizlabs/php_codesniffer": "^3.5.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "Rowbot\\Punycode\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Trevor Rowbotham", + "homepage": "https://trowbotham.com", + "role": "Developer" + } + ], + "description": "A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA).", + "keywords": [ + "punycode", + "rfc-3492", + "rfc3492" + ], + "support": { + "issues": "https://github.com/TRowbotham/punycode/issues", + "source": "https://github.com/TRowbotham/punycode/tree/1.0.4" + }, + "time": "2024-05-03T00:56:10+00:00" + }, + { + "name": "rowbot/url", + "version": "4.2.1", + "source": { + "type": "git", + "url": "https://github.com/TRowbotham/URL-Parser.git", + "reference": "9b1bd1ac757672cb0682f697b53dc5aa03c76297" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/TRowbotham/URL-Parser/zipball/9b1bd1ac757672cb0682f697b53dc5aa03c76297", + "reference": "9b1bd1ac757672cb0682f697b53dc5aa03c76297", + "shasum": "" + }, + "require": { + "brick/math": "^0.12 || ^0.13 || ^0.14 || ^0.15 || ^0.16 || ^0.17 || ^0.18 || ^0.19 || ^0.20 || ^1.0", + "ext-mbstring": "*", + "php": ">=8.1", + "psr/log": "^2.0 || ^3.0", + "rowbot/idna": "^0.3.0" + }, + "require-dev": { + "guzzlehttp/guzzle": "^7.0", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^10.0 || ^11.0 || ^12.0", + "slevomat/coding-standard": "^8.0", + "squizlabs/php_codesniffer": "^3.7.1", + "symfony/cache": "^5.0 || ^6.0 || ^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Rowbot\\URL\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Trevor Rowbotham", + "homepage": "https://trowbotham.com", + "role": "Developer" + } + ], + "description": "A WHATWG URL spec compliant URL parser for working with URLs and their query strings.", + "keywords": [ + "WHATWG", + "query-string", + "querystring", + "uri", + "url", + "url-parser", + "url-parsing" + ], + "support": { + "issues": "https://github.com/TRowbotham/URL-Parser/issues", + "source": "https://github.com/TRowbotham/URL-Parser/tree/4.2.1" + }, + "time": "2026-10-03T01:15:39+00:00" + }, { "name": "sam-it/yii2-mariadb", "version": "v3.0.0", @@ -3855,16 +4118,16 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.31.0", + "version": "v1.43.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "3833d7255cc303546435cb650316bff708a1c75c" + "reference": "ebd57ccc7edb93d632e184efbe7693d2517bab3b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c", - "reference": "3833d7255cc303546435cb650316bff708a1c75c", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/ebd57ccc7edb93d632e184efbe7693d2517bab3b", + "reference": "ebd57ccc7edb93d632e184efbe7693d2517bab3b", "shasum": "" }, "require": { @@ -3876,8 +4139,8 @@ "type": "library", "extra": { "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" } }, "autoload": { @@ -3916,7 +4179,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.31.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.43.0" }, "funding": [ { @@ -3927,12 +4190,16 @@ "url": "https://github.com/fabpot", "type": "github" }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", "type": "tidelift" } ], - "time": "2024-09-09T11:45:10+00:00" + "time": "2026-09-23T22:02:09+00:00" }, { "name": "symfony/polyfill-mbstring",