Skip to content

Allow forwarding the claims parameter from the initial authorization request to brokered OPs #41670

Closed

Description

@pedroigor

Description

Currently, there is no way to forward the claims parameter to a brokered OP.

Discussion

No response

Motivation

Allow forwarding the claims parameter to a brokered OP.

Details

No response

Activity

  1. self-assigned this
    on Aug 5, 2025
  2. bgillis commented on Aug 5, 2025

    @bgillis

    Please find hereby the ticket describing the issue
    #41459

  3. added a commit that references this issue on Aug 5, 2025
    5399066
  4. pedroigor commented on Aug 5, 2025

    @pedroigor
    ContributorAuthor

    Thanks @bgillis. Is the proposed change enough to solve your use case and close the issue you linked?

  5. bgillis commented on Aug 5, 2025

    @bgillis

    @pedroigor Yes I guess so. Thank you very much for the quick fix.

    If I understand well the applied solution, the claims parameter will be then automatically forwarded to the brokered OP if present in the initial auth request... and by adding from now on this claims as an additional configuration element for the brokered OP in RHBK (in particular, "Forwarded query parameters"). Am I right ?

  6. added a commit that references this issue on Aug 6, 2025
    84fc9bb
  7. bgillis commented on Aug 8, 2025

    @bgillis

    @pedroigor This morning, I applied your fix on Keycloak 26.2.5 to validate that it solves indeed my issue.
    Unfortunately, the fix is incomplete.

    Please find hereby an example of the Initial Authorisation Request sent to Keycloak by my single page appliocation...

    http://localhost:8080/realms/connective/protocol/openid-connect/auth?response_type=code&client_id=cm-app&redirect_uri=https://www.google.com&scope=openid&state=xcoivjuywkdkhvus&ui_locales=fr&code_challenge=rfb3f94xsoyiqvaciahd2ngx-pabkb3ggnha8sbaqrg&code_challenge_method=s256&acr_values=idp:itsme&kc_idp_hint=identity&claims=%7B%22userinfo%22%3A%7B%22http%3A%2F%2Fitsme.services%2Fv2%2Fclaim%2FBENationalNumber%22%3Anull%2C%22http%3A%2F%2Fitsme.services%2Fv2%2Fclaim%2FBEeidSn%22%3Anull%2C%22http%3A%2F%2Fitsme.services%2Fv2%2Fclaim%2Fclaim_citizenship%22%3Anull%2C%22http%3A%2F%2Fitsme.services%2Fv2%2Fclaim%2Fclaim_citizenship_as_iso%22%3Anull%2C%22http%3A%2F%2Fitsme.services%2Fv2%2Fclaim%2Fplace_of_birth%22%3Anull%2C%22http%3A%2F%2Fitsme.services%2Fv2%2Fclaim%2FvalidityTo%22%3Anull%2C%22http%3A%2F%2Fitsme.services%2Fv2%2Fclaim%2FIDDocumentSN%22%3Anull%2C%22http%3A%2F%2Fitsme.services%2Fv2%2Fclaim%2FIDDocumentType%22%3Anull%2C%22http%3A%2F%2Fitsme.services%2Fv2%2Fclaim%2FIDIssuingCountry%22%3Anull%2C%22http%3A%2F%2Fitsme.services%2Fv2%2Fclaim%2Fissuance_locality%22%3Anull%7D%7D

    The claims query params unencoded value is the following:

    {"userinfo":{"http://itsme.services/v2/claim/BENationalNumber":null,"http://itsme.services/v2/claim/BEeidSn":null,"http://itsme.services/v2/claim/claim_citizenship":null,"http://itsme.services/v2/claim/claim_citizenship_as_iso":null,"http://itsme.services/v2/claim/place_of_birth":null,"http://itsme.services/v2/claim/validityTo":null,"http://itsme.services/v2/claim/IDDocumentSN":null,"http://itsme.services/v2/claim/IDDocumentType":null,"http://itsme.services/v2/claim/IDIssuingCountry":null,"http://itsme.services/v2/claim/issuance_locality":null}}

    When Keycloak tries now to forward this claims query parameter to the brokered identity provider, I now get an exception thrown by Keycloak...

    2025-08-08 09:47:58,403 ERROR [org.keycloak.services.resources.IdentityBrokerService] (executor-thread-41) couldNotSendAuthenticationRequestMessage: org.keycloak.broker.provider.IdentityBrokerException: Could not create authentication request.
            at org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider.performLogin(AbstractOAuth2IdentityProvider.java:142)
            at org.keycloak.services.resources.IdentityBrokerService.performLogin(IdentityBrokerService.java:396)
            at org.keycloak.services.resources.IdentityBrokerService$quarkusrestinvoker$performLogin_639fa76256feb47da66621dcdd20f8de386404c5.invoke(Unknown Source)
            at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
            at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
            at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
            at io.quarkus.vertx.core.runtime.VertxCoreRecorder$15.runWith(VertxCoreRecorder.java:638)
            at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2675)
            at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2654)
            at org.jboss.threads.EnhancedQueueExecutor.runThreadBody(EnhancedQueueExecutor.java:1627)
            at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1594)
            at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
            at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
            at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
            at java.base/java.lang.Thread.run(Thread.java:840)
    Caused by: jakarta.ws.rs.core.UriBuilderException: failed to create URI
            at org.jboss.resteasy.reactive.common.jaxrs.UriBuilderImpl.buildFromValues(UriBuilderImpl.java:753)
            at org.jboss.resteasy.reactive.common.jaxrs.UriBuilderImpl.build(UriBuilderImpl.java:741)
            at org.keycloak.broker.oidc.AbstractOAuth2IdentityProvider.performLogin(AbstractOAuth2IdentityProvider.java:138)
            ... 14 more
    Caused by: java.net.URISyntaxException: Illegal character in query at index 480: https://identity-acc.connective.eu/connect/authorize?scope=openid+profile+address+phone+email+eid&state=UEmUJ8Yo4jbX_TFkTCURfOLsjMdRIZsYE-SbMRKRDrI.iod5iHReEm0.409s1MQFQ7S9xNah1VwgZQ.eyJydSI6Imh0dHBzOi8vd3d3Lmdvb2dsZS5jb20iLCJydCI6ImNvZGUiLCJzdCI6Inhjb2l2anV5d2tka2h2dXMifQ&response_type=code&client_id=96cab3f5-611f-433c-a3e5-bc032601c0d1&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Frealms%2Fconnective%2Fbroker%2Fidentity%2Fendpoint&ui_locales=fr&acr_values=idp%3Aitsme&claims={"userinfo":{"http://itsme.services/v2/claim/BENationalNumber":null,"http://itsme.services/v2/claim/BEeidSn":null,"http://itsme.services/v2/claim/claim_citizenship":null,"http://itsme.services/v2/claim/claim_citizenship_as_iso":null,"http://itsme.services/v2/claim/place_of_birth":null,"http://itsme.services/v2/claim/validityTo":null,"http://itsme.services/v2/claim/IDDocumentSN":null,"http://itsme.services/v2/claim/IDDocumentType":null,"http://itsme.services/v2/claim/IDIssuingCountry":null,"http://itsme.services/v2/claim/issuance_locality":null}}&code_challenge=khQ3ZZadn78fLMHa9iWG2G7cKa-XpLF0SsHLIgSt4kw&code_challenge_method=S256&nonce=w66wZZEhJEjKqcb53dwiog
            at java.base/java.net.URI$Parser.fail(URI.java:2976)
            at java.base/java.net.URI$Parser.checkChars(URI.java:3147)
            at java.base/java.net.URI$Parser.parseHierarchical(URI.java:3235)
            at java.base/java.net.URI$Parser.parse(URI.java:3177)
            at java.base/java.net.URI.<init>(URI.java:623)
            at org.jboss.resteasy.reactive.common.jaxrs.UriBuilderImpl.buildFromValues(UriBuilderImpl.java:748)
            ... 16 more
    
    

    As you can see, the claims query parameter does not seems to be correctly url encoded by Keycloak.

    Could you then reopened this issue ? Thank you.

    Bertrand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions