From 2c53bf2891f5da37c7eb1b9021438e4fdbaa0601 Mon Sep 17 00:00:00 2001 From: Bill Guedel Date: Tue, 17 Aug 2021 15:45:38 -0500 Subject: [PATCH] fix/jwtSync fixes #68 per example in related issue; time sync issue can occur when setting issued at to be the current time. This sets the issued at to be 1 minute earlier to avoid this. Tested locally for 2 days with no issues. --- .../java/com/spotify/github/v3/clients/JwtTokenIssuer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/spotify/github/v3/clients/JwtTokenIssuer.java b/src/main/java/com/spotify/github/v3/clients/JwtTokenIssuer.java index 8746eee2..20e652a9 100644 --- a/src/main/java/com/spotify/github/v3/clients/JwtTokenIssuer.java +++ b/src/main/java/com/spotify/github/v3/clients/JwtTokenIssuer.java @@ -36,6 +36,7 @@ public class JwtTokenIssuer { private static final SignatureAlgorithm SIGNATURE_ALGORITHM = SignatureAlgorithm.RS256; private static final long TOKEN_TTL = 600000; + private static final long TOKEN_ISSUED = 6000; private final PrivateKey signingKey; @@ -74,7 +75,7 @@ public String getToken(final Integer appId) { .setIssuer(String.valueOf(appId)) .signWith(signingKey, SIGNATURE_ALGORITHM) .setExpiration(new Date(System.currentTimeMillis() + TOKEN_TTL)) - .setIssuedAt(new Date()) + .setIssuedAt(new Date(System.currentTimeMillis() - TOKEN_ISSUED)) .compact(); } }