Skip to content

OAuth2AuthorizationServerJwtAutoConfiguration uses @ConditionalOnClass incorrectly #45177

Closed
@wilkinsona

Description

@wilkinsona

@Bean
@ConditionalOnClass(JwtDecoder.class)
@ConditionalOnMissingBean
JwtDecoder jwtDecoder(JWKSource<SecurityContext> jwkSource) {
return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource);
}

This may break if JwtDecoder is not on the classpath as OAuth2AuthorizationServerJwtAutoConfiguration will still be loaded but it will declare a method whose signature refers to a class that does not exist.

@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
@ConditionalOnMissingBean
JWKSource<SecurityContext> jwkSource() {
RSAKey rsaKey = getRsaKey();
JWKSet jwkSet = new JWKSet(rsaKey);
return new ImmutableJWKSet<>(jwkSet);
}

There's no check here for com.nimbusds.jose.jwk.source.JWKSource or com.nimbusds.jose.proc.SecurityContext being on the classpath and the class only checks for org.springframework.security.oauth2.server.authorization.OAuth2Authorization.

It could be that the presence of OAuth2Authorization implies that the other classes must be present, or it may be that we need to introduce some inner-classes.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions