@@ -38,7 +38,7 @@ pub(super) struct PushedAuthorizationRequest {
3838
3939 // ATProtocol-specific parameter (legacy, prefer login_hint)
4040 pub subject : Option < String > ,
41-
41+
4242 /// JWT client assertion for private_key_jwt authentication (RFC 7523)
4343 pub client_assertion : Option < String > ,
4444 /// Client assertion type for private_key_jwt authentication
@@ -284,11 +284,13 @@ fn extract_client_auth_from_headers(headers: &HeaderMap) -> Option<ClientAuthent
284284}
285285
286286/// Extract client authentication from PAR request form data
287- fn extract_client_auth_from_request ( request : & PushedAuthorizationRequest ) -> Option < ClientAuthentication > {
287+ fn extract_client_auth_from_request (
288+ request : & PushedAuthorizationRequest ,
289+ ) -> Option < ClientAuthentication > {
288290 // Check for JWT client assertion first (private_key_jwt)
289- if let ( Some ( client_assertion) , Some ( client_assertion_type) ) =
290- ( & request. client_assertion , & request. client_assertion_type ) {
291-
291+ if let ( Some ( client_assertion) , Some ( client_assertion_type) ) =
292+ ( & request. client_assertion , & request. client_assertion_type )
293+ {
292294 // Validate the assertion type
293295 if client_assertion_type == "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" {
294296 return Some ( ClientAuthentication {
@@ -299,7 +301,7 @@ fn extract_client_auth_from_request(request: &PushedAuthorizationRequest) -> Opt
299301 } ) ;
300302 }
301303 }
302-
304+
303305 // PAR typically uses client credentials from headers, not form data
304306 // But we'll support client_id from the form
305307 Some ( ClientAuthentication {
@@ -339,28 +341,33 @@ fn authenticate_client(
339341 ClientAuthMethod :: PrivateKeyJwt => {
340342 // Require JWT client assertion
341343 if let Some ( client_assertion) = client_auth. client_assertion . as_ref ( ) {
342- // Construct token endpoint URL for audience validation
344+ // Construct token endpoint URL for audience validation
343345 // Note: PAR uses token endpoint as audience per RFC 9126
344346 let token_endpoint = format ! ( "{}/oauth/token" , issuer) ;
345-
347+
346348 // Validate the JWT client assertion
347349 let par_endpoint = format ! ( "{}/oauth/par" , issuer) ;
348- match validate_client_assertion ( client_assertion, client, & token_endpoint, Some ( & par_endpoint) ) {
350+ match validate_client_assertion (
351+ client_assertion,
352+ client,
353+ & token_endpoint,
354+ Some ( & par_endpoint) ,
355+ ) {
349356 Ok ( validated_client_id) => {
350357 // Ensure the validated client_id matches the expected client
351358 if validated_client_id == client. client_id {
352359 Ok ( ( ) )
353360 } else {
354361 Err ( OAuthError :: InvalidClient (
355- "JWT client_id does not match expected client" . to_string ( )
362+ "JWT client_id does not match expected client" . to_string ( ) ,
356363 ) )
357364 }
358365 }
359366 Err ( e) => Err ( e) ,
360367 }
361368 } else {
362369 Err ( OAuthError :: InvalidClient (
363- "Missing client_assertion for private_key_jwt authentication" . to_string ( )
370+ "Missing client_assertion for private_key_jwt authentication" . to_string ( ) ,
364371 ) )
365372 }
366373 }
0 commit comments