Describe the bug Logging in using reactive OAuth2 built with native throws after redirect from OAuth2 server(Google in my case).
java.lang.IllegalStateException: No provider found for class org.springframework.security.oauth2.client.authentication.OAuth2AuthorizationCodeAuthenticationToken
at org.springframework.security.web.server.authentication.AuthenticationWebFilter.lambda$authenticate$6(AuthenticationWebFilter.java:123)
Do note that the non-reactive counterpart does work and is able to find the provider correctly.
To Reproduce
run gradlew bootBuildImage, run the docker image that is created, and attempt to login via OAuth2.
Expected behavior Login with reactive Oauth2 without error
Sample
Here is a repo with a working example minus client id/secrets for the oauth2 client
Comment From: marcusdacoregio
Hi @msosa, thanks for the report.
The problem here is that there is no hint for JwtDecoder that is used here. In the meantime, while I'm working on the fix and the version is not released, you can workaround that by changing your application to include that hint:
@SpringBootApplication
@ImportRuntimeHints(MyHints::class)
class ReactiveOauth2Application
fun main(args: Array<String>) {
runApplication<ReactiveOauth2Application>(*args)
}
class MyHints: RuntimeHintsRegistrar {
override fun registerHints(hints: RuntimeHints, classLoader: ClassLoader?) {
hints.reflection().registerType(TypeReference.of("org.springframework.security.oauth2.jwt.JwtDecoder"), MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS)
}
}
Comment From: msosa
Awesome! I did try adding a few hints but not this one. Appreciate you looking into it.