Skip to content

Commit

Permalink
#134 - Fix up JWTVerificaitonResolver.
Browse files Browse the repository at this point in the history
  • Loading branch information
markrmiller committed Jul 14, 2020
1 parent b018247 commit bfdab56
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void init(Map<String, Object> pluginConfig) {
long jwkCacheDuration = Long.parseLong((String) pluginConfig.getOrDefault(PARAM_JWK_CACHE_DURATION, "3600"));
JWTIssuerConfig.setHttpsJwksFactory(new JWTIssuerConfig.HttpsJwksFactory(jwkCacheDuration, DEFAULT_REFRESH_REPRIEVE_THRESHOLD));

issuerConfigs = new ArrayList<>();
issuerConfigs = Collections.synchronizedList(new ArrayList<>());

// Try to parse an issuer from top level config, and add first (primary issuer)
Optional<JWTIssuerConfig> topLevelIssuer = parseIssuerFromTopLevelConfig(pluginConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.security.Key;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -59,7 +60,7 @@ public class JWTVerificationkeyResolver implements VerificationKeyResolver {

private final VerificationJwkSelector verificationJwkSelector = new VerificationJwkSelector();

private Map<String, JWTIssuerConfig> issuerConfigs = new ConcurrentHashMap<>();
private Map<String, JWTIssuerConfig> issuerConfigs = Collections.synchronizedMap(new HashMap<>());
private final boolean requireIssuer;

/**
Expand All @@ -70,9 +71,7 @@ public class JWTVerificationkeyResolver implements VerificationKeyResolver {
public JWTVerificationkeyResolver(Collection<JWTIssuerConfig> issuerConfigs, boolean requireIssuer) {
this.requireIssuer = requireIssuer;
issuerConfigs.forEach(ic -> {
if (ic.getIss() != null && ic != null) {
this.issuerConfigs.put(ic.getIss(), ic);
}
this.issuerConfigs.put(ic.getIss(), ic);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class JWTAuthPluginTest extends SolrTestCaseJ4 {

@BeforeClass
public static void beforeAll() throws Exception {
System.setProperty("solr.disablePublicKeyHandler", "false");
JwtClaims claims = generateClaims();
JsonWebSignature jws = new JsonWebSignature();
jws.setPayload(claims.toJson());
Expand Down

0 comments on commit bfdab56

Please sign in to comment.