mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
Compute new expiration from old expiration
This commit is contained in:
@@ -40,7 +40,7 @@ public class JwtAccessTokenRefresher {
|
||||
log.warn("no parent token id found in token; could not refresh");
|
||||
return Optional.empty();
|
||||
}
|
||||
builder.expiresIn(1, TimeUnit.HOURS);
|
||||
builder.expiresIn(computeOldExpirationInMillis(oldToken), TimeUnit.MILLISECONDS);
|
||||
builder.parentKey(parentTokenId.get().toString());
|
||||
return Optional.of(builder.build());
|
||||
} else {
|
||||
@@ -48,6 +48,10 @@ public class JwtAccessTokenRefresher {
|
||||
}
|
||||
}
|
||||
|
||||
private long computeOldExpirationInMillis(JwtAccessToken oldToken) {
|
||||
return oldToken.getExpiration().getTime() - oldToken.getIssuedAt().getTime();
|
||||
}
|
||||
|
||||
private boolean canBeRefreshed(JwtAccessToken oldToken) {
|
||||
return tokenIsValid(oldToken) && tokenCanBeRefreshed(oldToken);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user