Skip to content

Commit 7172a85

Browse files
committed
fix: handle server_error on expired unsigned request objects
1 parent 6a3b768 commit 7172a85

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

lib/actions/authorization/process_request_object.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,13 @@ module.exports = async function processRequestObject(PARAM_LIST, ctx, next) {
141141
}
142142
}
143143

144-
if (alg === 'none') {
144+
try {
145145
JWT.assertPayload(payload, opts);
146-
} else {
146+
} catch (err) {
147+
throw new InvalidRequestObject(`Request Object claims are invalid (${err.message})`);
148+
}
149+
150+
if (alg !== 'none') {
147151
try {
148152
await JWT.verify(params.request, client.keystore, opts);
149153
trusted = true;

test/request/jwt_request.test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,37 @@ describe('request parameter features', () => {
484484
});
485485
}
486486

487+
it('handles JWT claim assertions', function () {
488+
const spy = sinon.spy();
489+
this.provider.once(errorEvt, spy);
490+
491+
return JWT.sign({
492+
client_id: 'client',
493+
response_type: 'code',
494+
redirect_uri: 'https://client.example.com/cb',
495+
exp: 1,
496+
}, null, 'none', { issuer: 'client', audience: this.provider.issuer }).then((request) => this.wrap({
497+
agent: this.agent,
498+
route,
499+
verb,
500+
auth: {
501+
request,
502+
scope: 'openid',
503+
client_id: 'client',
504+
response_type: 'code',
505+
},
506+
})
507+
.expect(errorCode)
508+
.expect(() => {
509+
expect(spy.calledOnce).to.be.true;
510+
expect(spy.args[0][1]).to.have.property('message', 'invalid_request_object');
511+
expect(spy.args[0][1]).to.have.property(
512+
'error_description',
513+
'Request Object claims are invalid (jwt expired)',
514+
);
515+
}));
516+
});
517+
487518
it('doesnt allow client_id to differ', function () {
488519
const spy = sinon.spy();
489520
this.provider.once(errorEvt, spy);

0 commit comments

Comments
 (0)