Skip to content

Commit

Permalink
fix: skip validating iat is in the past
Browse files Browse the repository at this point in the history
validating that iat is in the past is common sense but actually nowhere
defined, OpenID JWTs forcibly contain `exp` and for those
it seems requiring a few second leeway just to satisfy `iat` seems
inappropriate
  • Loading branch information
panva committed Dec 17, 2019
1 parent 9c672b6 commit 0791001
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
6 changes: 0 additions & 6 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,12 +691,6 @@ module.exports = (issuer, aadIssValidation = false) => class Client extends Base
jwt: idToken,
});
}
if (payload.iat > timestamp + this[CLOCK_TOLERANCE]) {
throw new RPError({
printf: ['id_token issued in the future, now %i, iat %i', timestamp + this[CLOCK_TOLERANCE], payload.iat],
jwt: idToken,
});
}
}

if (payload.nbf !== undefined) {
Expand Down
16 changes: 0 additions & 16 deletions test/client/client_instance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1884,22 +1884,6 @@ describe('Client', () => {
});
});

it('verifies iat is in the past', function () {
const payload = {
iss: this.issuer.issuer,
sub: 'userId',
aud: this.client.client_id,
exp: now() + 3600,
iat: now() + 20,
};

return this.IdToken(this.keystore.get(), 'RS256', payload)
.then((token) => this.client.validateIdToken(token))
.then(fail, (error) => {
expect(error).to.have.property('message').that.matches(/^id_token issued in the future, now \d+, iat \d+$/);
});
});

it('allows iat skew', function () {
this.client[custom.clock_tolerance] = 5;
const payload = {
Expand Down

0 comments on commit 0791001

Please sign in to comment.