Pushed authorization requests
| This documentation was generated with the assistance of AI. Please report any inaccuracies. |
With pushed authorization requests (PAR, RFC 9126) the client sends the parameters of its authorization request straight
to the authorization server over an authenticated back-channel call, and the browser is then sent to the authorization
endpoint with only an opaque request_uri. The parameters can no longer be read or altered in the browser, the client
is authenticated before the user sees anything, and long requests do not hit URL limits. The endpoint is Spring
Authorization Server’s; this repository only switches it on with a property. The rest is the ordinary authorization code
flow with PKCE (see Authorization code with PKCE through the BFF).
-
Actors: the user with a browser, a client of the authorization code flow,
auth-server. -
Clients involved: any client with the
authorization_codegrant and a registered redirect URI. No client setting makes PAR mandatory: the endpoint is offered, not required. The BFF does not use it. -
Preconditions:
authserver.par.enabled=true(defaultfalse). It is a property, not a profile. -
Endpoints:
POST /oauth2/par,GET /oauth2/authorize,POST /oauth2/token; the metadata fieldpushed_authorization_request_endpointin/.well-known/openid-configurationand/.well-known/oauth-authorization-server.
Steps
-
With
authserver.par.enabled=true,ParConfiguration(conditional on the property) declares aProtocolChainCustomizer(order 5) that enables the framework’s pushed authorization request endpoint. The metadata then advertisespushed_authorization_request_endpoint; with the property off,POST /oauth2/paranswers404and the field is absent. -
The client builds a normal authorization request (
response_type=code,client_id,redirect_uri,scope,state,code_challenge,code_challenge_method=S256) and posts it as a form toPOST /oauth2/par, authenticating as it would at the token endpoint (see Client authentication). -
The server authenticates the client, validates the request as the authorization endpoint would (client, redirect URI, scopes, PKCE), stores it and answers
201 Createdwithrequest_uri(urn:ietf:params:oauth:request_uri:…) andexpires_in. -
The client redirects the browser to
GET /oauth2/authorize?client_id=…&request_uri=…. -
The server resolves the stored request. From here the flow is the authorization code flow: sign-in at
/login, the MFA policy and step-up (MfaProtocolChainCustomizerandStepUpProtocolChainCustomizerapply as usual, so a client withmfaRequiredsends the user to/login/second-factor), consent, then a redirect toredirect_uriwithcodeandstate. -
The
request_uriis single use: presenting it again does not yield another code. -
The client exchanges the code with its
code_verifieratPOST /oauth2/token.
/**
* Declares the customizer that enables the pushed authorization request endpoint.
*
* @return the customizer.
*/
@Bean
@Order(ORDER)
public ProtocolChainCustomizer parProtocolChainCustomizer() {
return server -> server.pushedAuthorizationRequestEndpoint(Customizer.withDefaults());
}
par:
# Pushed authorization requests (RFC 9126): the endpoint is off unless explicitly enabled.
enabled: false
Tokens and claims
PAR changes how the request reaches the server, not the result: the tokens are those of the authorization code flow
(access token with roles, tenant, aud and the MFA claims, refresh token, and an ID token when openid was
requested). The push response holds only request_uri and expires_in.
How it is tested
-
auth-server/boot:ParITchecks that with the property off the endpoint answers404and is not advertised; withauthserver.par.enabled=trueit answers arequest_uriand is advertised, the pushed request completes the code flow, a client requiring MFA is sent to the second-factor page, and a reusedrequest_uriyields no code.
Further reading
-
Implicit flow (legacy demo) and PAR (feature page, which also covers the PAR switch)