Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #17567 #17588

Merged
merged 5 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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