Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device Authorization Grant #1074

Merged
merged 59 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
48101dd
Device Code grant
lucadegasperi Nov 25, 2019
2d3a176
removed unused method on the interface
lucadegasperi Nov 26, 2019
fb6cfd4
fixing the response
lucadegasperi Nov 26, 2019
080c37d
added verification uri
lucadegasperi Nov 26, 2019
2545475
Fix Authorship
lucadegasperi Nov 28, 2019
b5da0d2
Stycle CI fixes
lucadegasperi Nov 28, 2019
f4a8e79
phpstan fixes
lucadegasperi Nov 28, 2019
a0749a5
more phpstan fixes
lucadegasperi Nov 28, 2019
699ddae
fix
lucadegasperi Nov 28, 2019
f44acde
last fix
lucadegasperi Nov 28, 2019
5fee7e4
Update examples to include device code grant
Sephster Dec 19, 2019
925944f
Fix grant identifier in test
Sephster Dec 19, 2019
3d87496
Add device code RFC to readme
Sephster Dec 19, 2019
4270a57
Move device code specific code to grant
Sephster Dec 19, 2019
4819946
Move generateUniqueUserCode to Device Code Grant
Sephster Dec 19, 2019
a1246f2
Change user code to be alpha based
Sephster Dec 19, 2019
854849c
Add missing use statements
Sephster Dec 19, 2019
3ad3c1d
Make error message specific to device grant
Sephster Dec 19, 2019
dfde596
Fix phpstan errors
Sephster Dec 21, 2019
d3f0a79
Fix styling issues
Sephster Dec 21, 2019
71693f3
Add slow down response
Sephster Dec 23, 2019
a2ddfdc
Add device grant middleware to slow requests
Sephster Apr 19, 2020
eba69bb
StyleCI fixes
Sephster Apr 19, 2020
7621652
StyleCI fixes
Sephster Apr 19, 2020
1c1e2cf
Update composer dependencies
Sephster Apr 19, 2020
9cb2dfe
trying to fix styleCI issue
Sephster Apr 19, 2020
df1ed20
Fix brackets formatting
Sephster Apr 19, 2020
b10cec4
Fix bug
Sephster Apr 19, 2020
8ac43b6
Fix bugs
Sephster Apr 19, 2020
effa69a
Update to latest version of server
Sephster Jul 27, 2023
5e9444d
Update flow and tests
Sephster Aug 28, 2023
ab39ef6
Tidy up tests and add error handling
Sephster Sep 5, 2023
2575a3e
Update comment
Sephster Sep 25, 2023
c3f91e8
Merge in v9-wip
Sephster Oct 29, 2023
b35b931
Fix merge errors
Sephster Nov 1, 2023
99835a6
Fix tests and styling
Sephster Nov 1, 2023
0ad7cc3
Merge v9-wip upstream branch
Sephster Jan 10, 2024
29122db
Fix composer file
Sephster Jan 10, 2024
b6e28fa
actually fix composer file
Sephster Jan 10, 2024
4aaf7aa
Fix docblock comment merge error
Sephster Jan 10, 2024
93157f4
Fix typing error
Sephster Jan 10, 2024
76cb886
Fix PHPStan errors
Sephster Jan 17, 2024
15c214d
Fix all PHPStan errors
Sephster Jan 25, 2024
4e9de6e
Support complete_verification_uri
Sephster Jan 31, 2024
0636d25
add ability to set interval
Sephster Mar 5, 2024
f8f15ef
Simplify device code response - remove payload
Sephster Mar 21, 2024
0bc83e5
Remove uuid lib
Sephster Mar 21, 2024
67284de
Fix device code examples
Sephster Mar 21, 2024
e8b5669
Remove unnecessary repository functions
Sephster Mar 21, 2024
4345dae
remove unusued import
Sephster Mar 21, 2024
2cf9fbb
Add new methods to GrantTypeInterface
Sephster Mar 21, 2024
e080cbf
Fix a test exception
Sephster Mar 21, 2024
b4fdc31
Update changelog
Sephster Mar 21, 2024
6250531
Update changelog
Sephster Mar 21, 2024
616240f
Update PHP version support
Sephster Mar 21, 2024
dde13a4
Revert docblock deletions
Sephster Mar 21, 2024
d00fbfc
Update author
Sephster Mar 21, 2024
3449fa8
Update author
Sephster Mar 21, 2024
571843d
revert erroneous edit
Sephster Mar 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]
### Added
- Device Authorization Grant added (PR #1074)
- GrantTypeInterface has a new function, `revokeRefreshTokens()` for enabling or disabling refresh tokens after use (PR #1375)
- A CryptKeyInterface to allow developers to change the CryptKey implementation with greater ease (PR #1044)
- The authorization server can now finalize scopes when a client uses a refresh token (PR #1094)
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,29 @@
Out of the box it supports the following grants:

* Authorization code grant
* Implicit grant
* Client credentials grant
* Resource owner password credentials grant
* Device authorization grant
* Implicit grant
* Refresh grant
* Resource owner password credentials grant

The following RFCs are implemented:

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

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

## Requirements

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

* PHP 8.0
* PHP 8.1
* PHP 8.2
* PHP 8.3

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

Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"lcobucci/jwt": "^5.0",
"psr/http-message": "^2.0",
"defuse/php-encryption": "^2.4",
"lcobucci/clock": "^2.3 || ^3.0"
"ext-json": "*",
"lcobucci/clock": "^2.3 || ^3.0",
"psr/http-server-middleware": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6.15",
Expand Down
29 changes: 29 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,32 @@ curl -X "POST" "http://localhost:4444/refresh_token.php/access_token" \
--data-urlencode "client_secret=abc123" \
--data-urlencode "refresh_token={{REFRESH_TOKEN}}"
```

## Testing the device authorization grant example

Send the following cURL request. This will return a device code which can be exchanged for an access token.

```
curl -X "POST" "http://localhost:4444/device_code.php/device_authorization" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: 1.0" \
--data-urlencode "client_id=myawesomeapp" \
--data-urlencode "client_secret=abc123" \
--data-urlencode "scope=basic email"
```

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

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

```
curl -X "POST" "http://localhost:4444/device_code.php/access_token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: 1.0" \
--data-urlencode "grant_type=urn:ietf:params:oauth:grant-type:device_code" \
--data-urlencode "device_code={{DEVICE_CODE}}" \
--data-urlencode "client_id=myawesomeapp" \
--data-urlencode "client_secret=abc123"
```
2 changes: 1 addition & 1 deletion examples/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"slim/slim": "^3.12.3"
},
"require-dev": {
"league/event": "^2.2",
"league/event": "^3.0",
"lcobucci/jwt": "^3.4.6 || ^4.0.4",
"psr/http-message": "^1.0.1",
"defuse/php-encryption": "^2.2.1",
Expand Down
Loading
Loading