Skip to content

Commit f2a832e

Browse files
authored
Merge branch 'thephpleague:master' into pass-user-id-to-finalize-scopes
2 parents b3c8d3c + 07920aa commit f2a832e

40 files changed

+897
-399
lines changed

.github/workflows/coding-standards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ jobs:
3131

3232
- name: Install Dependencies
3333
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
34-
34+
3535
- name: Run Codesniffer
3636
run: vendor/bin/phpcs

.github/workflows/static-analysis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
strategy:
1414
matrix:
15-
php-version: [8.1, 8.2, 8.3]
15+
php-version: [8.1, 8.2, 8.3, 8.4]
1616
composer-stability: [prefer-lowest, prefer-stable]
1717
operating-system:
1818
- ubuntu-latest
@@ -34,4 +34,4 @@ jobs:
3434

3535
- name: Run Static Analysis
3636
run: vendor/bin/phpstan analyse
37-
37+

.github/workflows/tests.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
php: [8.1, 8.2, 8.3]
15-
os: [ubuntu-22.04]
14+
php: [8.1, 8.2, 8.3, 8.4]
15+
os: [ubuntu-latest, windows-latest]
1616
stability: [prefer-lowest, prefer-stable]
1717

1818
runs-on: ${{ matrix.os }}
1919

20-
name: PHP ${{ matrix.php }} - ${{ matrix.stability }}
20+
name: PHP ${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
2121

2222
steps:
2323
- name: Checkout code
2424
uses: actions/checkout@v4
25-
with:
25+
with:
2626
fetch-depth: 0
2727

2828
- name: Setup PHP
2929
uses: shivammathur/setup-php@v2
3030
with:
3131
php-version: ${{ matrix.php }}
32-
extensions: dom, curl, libxml, mbstring, zip
32+
extensions: dom, curl, libxml, mbstring, sodium, zip
3333
coverage: pcov
3434

3535
- name: Install dependencies

CHANGELOG.md

+41-10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,35 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
### Added
9+
- Added a new function to the provided ClientTrait, `supportsGrantType` to allow the auth server to issue the response `unauthorized_client` when applicable (PR #1420)
10+
11+
### Fixed
12+
- Clients only validated for Refresh, Device Code, and Password grants if the client is confidential (PR #1420)
13+
14+
### Changed
15+
- Key permission checks ignored on Windows regardless of userland choice as cannot be run successfully on this OS (PR #1447)
16+
17+
## [9.1.0] - released 2024-11-21
18+
### Added
19+
- Support for PHP 8.4 (PR #1454)
20+
21+
### Fixed
22+
- In the Auth Code grant, when requesting an access token with an invalid auth code, we now respond with an invalid_grant error instead of invalid_request (PR #1433)
23+
- Fixed spec compliance issue where device access token request was mistakenly expecting to receive scopes in the request (PR #1412)
24+
- Refresh tokens pre version 9 might have had user IDs set as ints which meant they were incorrectly rejected. We now cast these values to strings to allow old refresh tokens (PR #1436)
25+
- Fixed bug on setting interval visibility of device authorization grant (PR #1410)
26+
- Fix a bug where the new poll date were not persisted when `slow_down` error happens, because the exception is thrown before calling `persistDeviceCode`. (PR #1410)
27+
- Fix a bug where `slow_down` error response may have been returned even after the user has completed the auth flow (already approved / denied the request). (PR #1410)
28+
29+
## [9.0.1] - released 2024-10-14
30+
### Fixed
31+
- Auto-generated event emitter is now persisted. Previously, a new emitter was generated every time (PR #1428)
32+
- Fixed bug where you could not omit a redirect uri even if one had not been specified during the auth request (PR #1428)
33+
- Fixed bug where "state" parameter wasn't present on `invalid_scope` error response and wasn't on fragment part of `access_denied` redirect URI on Implicit grant (PR #1298)
34+
- Fixed bug where disabling refresh token revocation via `revokeRefreshTokens(false)` unintentionally disables issuing new refresh token (PR #1449)
35+
736
## [9.0.0] - released 2024-05-13
837
### Added
938
- Device Authorization Grant added (PR #1074)
@@ -53,13 +82,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5382

5483
## [8.5.3] - released 2023-07-06
5584
### Security
56-
- If a key string is provided to the CryptKey constructor with an invalid
57-
passphrase, the LogicException message generated will expose the given key.
85+
- If a key string is provided to the CryptKey constructor with an invalid
86+
passphrase, the LogicException message generated will expose the given key.
5887
The key is no longer leaked via this exception (PR #1353)
5988

6089
## [8.5.2] - released 2023-06-16
6190
### Changed
62-
- Bumped the versions for laminas/diactoros and psr/http-message to support
91+
- Bumped the versions for laminas/diactoros and psr/http-message to support
6392
PSR-7 v2.0 (PR #1339)
6493

6594
## [8.5.1] - released 2023-04-04
@@ -151,13 +180,13 @@ a PKCE downgrade attack (PR #1326)
151180
- Removed support for PHP 7.2 (PR #1146)
152181

153182
### Fixed
154-
- Fix typo in parameter hint. `code_challenged` changed to `code_challenge`. Thrown by Auth Code Grant when the code challenge does not match the regex. (PR #1130)
183+
- Fix typo in parameter hint. `code_challenged` changed to `code_challenge`. Thrown by Auth Code Grant when the code challenge does not match the regex. (PR #1130)
155184
- Undefined offset was returned when no client redirect URI was set. Now throw an invalidClient exception if no redirect URI is set against a client (PR #1140)
156185

157186
## [8.1.1] - released 2020-07-01
158187

159188
### Fixed
160-
- If you provide a valid redirect_uri with the auth code grant and an invalid scope, the server will use the given
189+
- If you provide a valid redirect_uri with the auth code grant and an invalid scope, the server will use the given
161190
redirect_uri instead of the default client redirect uri (PR #1126)
162191

163192
## [8.1.0] - released 2020-04-29
@@ -177,9 +206,9 @@ redirect_uri instead of the default client redirect uri (PR #1126)
177206
### Fixed
178207
- Clients are now explicitly prevented from using the Client Credentials grant unless they are confidential to conform
179208
with the OAuth2 spec (PR #1035)
180-
- Abstract method `getIdentifier()` added to AccessTokenTrait. The trait cannot be used without the `getIdentifier()`
209+
- Abstract method `getIdentifier()` added to AccessTokenTrait. The trait cannot be used without the `getIdentifier()`
181210
method being defined (PR #1051)
182-
- An exception is now thrown if a refresh token is accidentally sent in place of an authorization code when using the
211+
- An exception is now thrown if a refresh token is accidentally sent in place of an authorization code when using the
183212
Auth Code Grant (PR #1057)
184213
- Can now send access token request without being forced to specify a redirect URI (PR #1096)
185214
- In the BearerTokenValidator, if an implementation is using PDO, there is a possibility that a RuntimeException will be thrown when checking if an access token is revoked. This scenario no longer incorrectly issues an exception with a hint mentioning an issue with JSON decoding. (PR #1107)
@@ -233,7 +262,7 @@ Auth Code Grant (PR #1057)
233262
## [7.3.0] - released 2018-11-13
234263

235264
### Changed
236-
- Moved the `finalizeScopes()` call from `validateAuthorizationRequest` method to the `completeAuthorizationRequest` method so it is called just before the access token is issued (PR #923)
265+
- Moved the `finalizeScopes()` call from `validateAuthorizationRequest` method to the `completeAuthorizationRequest` method so it is called just before the access token is issued (PR #923)
237266

238267
### Added
239268
- Added a ScopeTrait to provide an implementation for jsonSerialize (PR #952)
@@ -335,7 +364,7 @@ To address feedback from the security release the following change has been made
335364
## [5.1.4] - 2017-07-01
336365

337366
- Fixed multiple security vulnerabilities as a result of a security audit paid for by the [Mozilla Secure Open Source Fund](https://wiki.mozilla.org/MOSS/Secure_Open_Source). All users of this library are encouraged to update as soon as possible to this version or version 6.0 or greater.
338-
- It is recommended on each `AuthorizationServer` instance you set the `setEncryptionKey()`. This will result in stronger encryption being used. If this method is not set messages will be sent to the defined error handling routines (using `error_log`). Please see the examples and documentation for examples.
367+
- It is recommended on each `AuthorizationServer` instance you set the `setEncryptionKey()`. This will result in stronger encryption being used. If this method is not set messages will be sent to the defined error handling routines (using `error_log`). Please see the examples and documentation for examples.
339368
- TravisCI now tests PHP 7.1 (Issue #671)
340369
- Fix middleware example fatal error (Issue #682)
341370
- Fix typo in the first README sentence (Issue #690)
@@ -646,7 +675,9 @@ Version 5 is a complete code rewrite.
646675

647676
- First major release
648677

649-
[Unreleased]: https://github.com/thephpleague/oauth2-server/compare/9.0.0...HEAD
678+
[Unreleased]: https://github.com/thephpleague/oauth2-server/compare/9.1.0...HEAD
679+
[9.1.0]: https://github.com/thephpleague/oauth2-server/compare/9.0.1...9.1.0
680+
[9.0.1]: https://github.com/thephpleague/oauth2-server/compare/9.0.0...9.0.1
650681
[9.0.0]: https://github.com/thephpleague/oauth2-server/compare/9.0.0-RC1...9.0.0
651682
[9.0.0-RC1]: https://github.com/thephpleague/oauth2-server/compare/8.5.4...9.0.0-RC1
652683
[8.5.4]: https://github.com/thephpleague/oauth2-server/compare/8.5.3...8.5.4

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Out of the box it supports the following grants:
2121
The following RFCs are implemented:
2222

2323
* [RFC6749 "OAuth 2.0"](https://tools.ietf.org/html/rfc6749)
24-
* [RFC6750 " The OAuth 2.0 Authorization Framework: Bearer Token Usage"](https://tools.ietf.org/html/rfc6750)
24+
* [RFC6750 "The OAuth 2.0 Authorization Framework: Bearer Token Usage"](https://tools.ietf.org/html/rfc6750)
2525
* [RFC7519 "JSON Web Token (JWT)"](https://tools.ietf.org/html/rfc7519)
2626
* [RFC7636 "Proof Key for Code Exchange by OAuth Public Clients"](https://tools.ietf.org/html/rfc7636)
2727
* [RFC8628 "OAuth 2.0 Device Authorization Grant](https://tools.ietf.org/html/rfc8628)
@@ -35,6 +35,7 @@ The latest version of this package supports the following versions of PHP:
3535
* PHP 8.1
3636
* PHP 8.2
3737
* PHP 8.3
38+
* PHP 8.4
3839

3940
The `openssl` and `json` extensions are also required.
4041

composer.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"homepage": "https://oauth2.thephpleague.com/",
55
"license": "MIT",
66
"require": {
7-
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
7+
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
88
"ext-openssl": "*",
99
"league/event": "^3.0",
1010
"league/uri": "^7.0",
@@ -16,9 +16,9 @@
1616
"psr/http-server-middleware": "^1.0"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^9.6.15",
20-
"laminas/laminas-diactoros": "^3.3.0",
21-
"phpstan/phpstan": "^1.10.55",
19+
"phpunit/phpunit": "^9.6.21",
20+
"laminas/laminas-diactoros": "^3.5",
21+
"phpstan/phpstan": "^1.12",
2222
"phpstan/phpstan-phpunit": "^1.3.15",
2323
"roave/security-advisories": "dev-master",
2424
"phpstan/extension-installer": "^1.3.1",

examples/README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
# Example implementations
1+
# Example implementations (via [`Slim 3`](https://github.com/slimphp/Slim/tree/3.x))
22

33
## Installation
44

55
0. Run `composer install` in this directory to install dependencies
66
0. Create a private key `openssl genrsa -out private.key 2048`
7-
0. Create a public key `openssl rsa -in private.key -pubout > public.key`
8-
0. `cd` into the public directory
9-
0. Start a PHP server `php -S localhost:4444`
7+
0. Export the public key `openssl rsa -in private.key -pubout > public.key`
8+
0. Start local PHP server `php -S 127.0.0.1:4444 -t public/`
109

1110
## Testing the client credentials grant example
1211

@@ -63,12 +62,12 @@ curl -X "POST" "http://localhost:4444/device_code.php/device_authorization" \
6362
--data-urlencode "client_id=myawesomeapp" \
6463
--data-urlencode "client_secret=abc123" \
6564
--data-urlencode "scope=basic email"
66-
```
65+
```
6766

6867
We have set up the example so that a user ID is already associated with the device code. In a production application you
6968
would implement an authorization view to allow a user to authorize the device.
7069

71-
Issue the following cURL request to exchange your device code for an access token. Replace `{{DEVICE_CODE}}` with the
70+
Issue the following cURL request to exchange your device code for an access token. Replace `{{DEVICE_CODE}}` with the
7271
device code returned from your first cURL post:
7372

7473
```
@@ -79,4 +78,4 @@ curl -X "POST" "http://localhost:4444/device_code.php/access_token" \
7978
--data-urlencode "device_code={{DEVICE_CODE}}" \
8079
--data-urlencode "client_id=myawesomeapp" \
8180
--data-urlencode "client_secret=abc123"
82-
```
81+
```

examples/public/auth_code.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
declare(strict_types=1);
1212

13+
include __DIR__ . '/../vendor/autoload.php';
14+
1315
use Laminas\Diactoros\Stream;
1416
use League\OAuth2\Server\AuthorizationServer;
1517
use League\OAuth2\Server\Exception\OAuthServerException;
@@ -24,10 +26,8 @@
2426
use Psr\Http\Message\ServerRequestInterface;
2527
use Slim\App;
2628

27-
include __DIR__ . '/../vendor/autoload.php';
28-
2929
$app = new App([
30-
'settings' => [
30+
'settings' => [
3131
'displayErrorDetails' => true,
3232
],
3333
AuthorizationServer::class => function () {

examples/public/client_credentials.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
use Slim\App;
2525

2626
$app = new App([
27-
'settings' => [
27+
'settings' => [
2828
'displayErrorDetails' => true,
2929
],
3030
AuthorizationServer::class => function () {

examples/public/device_code.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
include __DIR__ . '/../vendor/autoload.php';
1414

15+
use Laminas\Diactoros\Stream;
1516
use League\OAuth2\Server\AuthorizationServer;
1617
use League\OAuth2\Server\Exception\OAuthServerException;
1718
use League\OAuth2\Server\Grant\DeviceCodeGrant;
@@ -23,7 +24,6 @@
2324
use Psr\Http\Message\ResponseInterface;
2425
use Psr\Http\Message\ServerRequestInterface;
2526
use Slim\App;
26-
use Zend\Diactoros\Stream;
2727

2828
$app = new App([
2929
'settings' => [

examples/public/implicit.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
declare(strict_types=1);
1212

13+
include __DIR__ . '/../vendor/autoload.php';
14+
1315
use Laminas\Diactoros\Stream;
1416
use League\OAuth2\Server\AuthorizationServer;
1517
use League\OAuth2\Server\Exception\OAuthServerException;
@@ -22,10 +24,8 @@
2224
use Psr\Http\Message\ServerRequestInterface;
2325
use Slim\App;
2426

25-
include __DIR__ . '/../vendor/autoload.php';
26-
2727
$app = new App([
28-
'settings' => [
28+
'settings' => [
2929
'displayErrorDetails' => true,
3030
],
3131
AuthorizationServer::class => function () {

examples/public/middleware_use.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
use Slim\App;
3030

3131
$app = new App([
32-
'settings' => [
32+
'settings' => [
3333
'displayErrorDetails' => true,
3434
],
3535
AuthorizationServer::class => function () {

examples/public/password.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
declare(strict_types=1);
44

5+
include __DIR__ . '/../vendor/autoload.php';
6+
57
use League\OAuth2\Server\AuthorizationServer;
68
use League\OAuth2\Server\Exception\OAuthServerException;
79
use League\OAuth2\Server\Grant\PasswordGrant;
@@ -14,8 +16,6 @@
1416
use Psr\Http\Message\ServerRequestInterface;
1517
use Slim\App;
1618

17-
include __DIR__ . '/../vendor/autoload.php';
18-
1919
$app = new App([
2020
// Add the authorization server to the DI container
2121
AuthorizationServer::class => function () {

examples/public/refresh_token.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
declare(strict_types=1);
1212

13+
include __DIR__ . '/../vendor/autoload.php';
14+
1315
use League\OAuth2\Server\AuthorizationServer;
1416
use League\OAuth2\Server\Exception\OAuthServerException;
1517
use League\OAuth2\Server\Grant\RefreshTokenGrant;
@@ -21,10 +23,8 @@
2123
use Psr\Http\Message\ServerRequestInterface;
2224
use Slim\App;
2325

24-
include __DIR__ . '/../vendor/autoload.php';
25-
2626
$app = new App([
27-
'settings' => [
27+
'settings' => [
2828
'displayErrorDetails' => true,
2929
],
3030
AuthorizationServer::class => function () {

examples/src/Repositories/AuthCodeRepository.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,31 @@ class AuthCodeRepository implements AuthCodeRepositoryInterface
2121
/**
2222
* {@inheritdoc}
2323
*/
24-
public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity)
24+
public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity): void
2525
{
2626
// Some logic to persist the auth code to a database
2727
}
2828

2929
/**
3030
* {@inheritdoc}
3131
*/
32-
public function revokeAuthCode($codeId)
32+
public function revokeAuthCode($codeId): void
3333
{
3434
// Some logic to revoke the auth code in a database
3535
}
3636

3737
/**
3838
* {@inheritdoc}
3939
*/
40-
public function isAuthCodeRevoked($codeId)
40+
public function isAuthCodeRevoked($codeId): bool
4141
{
4242
return false; // The auth code has not been revoked
4343
}
4444

4545
/**
4646
* {@inheritdoc}
4747
*/
48-
public function getNewAuthCode()
48+
public function getNewAuthCode(): AuthCodeEntityInterface
4949
{
5050
return new AuthCodeEntity();
5151
}

0 commit comments

Comments
 (0)