p2-inc / keycloak-magic-link

Magic Link Authentication for Keycloak
https://phasetwo.io
Other
222 stars 44 forks source link

java.lang.NoSuchMethodError thrown by MagicLinkAuthenticator.java action() method #23

Closed akashbatomic closed 1 year ago

akashbatomic commented 1 year ago

Hi,

After initial setup hiccups, I was able to setup this provider with keycloak and got the login screen with the username/email field to appear. I followed this

But when I submit the form in the UI, I get the following exception in the keycloak server logs: 2023-03-09 13:16:06,711 INFO [io.phasetwo.keycloak.magic.auth.MagicLinkAuthenticator] (executor-thread-4) MagicLinkAuthenticator.action 2023-03-09 13:16:06,721 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-4) Uncaught server error: java.lang.NoSuchMethodError: org.keycloak.authentication.AuthenticationFlowContext.getHttpRequest()Lorg/keycloak/http/HttpRequest; at io.phasetwo.keycloak.magic.auth.MagicLinkAuthenticator.action(MagicLinkAuthenticator.java:74) at org.keycloak.authentication.DefaultAuthenticationFlow.processAction(DefaultAuthenticationFlow.java:155) at org.keycloak.authentication.AuthenticationProcessor.authenticationAction(AuthenticationProcessor.java:977) at org.keycloak.services.resources.LoginActionsService.processFlow(LoginActionsService.java:311) at org.keycloak.services.resources.LoginActionsService.processAuthentication(LoginActionsService.java:282) at org.keycloak.services.resources.LoginActionsService.authenticate(LoginActionsService.java:274) at org.keycloak.services.resources.LoginActionsService.authenticateForm(LoginActionsService.java:339) 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.j

This is my setup:

This is what my Authentication flow looks like:

Screenshot 2023-03-09 at 1 58 14 PM

This is what Magic Link Config looks like:

Screenshot 2023-03-09 at 1 59 53 PM

Am I missing something in the config ?

xgp commented 1 year ago

Sorry @akashbatomic the error is not yours. Keycloak 21.0.0 made a breaking change in the API, and version 0.8 and beyond will no longer be compatible with previous Keycloak versions.

If you are not making changes to the extension, I'd suggest taking the jar from Maven central https://repo1.maven.org/maven2/io/phasetwo/keycloak/keycloak-magic-link/

If you need to use <21.0.0, you can use 0.7. Otherwise, I'd recommend upgrading your Keycloak version.