This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new c4deff31ba75 CAMEL-26902: camel-keycloak - createOrganization works 
with a Keycloak 26.0 server (#30264)
c4deff31ba75 is described below

commit c4deff31ba7537f9c4089ebb78aaacce0c2afa1f
Author: AurĂ©lien Pupier <[email protected]>
AuthorDate: Wed Nov 18 08:02:36 2026 +0100

    CAMEL-26902: camel-keycloak - createOrganization works with a Keycloak 26.0 
server (#30264)
    
    The ppc64le integration tests still run against Keycloak 26.0.5, because
    no newer image is available for that architecture. After the bump of
    keycloak-core to 26.8.x, 9 tests of KeycloakTestInfraIT failed there
    (testCreateOrganization and the 8 organization tests that depend on it),
    as seen in the Camel Core (Build and test) main build #2475.
    
    Cause: the producer added the domain as a plain
    OrganizationDomainRepresentation. The 26.8 client library has two new
    fields on that class, identityProviderAlias and autoRedirect. autoRedirect
    is a primitive boolean, so it is always serialized, as false. A Keycloak
    26.0 server knows only name and verified, and answers
    400 Unrecognized field "autoRedirect".
    
    Fix: createOrganization builds the domain from a private subclass,
    LegacyOrganizationDomain, annotated with @JsonIgnoreProperties for
    autoRedirect and identityProviderAlias. The producer never set these
    fields, so the request to a 26.8 server is unchanged in meaning.
    
    Verification:
    - KeycloakTestInfraIT against keycloak:26.0.5 (with -Dkeycloak.container):
      9 of 56 failed before the change, 56 of 56 pass after it.
    - full camel-keycloak build (unit tests and ITs) passes against
      keycloak:26.0.5 and against the default keycloak:26.8.2.
    
    Audit of the other operations: the fields of all 19 representation classes
    used by KeycloakProducer were compared between keycloak-core 26.0.5 and
    26.8.1, and a default instance of each class was serialized with the 26.8.1
    JsonSerialization and read back with a strict mapper on 26.0.5. Only
    OrganizationDomainRepresentation fails. The other new fields are objects,
    null by default and omitted by the NON_NULL inclusion. A pojoRequest body
    that sets a new field is not covered, and stays the responsibility of the
    caller.
    
    The upgrade guide now states that camel-keycloak is tested with Keycloak
    26.8.2 on amd64 and 26.0.5 on ppc64le, and mentions the createOrganization
    change.
    
    Co-authored-by: IBM Bob 2.2.1
    Signed-off-by: AurĂ©lien Pupier <[email protected]>
---
 .../org/apache/camel/component/keycloak/KeycloakProducer.java | 11 ++++++++++-
 .../modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc       |  8 +++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git 
a/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/KeycloakProducer.java
 
b/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/KeycloakProducer.java
index b9c41747fbc7..1bccd5be28a7 100644
--- 
a/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/KeycloakProducer.java
+++ 
b/components/camel-keycloak/src/main/java/org/apache/camel/component/keycloak/KeycloakProducer.java
@@ -29,6 +29,7 @@ import java.util.Map;
 import jakarta.ws.rs.WebApplicationException;
 import jakarta.ws.rs.core.Response;
 
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.InvalidPayloadException;
@@ -2752,7 +2753,7 @@ public class KeycloakProducer extends DefaultProducer {
             }
             String domainName = 
exchange.getIn().getHeader(KeycloakConstants.ORGANIZATION_DOMAIN, String.class);
             if (ObjectHelper.isNotEmpty(domainName)) {
-                OrganizationDomainRepresentation domain = new 
OrganizationDomainRepresentation();
+                OrganizationDomainRepresentation domain = new 
LegacyOrganizationDomain();
                 domain.setName(domainName);
                 org.addDomain(domain);
             }
@@ -3074,4 +3075,12 @@ public class KeycloakProducer extends DefaultProducer {
     public static Message getMessageForResponse(final Exchange exchange) {
         return exchange.getMessage();
     }
+
+    /**
+     * Organization domain without the fields added after Keycloak 26.0 
(autoRedirect, identityProviderAlias). The
+     * producer never sets them, and a Keycloak 26.0 server rejects an unknown 
field with HTTP 400.
+     */
+    @JsonIgnoreProperties({ "autoRedirect", "identityProviderAlias" })
+    private static final class LegacyOrganizationDomain extends 
OrganizationDomainRepresentation {
+    }
 }
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 62c5b24e00a2..010e3ece31ce 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -740,7 +740,13 @@ carry the built-in `kc-admin-api` client scope, and 
rejects other tokens with `4
 assigns the scope to `admin-cli` and `security-admin-console` only. When the 
`keycloak` producer authenticates with
 `clientId` and `clientSecret` of your own client, assign `kc-admin-api` to 
that client as a default client scope; a
 pre-obtained `accessToken` must be issued with that scope too. Username and 
password authentication uses `admin-cli`
-and keeps working. The integration tests of camel-keycloak now run against 
Keycloak 26.8.2.
+and keeps working. The integration tests of camel-keycloak now run against 
Keycloak 26.8.2 on amd64 and against
+Keycloak 26.0.5 on ppc64le.
+
+The `createOrganization` operation no longer sends the `autoRedirect` and 
`identityProviderAlias` fields of the
+organization domain, which the Keycloak 26.8 client library serializes 
(`autoRedirect` with the value `false`) and a
+Keycloak 26.0 server rejects with `400 Bad Request`. The producer never set 
these fields, so nothing changes for a
+Keycloak 26.8 server.
 
 === camel-kubernetes - the context reload on a secret or config map update 
lists the resources
 

Reply via email to