Skip to content

Commit

Permalink
added additional checks and logging when validating API keys
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Nov 9, 2023
1 parent dcc814e commit 67cea91
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/java/com/erudika/scoold/utils/ScooldUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -1975,13 +1975,16 @@ public Map<String, Object> getApiKeys() {

public Map<String, Long> getApiKeysExpirations() {
return API_KEYS.keySet().stream().collect(Collectors.toMap(k -> k, k -> {
String jwt = (String) API_KEYS.get(k);
try {
Date exp = SignedJWT.parse((String) API_KEYS.get(k)).getJWTClaimsSet().getExpirationTime();
if (exp != null) {
return exp.getTime();
if (!StringUtils.isBlank(jwt)) {
Date exp = SignedJWT.parse(jwt).getJWTClaimsSet().getExpirationTime();
if (exp != null) {
return exp.getTime();
}
}
} catch (ParseException ex) {
logger.error(null, ex);
logger.error("Failed to parse API key " + StringUtils.substring(jwt, 0, 10), ex);
}
return 0L;
}));
Expand Down

0 comments on commit 67cea91

Please sign in to comment.