Skip to content

Commit 639ecee

Browse files
committed
Add trace logging for parsing JWT
1 parent a26727a commit 639ecee

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/main/java/com/faforever/api/security/FafMultiTokenStore.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.faforever.api.security;
22

33
import com.faforever.api.config.FafApiProperties;
4+
import lombok.extern.slf4j.Slf4j;
45
import org.springframework.beans.factory.annotation.Qualifier;
56
import org.springframework.security.jwt.Jwt;
67
import org.springframework.security.jwt.JwtHelper;
@@ -21,6 +22,7 @@
2122
import java.util.Objects;
2223

2324
@Component
25+
@Slf4j
2426
public class FafMultiTokenStore implements TokenStore {
2527
private JsonParser objectMapper = JsonParserFactory.create();
2628

@@ -58,8 +60,10 @@ public OAuth2Authentication readAuthentication(String token) {
5860
Map<String, Object> claims = objectMapper.parseMap(unverifiedJwt.getClaims());
5961

6062
if (Objects.equals(claims.get("iss"), fafApiProperties.getJwt().getFafHydraIssuer())) {
63+
log.trace("Reading authentication for Hydra token");
6164
return hydraTokenStore.readAuthentication(token);
6265
} else {
66+
log.trace("Reading authentication for legacy API token");
6367
return classicTokenStore.readAuthentication(token);
6468
}
6569
}
@@ -72,8 +76,10 @@ public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authe
7276
@Override
7377
public OAuth2AccessToken readAccessToken(String tokenValue) {
7478
try {
79+
log.trace("Reading access token for legacy api token");
7580
return classicTokenStore.readAccessToken(tokenValue);
7681
} catch (Exception e) {
82+
log.trace("Reading access token for legacy api token failed. Fallback to reading access token for Hydra token");
7783
return hydraTokenStore.readAccessToken(tokenValue);
7884
}
7985
}

0 commit comments

Comments
 (0)