Skip to content

Commit

Permalink
fixes #17567 (#17588)
Browse files Browse the repository at this point in the history
Add new configuration item: azure.activedirectory.jwk-set-cache-refresh-time
  • Loading branch information
jacko9et authored Nov 16, 2020
1 parent 9215dcc commit bf43d37
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ public ResourceRetriever getJWTResourceRetriever() {
@ConditionalOnMissingBean(JWKSetCache.class)
public JWKSetCache getJWKSetCache() {
long lifespan = aadAuthenticationProperties.getJwkSetCacheLifespan();
return new DefaultJWKSetCache(lifespan, lifespan, TimeUnit.MILLISECONDS);
long refreshTime = aadAuthenticationProperties.getJwkSetCacheRefreshTime();
return new DefaultJWKSetCache(lifespan, refreshTime, TimeUnit.MILLISECONDS);
}

@PostConstruct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class AADAuthenticationProperties {
private static final Logger LOGGER = LoggerFactory.getLogger(AADAuthenticationProperties.class);
private static final String DEFAULT_SERVICE_ENVIRONMENT = "global";
private static final long DEFAULT_JWK_SET_CACHE_LIFESPAN = TimeUnit.MINUTES.toMillis(5);
private static final long DEFAULT_JWK_SET_CACHE_REFRESH_TIME = DEFAULT_JWK_SET_CACHE_LIFESPAN;
private static final String GROUP_RELATIONSHIP_DIRECT = "direct";
private static final String GROUP_RELATIONSHIP_TRANSITIVE = "transitive";

Expand Down Expand Up @@ -101,6 +102,11 @@ public class AADAuthenticationProperties {
*/
private long jwkSetCacheLifespan = DEFAULT_JWK_SET_CACHE_LIFESPAN;

/**
* The refresh time of the cached JWK set before it expires, default is 5 minutes.
*/
private long jwkSetCacheRefreshTime = DEFAULT_JWK_SET_CACHE_REFRESH_TIME;

/**
* Azure Tenant ID.
*/
Expand Down Expand Up @@ -388,6 +394,14 @@ public void setJwkSetCacheLifespan(long jwkSetCacheLifespan) {
this.jwkSetCacheLifespan = jwkSetCacheLifespan;
}

public long getJwkSetCacheRefreshTime() {
return jwkSetCacheRefreshTime;
}

public void setJwkSetCacheRefreshTime(long jwkSetCacheRefreshTime) {
this.jwkSetCacheRefreshTime = jwkSetCacheRefreshTime;
}

public String getTenantId() {
return tenantId;
}
Expand Down

0 comments on commit bf43d37

Please sign in to comment.