Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not process response from SAML identity provider because "this.text" is null #20670

Closed
2 tasks done
damien-vidal opened this issue May 30, 2023 · 3 comments
Closed
2 tasks done
Assignees
Labels
area/identity-brokering kind/bug Categorizes a PR related to a bug
Milestone

Comments

@damien-vidal
Copy link

Before reporting an issue

  • I have searched existing issues
  • I have reproduced the issue with the latest release

Area

identity-brokering

Describe the bug

LOG;

2023-05-30 19:47:43,760 ERROR [org.keycloak.services.error.KeycloakErrorHandler] (executor-thread-38) Uncaught server error: org.keycloak.broker.provider.IdentityBrokerException: Could not process response from SAML identity provider.
at org.keycloak.broker.saml.SAMLEndpoint$Binding.handleLoginResponse(SAMLEndpoint.java:596)
at org.keycloak.broker.saml.SAMLEndpoint$Binding.handleSamlResponse(SAMLEndpoint.java:679)
at org.keycloak.broker.saml.SAMLEndpoint$Binding.execute(SAMLEndpoint.java:278)
at org.keycloak.broker.saml.SAMLEndpoint.postBinding(SAMLEndpoint.java:189)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
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:152)
at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:183)
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.RoutingContextImpl.next(RoutingContextImpl.java:140)
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.RoutingContextImpl.next(RoutingContextImpl.java:140)
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.RoutingContextImpl.next(RoutingContextImpl.java:140)
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:1623)
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.length()" because "this.text" is null
at java.base/java.util.regex.Matcher.getTextLength(Matcher.java:1778)
at java.base/java.util.regex.Matcher.reset(Matcher.java:435)
at java.base/java.util.regex.Matcher.(Matcher.java:255)
at java.base/java.util.regex.Pattern.matcher(Pattern.java:1156)
at java.base/java.util.regex.Pattern.split(Pattern.java:1284)
at org.keycloak.broker.provider.util.IdentityBrokerState.encoded(IdentityBrokerState.java:66)
at org.keycloak.services.resources.IdentityBrokerService.getAndVerifyAuthenticationSession(IdentityBrokerService.java:1053)
at org.keycloak.broker.saml.SAMLEndpoint$Binding.handleLoginResponse(SAMLEndpoint.java:418)

Version

21.1.1

Expected behavior

Authentication should pass

Actual behavior

Authentication fails because of an exception

How to Reproduce?

  • Configure OIDC Client
  • Configure SAML2 Identity Provider ( import METADATA via XML)
  • Login via SAML2 IdP
    => exception, so authentication failed

Anything else?

Same config and workflow works well with Keycloak version 16.1.1

@damien-vidal damien-vidal added kind/bug Categorizes a PR related to a bug status/triage labels May 30, 2023
@douglaspalmer douglaspalmer added this to the 22.0.0 milestone Jun 1, 2023
@pedroigor
Copy link
Contributor

pedroigor commented Jun 1, 2023

@damien-vidal Could you please give more details about the response from the brokered SAML Identity Provider? I would like to see how the relay state looks like and more details about the redirect back to Keycloak.

@pedroigor pedroigor self-assigned this Jun 2, 2023
@pedroigor
Copy link
Contributor

Keycloak expects the relay state to be in the response from the IdP. It might happen that the IdP is returning with an error response (e.g.: anything other than status urn:oasis:names:tc:SAML:2.0:status:Success) and the relay state is not being sent. We use the relay state to resolve the authentication session.

What we can do is change the logic to first check if the response is valid and then check for the relay state to avoid this error. Or get more details about how you are configuring the broker and see if we can resolve the authentication session based on the client id instead of relying on the relay state.

The issue is lacking more details about how to reproduce the problem so I'm closing until we have more information about how to reproduce it.

@pedroigor pedroigor closed this as not planned Won't fix, can't repro, duplicate, stale Jun 6, 2023
@damien-vidal
Copy link
Author

Sorry I changed the log to TRACE but I was not able to reproduce it anymore. The only thing I changed in keycloak was the skew clock. And then in my IdP I also set the correct URL in audience because my IdP by default set the client ID in audience (I guess in 16.x version the audience was not checked by default). But I found these two issues after in the TRACE logs and the reported issue was not present anymore. Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/identity-brokering kind/bug Categorizes a PR related to a bug
Projects
None yet
Development

No branches or pull requests

3 participants