Skip to content

Commit

Permalink
fix: remap invalid_redirect_uri as invalid_request in PAR
Browse files Browse the repository at this point in the history
BREAKING CHANGE: PAR no longer remaps all errors as
invalid_request_object.
  • Loading branch information
panva committed Mar 3, 2021
1 parent d1d9421 commit ceb3cd1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
const { OIDCProviderError } = require('../../helpers/errors');
const { InvalidRedirectUri, WebMessageUriMismatch } = require('../../helpers/errors');

/*
* Remaps the Pushed Authorization Request Endpoint errors thrown in downstream middlewares when
* coming purely from the JWT Request Object
* Remaps the Pushed Authorization Request Endpoint errors thrown in downstream middlewares.
*
* @throws: invalid_request_object
* @throws: invalid_request
*/
module.exports = async function requestObjectRemapErrors(ctx, next) {
if (!ctx.oidc.params.request) {
return next();
}

return next().catch((err) => {
if (err instanceof OIDCProviderError) {
if (err instanceof InvalidRedirectUri || err instanceof WebMessageUriMismatch) {
Object.assign(err, {
message: 'invalid_request_object',
error: 'invalid_request_object',
message: 'invalid_request',
error: 'invalid_request',
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ describe('Pushed Request Object', () => {
})
.expect(400)
.expect({
error: 'invalid_request_object',
error: 'invalid_request',
error_description: "redirect_uri did not match any of the client's registered redirect_uris",
});
});
Expand Down Expand Up @@ -420,7 +420,7 @@ describe('Pushed Request Object', () => {
})
.expect(400)
.expect({
error: 'invalid_redirect_uri',
error: 'invalid_request',
error_description: "redirect_uri did not match any of the client's registered redirect_uris",
});
});
Expand Down

0 comments on commit ceb3cd1

Please sign in to comment.