Skip to content

feat: Add support for Pushed Authorization Requests (PAR)#321

Open
An0n-01 wants to merge 3 commits intofastify:mainfrom
An0n-01:main
Open

feat: Add support for Pushed Authorization Requests (PAR)#321
An0n-01 wants to merge 3 commits intofastify:mainfrom
An0n-01:main

Conversation

@An0n-01
Copy link
Copy Markdown

@An0n-01 An0n-01 commented Feb 16, 2026

Hey.

I've implemented #320 now. I've also tested with my local keycloak instance and it works.


Implemented support for Pushed Authorization Requests (PAR) according to RFC9126.

This enhances security by allowing clients to push authorization request parameters directly to the authorization server via a backchannel POST request, receiving a request_uri to use in the subsequent authorization request.

Prevents parameter tampering and reduces exposure in browser URLs.

Checklist

Implements support for Pushed Authorization Requests (PAR)
according to RFC9126.

This enhances security by allowing clients to push
authorization request parameters directly to the authorization server
via a backchannel POST request, receiving a request_uri to use in
the subsequent authorization request.

Prevents parameter tampering and reduces exposure in browser URLs.
@An0n-01 An0n-01 changed the title feat: Adds support for Pushed Authorization Requests (PAR) feat: Add support for Pushed Authorization Requests (PAR) Feb 16, 2026
Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add some more tests for the full flow?

Comment thread index.js
if (v !== undefined && v !== null) {
body.append(k, Array.isArray(v) ? v.join(' ') : String(v))
}
})
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use a for(;;) loop

Comment thread index.js
res.on('data', (chunk) => { rawData += chunk })
res.on('end', () => {
try {
const data = JSON.parse(rawData)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use secure-json-parse here?

Comment thread index.js

function onParResponse (res) {
let rawData = ''
res.on('data', (chunk) => { rawData += chunk })
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you need to set the encoding correctly

Comment thread index.js
if (res.statusCode >= 200 && res.statusCode < 300) {
callback(null, data)
} else {
const err = new Error(`PAR request failed: ${data.error_description || data.error || 'Unknown error'}`)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use fastify-error

Comment thread index.js
}

function errHandler (e) {
const err = new Error('Problem calling PAR endpoint. See innerError for details.')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use fastify-error

Comment thread index.js

// Validate that PAR endpoint was discovered
if (!authFromMetadata.parPath) {
next(new Error('PAR is enabled but pushed_authorization_request_endpoint was not found in discovery metadata'))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fastify-error

@An0n-01
Copy link
Copy Markdown
Author

An0n-01 commented Feb 17, 2026

I'll look at everything asap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants