Skip to content

Commit c21eef3

Browse files
author
Matthieu Bosquet
authored
Relax iat claim as per latest DPoP draft (#173)
* Relax iat claim as per latest DPoP draft * Disable linter rule failing on client_id
1 parent 30ff61a commit c21eef3

5 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/config/index.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
// Clock tolerance for all time based token verifications
2-
export const clockToleranceInSeconds = 5;
1+
/*
2+
* Default configuration.
3+
*
4+
* - clockToleranceInSeconds: How far in the future a token can be (if client's or server's clocks are off).
5+
* - maxAccessTokenAgeInSeconds: How old an Access Token can be.
6+
* - maxAgeInMilliseconds: For DPoP proofs & JTI cache (so that DPoP would fail to be replayed); also for Issuer Key Set cache & WebID issuers cache.
7+
* - maxRequestsPerSecond: Used to calculate the default cache size based on max age.
8+
*
9+
* Note: DPoP clock tolerance for time based token verification is advised to be a few seconds or minutes. See DPoP Proof Replay https://datatracker.ietf.org/doc/html/draft-ietf-oauth-dpop-09#section-11.1).
10+
*/
11+
// Set to 120 so clients can be a bit off
12+
export const clockToleranceInSeconds = 120;
313
// Limit Access Token Age to 24 Hours, it should probably have an exp claim much shorter than that
414
export const maxAccessTokenAgeInSeconds = 86400;
5-
// Default max age for everything else
6-
export const maxAgeInMilliseconds = 60000;
7-
// Used to calculate the default cache size based on max age
15+
// Default max age to 120 seconds for everything else
16+
export const maxAgeInMilliseconds = 120000;
17+
// An estimate of 100 rps for most small to medium projects
818
export const maxRequestsPerSecond = 100;

test/fixture/BearerAccessToken.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const header: SolidAccessTokenHeader = {
99
kid: "x",
1010
};
1111

12+
/* eslint-disable camelcase */
1213
const payload: SolidAccessTokenPayload = {
1314
aud: "solid",
1415
exp: 1603386448,

test/fixture/DPoPBoundAccessToken.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const header: SolidAccessTokenHeader = {
1010
kid: "x",
1111
};
1212

13+
/* eslint-disable camelcase */
1314
const bearerPayload: SolidAccessTokenPayload = {
1415
aud: "solid",
1516
exp: 1603386448,

test/fixture/SOLID_ACCESS_TOKEN_X.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { SolidAccessToken } from "../../src/type/SolidAccessToken";
22

3+
/* eslint-disable camelcase */
34
export const SOLID_ACCESS_TOKEN_X: SolidAccessToken = {
45
header: {
56
alg: "ES256",

test/unit/algorithm/verifySolidAccessTokenRequiredClaims.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { verifySolidAccessTokenRequiredClaims } from "../../../src/algorithm/verifySolidAccessTokenRequiredClaims";
22
import { RequiredClaimVerificationError } from "../../../src/error/RequiredClaimVerificationError";
33

4+
/* eslint-disable camelcase */
45
describe("verifySolidAccessTokenRequiredClaims", () => {
56
it("doesn't throw when the JSON object contains all required claims", () => {
67
expect(() => {

0 commit comments

Comments
 (0)