Skip to content

Commit

Permalink
fix/jwtSync
Browse files Browse the repository at this point in the history
fixes spotify#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.
  • Loading branch information
bguedel authored Aug 17, 2021
1 parent 12f5323 commit 2c53bf2
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
}

0 comments on commit 2c53bf2

Please sign in to comment.