Skip to content

[BUG] The JWK set cache configuration is not applied for beans AadAppRoleStatelessAuthenticationFilter and JwtDecoderFactory #41349

@moarychan

Description

@moarychan

Describe the bug

When user configures the below properties:

spring.cloud.azure.active-directory.jwk-set-cache-lifespan: xxx
spring.cloud.azure.active-directory.jwk-set-cache-refresh-time: xxx

The configured JWK set cache is not applied for below beans:

  • AadAppRoleStatelessAuthenticationFilter

@Bean
@ConditionalOnMissingBean(AadAppRoleStatelessAuthenticationFilter.class)
@ConditionalOnExpression("${spring.cloud.azure.active-directory.session-stateless:false} == true")
AadAppRoleStatelessAuthenticationFilter aadStatelessAuthFilter(ResourceRetriever resourceRetriever) {
LOGGER.info("Creating AadStatelessAuthFilter bean.");
return new AadAppRoleStatelessAuthenticationFilter(
new UserPrincipalManager(
endpoints,
properties,
resourceRetriever,
true
)
);
}

  • JwtDecoderFactory

https://github.com/spring-projects/spring-security/blob/2cc6cbdb77d761cdfc7d792bb2d772c2b9186e93/oauth2/oauth2-jose/src/main/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoder.java#L379-L397

Exception or Stack Trace
Will always use the default cache value. Check the url access frequency.
image

To Reproduce
Use sample aad-resource-server-by-filter-stateless and aad-web-application-and-resource-server.

Code Snippet
N/A

Expected behavior
Apply the user configured jwk set cache.

Screenshots
If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • Library/Libraries: spring-cloud-azure-starter-active-directory:5.14.0
  • Java version: Java 17

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide:

  • verbose dependency tree (mvn dependency:tree -Dverbose)
  • exception message, full stack trace, and any available logs

Additional context
N/A

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.azure-springAll azure-spring related issuesazure-spring-aadSpring active directory related issues.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type
No fields configured for issues without a type.

Projects

Status
Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions