mesutpiskin / keycloak-2fa-email-authenticator

šŸ”’ Keycloak Authentication Provider implementation to get a two factor authentication with a OTP/code/token send via Email (through SMTP)
https://medium.com/@mesutpiskin/two-factor-authentication-via-email-in-keycloak-custom-auth-spi-935bbb3952a8
Apache License 2.0
165 stars 91 forks source link

Keycloak 21.0.1 Method Error #8

Closed ckbaker10 closed 1 year ago

ckbaker10 commented 1 year ago

Hello,

Keycloak 21.0.1 warns about an internal SPI and produces this method error. I'm going to try to fix it by myself but I'm not very confident. If I succeed, I'll issue a pull request.

Cheers.

-- Tested to still work on Keycloak 20.0.5, happy that im doing pre upgrade tests :)

SPI Warning

2023-03-30 09:08:14,301 WARN [org.keycloak.services] (build-3) KC-SERVICES0047: demo-email-code-form (com.mesutpiskin.keycloak.auth.email.EmailAuthenticatorFormFactory) is implementing the internal SPI authenticator. This SPI is internal and may change without notice

Error Trace

2023-03-29 19:24:08,593 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-11) Uncaught server error: java.lang.NoSuchMethodError: 'org.jboss.resteasy.spi.HttpRequest org.keycloak.authentication.AuthenticationFlowContext.getHttpRequest()'
        at com.mesutpiskin.keycloak.auth.email.EmailAuthenticatorForm.action(EmailAuthenticatorForm.java:70)
        at org.keycloak.authentication.DefaultAuthenticationFlow.processAction(DefaultAuthenticationFlow.java:154)
        at org.keycloak.authentication.AuthenticationProcessor.authenticationAction(AuthenticationProcessor.java:985)
        at org.keycloak.services.resources.LoginActionsService.processFlow(LoginActionsService.java:323)
        at org.keycloak.services.resources.LoginActionsService.processAuthentication(LoginActionsService.java:294)
        at org.keycloak.services.resources.LoginActionsService.authenticateInternal(LoginActionsService.java:286)
        at org.keycloak.services.resources.LoginActionsService.access$100(LoginActionsService.java:111)
        at org.keycloak.services.resources.LoginActionsService$1.runInternal(LoginActionsService.java:266)
        at org.keycloak.common.util.ResponseSessionTask.run(ResponseSessionTask.java:67)
        at org.keycloak.common.util.ResponseSessionTask.run(ResponseSessionTask.java:44)
        at org.keycloak.models.utils.KeycloakModelUtils.runJobInRetriableTransaction(KeycloakModelUtils.java:299)
        at org.keycloak.services.resources.LoginActionsService.authenticate(LoginActionsService.java:259)
        at org.keycloak.services.resources.LoginActionsService.authenticateForm(LoginActionsService.java:351)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
        at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
        at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
        at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
        at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
        at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:192)
        at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:141)
        at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:32)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
        at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
        at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
        at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
        at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
        at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:82)
        at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:42)
        at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1284)
        at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:173)
        at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:200)
        at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:84)
        at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:71)
        at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1284)
        at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:173)
        at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:200)
        at io.quarkus.vertx.http.runtime.VertxHttpRecorder$6.handle(VertxHttpRecorder.java:430)
        at io.quarkus.vertx.http.runtime.VertxHttpRecorder$6.handle(VertxHttpRecorder.java:408)
        at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1284)
        at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:173)
        at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:200)
        at org.keycloak.quarkus.runtime.integration.web.QuarkusRequestFilter.lambda$createBlockingHandler$0(QuarkusRequestFilter.java:82)
        at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576)
        at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
        at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
        at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
        at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:829)
oliverlj commented 1 year ago

Working successfully on 21.0.1

Tim-is-coding commented 1 year ago

Also on 21.0.2

Gokulreva commented 1 year ago

Hi, is this issue resolved. We would like to upgrade the keycloak but when we checked last time we had the same issue.

guntherrhon commented 1 year ago

I'm using same Keyclock version defined in pom.xml and it's working. I used 21.* but received same our problem. C

alexted commented 1 year ago

@mesutpiskin could you please update the spi so that it works correctly on the current version of the kc?

alexted commented 1 year ago

@jakubskopal, @ksarink maybe you could help us?

ksarink commented 1 year ago

The problem seems to be that the plugin must be compiled with the corresponding Keycloak version. I created a fork where the plugin is compiled against the latest 10 Keycloak versions. Next I'll create a cronjob, which will update the plugin release when a new Keycloak version is released.

https://github.com/ksarink/keycloak-2fa-email-authenticator/releases/tag/0.3.0

mesutpiskin commented 1 year ago

https://github.com/mesutpiskin/keycloak-2fa-email-authenticator/releases/tag/v0.4