Skip to content

Commit

Permalink
fix: handle server_error on expired unsigned request objects
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Aug 30, 2019
1 parent 6a3b768 commit 7172a85
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/actions/authorization/process_request_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,13 @@ module.exports = async function processRequestObject(PARAM_LIST, ctx, next) {
}
}

if (alg === 'none') {
try {
JWT.assertPayload(payload, opts);
} else {
} catch (err) {
throw new InvalidRequestObject(`Request Object claims are invalid (${err.message})`);
}

if (alg !== 'none') {
try {
await JWT.verify(params.request, client.keystore, opts);
trusted = true;
Expand Down
31 changes: 31 additions & 0 deletions test/request/jwt_request.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,37 @@ describe('request parameter features', () => {
});
}

it('handles JWT claim assertions', function () {
const spy = sinon.spy();
this.provider.once(errorEvt, spy);

return JWT.sign({
client_id: 'client',
response_type: 'code',
redirect_uri: 'https://client.example.com/cb',
exp: 1,
}, null, 'none', { issuer: 'client', audience: this.provider.issuer }).then((request) => this.wrap({
agent: this.agent,
route,
verb,
auth: {
request,
scope: 'openid',
client_id: 'client',
response_type: 'code',
},
})
.expect(errorCode)
.expect(() => {
expect(spy.calledOnce).to.be.true;
expect(spy.args[0][1]).to.have.property('message', 'invalid_request_object');
expect(spy.args[0][1]).to.have.property(
'error_description',
'Request Object claims are invalid (jwt expired)',
);
}));
});

it('doesnt allow client_id to differ', function () {
const spy = sinon.spy();
this.provider.once(errorEvt, spy);
Expand Down

0 comments on commit 7172a85

Please sign in to comment.