Skip to content

Commit 0ed27b1

Browse files
authored
Merge pull request #1395 from thephpleague/9.0.0-WIP
Version 9 RC1
2 parents 0576f39 + b4ca1d9 commit 0ed27b1

File tree

115 files changed

+4761
-2729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+4761
-2729
lines changed
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Coding Standards
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
coding-standards:
9+
name: Coding Standards
10+
11+
runs-on: ${{ matrix.operating-system }}
12+
13+
strategy:
14+
matrix:
15+
php-version:
16+
- 8.3
17+
operating-system:
18+
- ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Install PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
coverage: none
28+
php-version: ${{ matrix.php-version }}
29+
ini-values: memory_limit=-1
30+
tools: composer:v2, cs2pr
31+
32+
- name: Install Dependencies
33+
run: composer update --prefer-stable --prefer-dist --no-interaction --no-progress
34+
35+
- name: Run Codesniffer
36+
run: vendor/bin/phpcs

.github/workflows/static-analysis.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Static Analysis
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
static-analysis:
9+
name: Static Analysis
10+
11+
runs-on: ${{ matrix.operating-system }}
12+
13+
strategy:
14+
matrix:
15+
php-version: [8.1, 8.2, 8.3]
16+
composer-stability: [prefer-lowest, prefer-stable]
17+
operating-system:
18+
- ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Install PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
coverage: none
28+
php-version: ${{ matrix.php-version }}
29+
ini-values: memory_limit=-1
30+
tools: composer:v2, cs2pr
31+
32+
- name: Install Dependencies
33+
run: composer update --${{ matrix.composer-stability }} --prefer-dist --no-interaction --no-progress
34+
35+
- name: Run Static Analysis
36+
run: vendor/bin/phpstan analyse
37+

.github/workflows/tests.yml

+1-8
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ jobs:
1414
php: [8.1, 8.2, 8.3]
1515
os: [ubuntu-22.04]
1616
stability: [prefer-lowest, prefer-stable]
17-
include:
18-
- os: ubuntu-20.04
19-
php: 8.0
20-
stability: prefer-lowest
21-
- os: ubuntu-20.04
22-
php: 8.0
23-
stability: prefer-stable
2417

2518
runs-on: ${{ matrix.os }}
2619

@@ -48,7 +41,7 @@ jobs:
4841
composer global require scrutinizer/ocular
4942

5043
- name: Execute tests
51-
run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover
44+
run: vendor/bin/phpunit --coverage-clover=coverage.clover
5245

5346
- name: Code coverage
5447
if: ${{ github.ref == 'refs/heads/master' && github.repository == 'thephpleague/oauth2-server' }}

CHANGELOG.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ 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

77
## [Unreleased]
8+
### Added
9+
- Device Authorization Grant added (PR #1074)
10+
- GrantTypeInterface has a new function, `revokeRefreshTokens()` for enabling or disabling refresh tokens after use (PR #1375)
11+
- A CryptKeyInterface to allow developers to change the CryptKey implementation with greater ease (PR #1044)
12+
- The authorization server can now finalize scopes when a client uses a refresh token (PR #1094)
13+
- An AuthorizationRequestInterface to make it easier to extend the AuthorizationRequest (PR #1110)
14+
- Added function `getKeyContents()` to the `CryptKeyInterface` (PR #1375)
15+
16+
### Fixed
17+
- If a refresh token has expired, been revoked, cannot be decrypted, or does not belong to the correct client, the server will now issue an `invalid_grant` error and a HTTP 400 response. In previous versions the server incorrectly issued an `invalid_request` and HTTP 401 response (PR #1042) (PR #1082)
18+
19+
### Changed
20+
- Authorization Request objects are now created through the factory method, `createAuthorizationRequest()` (PR #1111)
21+
- Changed parameters for `finalizeScopes()` to allow a reference to an auth code ID (PR #1112)
22+
- AccessTokenEntityInterface now requires the implementation of `toString()` instead of the magic method `__toString()` (PR #XXXX)
23+
24+
### Removed
25+
- Removed message property from OAuthException HTTP response. Now just use error_description as per the OAuth 2 spec (PR #1375)
826

927
## [8.5.4] - released 2023-08-25
1028
### Added
@@ -119,7 +137,6 @@ a PKCE downgrade attack (PR #1326)
119137
- If you provide a valid redirect_uri with the auth code grant and an invalid scope, the server will use the given
120138
redirect_uri instead of the default client redirect uri (PR #1126)
121139

122-
123140
## [8.1.0] - released 2020-04-29
124141

125142
### Added

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,29 @@
1212
Out of the box it supports the following grants:
1313

1414
* Authorization code grant
15-
* Implicit grant
1615
* Client credentials grant
17-
* Resource owner password credentials grant
16+
* Device authorization grant
17+
* Implicit grant
1818
* Refresh grant
19+
* Resource owner password credentials grant
1920

2021
The following RFCs are implemented:
2122

2223
* [RFC6749 "OAuth 2.0"](https://tools.ietf.org/html/rfc6749)
2324
* [RFC6750 " The OAuth 2.0 Authorization Framework: Bearer Token Usage"](https://tools.ietf.org/html/rfc6750)
2425
* [RFC7519 "JSON Web Token (JWT)"](https://tools.ietf.org/html/rfc7519)
2526
* [RFC7636 "Proof Key for Code Exchange by OAuth Public Clients"](https://tools.ietf.org/html/rfc7636)
27+
* [RFC8628 "OAuth 2.0 Device Authorization Grant](https://tools.ietf.org/html/rfc8628)
2628

2729
This library was created by Alex Bilbie. Find him on Twitter at [@alexbilbie](https://twitter.com/alexbilbie).
2830

2931
## Requirements
3032

3133
The latest version of this package supports the following versions of PHP:
3234

33-
* PHP 8.0
3435
* PHP 8.1
3536
* PHP 8.2
37+
* PHP 8.3
3638

3739
The `openssl` and `json` extensions are also required.
3840

composer.json

+27-12
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,29 @@
44
"homepage": "https://oauth2.thephpleague.com/",
55
"license": "MIT",
66
"require": {
7-
"php": "^8.0",
7+
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
88
"ext-openssl": "*",
9-
"league/event": "^2.2",
10-
"league/uri": "^6.7 || ^7.0",
11-
"lcobucci/jwt": "^4.3 || ^5.0",
12-
"psr/http-message": "^1.0.1 || ^2.0",
13-
"defuse/php-encryption": "^2.3",
14-
"lcobucci/clock": "^2.2 || ^3.0"
9+
"league/event": "^3.0",
10+
"league/uri": "^7.0",
11+
"lcobucci/jwt": "^5.0",
12+
"psr/http-message": "^2.0",
13+
"defuse/php-encryption": "^2.4",
14+
"ext-json": "*",
15+
"lcobucci/clock": "^2.3 || ^3.0",
16+
"psr/http-server-middleware": "^1.0"
1517
},
1618
"require-dev": {
17-
"phpunit/phpunit": "^9.6.6",
18-
"laminas/laminas-diactoros": "^3.0.0",
19-
"phpstan/phpstan": "^0.12.57",
20-
"phpstan/phpstan-phpunit": "^0.12.16",
21-
"roave/security-advisories": "dev-master"
19+
"phpunit/phpunit": "^9.6.15",
20+
"laminas/laminas-diactoros": "^3.3.0",
21+
"phpstan/phpstan": "^1.10.55",
22+
"phpstan/phpstan-phpunit": "^1.3.15",
23+
"roave/security-advisories": "dev-master",
24+
"phpstan/extension-installer": "^1.3.1",
25+
"phpstan/phpstan-deprecation-rules": "^1.1.4",
26+
"phpstan/phpstan-strict-rules": "^1.5.2",
27+
"slevomat/coding-standard": "^8.14.1",
28+
"php-parallel-lint/php-parallel-lint": "^1.3.2",
29+
"squizlabs/php_codesniffer": "^3.8"
2230
},
2331
"repositories": [
2432
{
@@ -69,5 +77,12 @@
6977
"psr-4": {
7078
"LeagueTests\\": "tests/"
7179
}
80+
},
81+
"config": {
82+
"allow-plugins": {
83+
"ocramius/package-versions": true,
84+
"phpstan/extension-installer": true,
85+
"dealerdirect/phpcodesniffer-composer-installer": false
86+
}
7287
}
7388
}

examples/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,32 @@ curl -X "POST" "http://localhost:4444/refresh_token.php/access_token" \
5151
--data-urlencode "client_secret=abc123" \
5252
--data-urlencode "refresh_token={{REFRESH_TOKEN}}"
5353
```
54+
55+
## Testing the device authorization grant example
56+
57+
Send the following cURL request. This will return a device code which can be exchanged for an access token.
58+
59+
```
60+
curl -X "POST" "http://localhost:4444/device_code.php/device_authorization" \
61+
-H "Content-Type: application/x-www-form-urlencoded" \
62+
-H "Accept: 1.0" \
63+
--data-urlencode "client_id=myawesomeapp" \
64+
--data-urlencode "client_secret=abc123" \
65+
--data-urlencode "scope=basic email"
66+
```
67+
68+
We have set up the example so that a user ID is already associated with the device code. In a production application you
69+
would implement an authorization view to allow a user to authorize the device.
70+
71+
Issue the following cURL request to exchange your device code for an access token. Replace `{{DEVICE_CODE}}` with the
72+
device code returned from your first cURL post:
73+
74+
```
75+
curl -X "POST" "http://localhost:4444/device_code.php/access_token" \
76+
-H "Content-Type: application/x-www-form-urlencoded" \
77+
-H "Accept: 1.0" \
78+
--data-urlencode "grant_type=urn:ietf:params:oauth:grant-type:device_code" \
79+
--data-urlencode "device_code={{DEVICE_CODE}}" \
80+
--data-urlencode "client_id=myawesomeapp" \
81+
--data-urlencode "client_secret=abc123"
82+
```

examples/composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"slim/slim": "^3.12.3"
44
},
55
"require-dev": {
6-
"league/event": "^2.2",
6+
"league/event": "^3.0",
77
"lcobucci/jwt": "^3.4.6 || ^4.0.4",
88
"psr/http-message": "^1.0.1",
99
"defuse/php-encryption": "^2.2.1",

0 commit comments

Comments
 (0)