Invalid when WebClient or RestTemplate is set to lb in jwtDecoder
zxuanhong opened this issue · comments
xuanhong commented
Describe the bug
webflux
- Invalid when webClient is set to lb in jwtDecoder
- code
@Bean
@LoadBalanced
public WebClient.Builder webClientBuilder() {
return WebClient.builder();
}
http.oauth2ResourceServer((resourceServer) -> resourceServer
// 使用jwt
.jwt(jwtSpec -> jwtSpec
// 设置jwt解析器适配器
.jwtAuthenticationConverter(grantedAuthoritiesExtractor())
.jwtDecoder(
NimbusReactiveJwtDecoder
.withIssuerLocation(properties.getJwt().getIssuerUri())
.webClient(builder.build())
.build()
)
)
);
webMvc
@Bean
@LoadBalanced
public RestTemplate loadBalanced() {
return new RestTemplate();
}
http.oauth2ResourceServer((resourceServer) -> resourceServer
// 使用jwt
.jwt(jwtSpec -> jwtSpec
// 设置jwt解析器适配器
.jwtAuthenticationConverter(jwtAuthenticationConverter())
.decoder(
NimbusJwtDecoder
.withIssuerLocation(properties.getJwt().getIssuerUri())
.restOperations(restTemplate())
.build()
)
)
);
To Reproduce
Steps to reproduce the behavior.
webflux
- The authorization service is started first, and then the gateway is started
- The authorization service is stopped based on the above, and an exception is called. Restart the authorization service. You keep getting an error no matter how you call it
webmvc
- webmvc can't parse directly, no matter how you operate it.And start to report an error, can not start directly