Skip to content

Implement RFC9101 JWT secured authentication requests (JAR)#749

Merged
azmeuk merged 6 commits intoauthlib:mainfrom
azmeuk:724-jar
May 18, 2025
Merged

Implement RFC9101 JWT secured authentication requests (JAR)#749
azmeuk merged 6 commits intoauthlib:mainfrom
azmeuk:724-jar

Conversation

@azmeuk
Copy link
Member

@azmeuk azmeuk commented Apr 18, 2025

This pull request brings a few refactoring and the implementation for RFC 9101
The OAuth 2.0 Authorization Framework: JWT-Secured Authorization Request (JAR)
.

To summarize, RFC9101 is about passing the authorization request payload in a JWT, called request object, instead of passing it in the request body or query string. The request object is passed in a request parameter or hosted at the client and the URI to the request object is passed in a request_uri parameter.

To achieve this I had to perform some refactoring, and deprecate some usage with planned removal for Authlib 1.7 (so we can release 1.6 including this PR).

  • The hook mechanism has been reworked, and the execute_hook method is replaced by a hooked decorator. This helps catching a method result every time when several return calls are in the method. There is no deprecation for hooks as I considered it is Authlib private API.
  • A AuthorizationServer extension mechanism is introduced, and the RFC9207 IssueParameter is now an authorization server extension instead of a grant extension. Using IssueParameter as a grant extension is tolerated until 1.7.
  • The create_authorization_response takes a grant parameter. This is to avoid calling get_consent_grant twice, which can be costly when a network request is performed to reach the request_uri endpoint. The parameter is optional at the moment but will become mandatory with 1.7.
  • The OAuth2Request has been split in another OAuth2Payload class. This help separate the request object and the request payload, so the rfc9101 extension can overwrite the request payload with the request object content. Properties like request.data are deprecated in favor of request.payload.data and will be removed in 1.7.

Fixes #723

@lepture
Copy link
Member

lepture commented Apr 21, 2025

There are many conflicts.

@azmeuk
Copy link
Member Author

azmeuk commented Apr 21, 2025

They are fixed!

@azmeuk azmeuk force-pushed the 724-jar branch 5 times, most recently from 9b6da3d to b74876f Compare April 28, 2025 12:02
@azmeuk azmeuk requested a review from lepture April 28, 2025 13:43
@lepture
Copy link
Member

lepture commented May 15, 2025

Since this PR will be included in 1.6, deprecating those request properties in 1.7 is too early, how about change it to 1.8?

@azmeuk
Copy link
Member Author

azmeuk commented May 15, 2025

Ok I will update the deprecations then.

azmeuk added 6 commits May 15, 2025 20:23
This would avoid calling 'get_authorization_grant' a second time (after
it being called a first time in 'get_consent_grant').
This would help avoid making the same network request twice when
RFC9101 'request_uri' parameter is used.
- Introduce a 'Hookable' class and a 'hooked' parameter.
- RFC9207 'iss' is an 'AuthorizationServer' extension instead of a
  'Grant' extension.
@azmeuk
Copy link
Member Author

azmeuk commented May 15, 2025

@lepture this is fixed

@azmeuk azmeuk merged commit d429c36 into authlib:main May 18, 2025
7 checks passed
@azmeuk azmeuk deleted the 724-jar branch May 18, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

role:authorization_server Concerns a server implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC9101 JWT-Secured Authorization Request (JAR)

2 participants