Camel Spring Boot

Keycloak

Manage the realms, users, roles, groups, clients and other resources of Keycloak with its Admin API, and receive Keycloak user and admin events.

What’s inside

Please refer to the above links for usage and configuration details.

Maven coordinates

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-keycloak-starter</artifactId>
</dependency>

Spring Boot Auto-Configuration

The starter supports 35 options, which are listed below.

Name Description Default Type

camel.component.keycloak.access-token

An access token the admin client sends as the Bearer token of its requests, instead of signing in with username and password or with the client credentials. It is used as is and not refreshed, so the calls fail once it expires.

String

camel.component.keycloak.allow-operation-header

Whether the CamelKeycloakOperation header may override the configured operation. Disabled by default: the operation decides what the endpoint does with its admin client, from reading a user to deleting a realm, so a message that can set the header can run any operation that the credentials of the endpoint allow. Enable it only on routes whose input is trusted.

false

Boolean

camel.component.keycloak.auth-client

Only the admin events made through the client with this ID (the internal ID of the client, not its client ID). Used with eventType=admin-events.

String

camel.component.keycloak.auth-ip-address

Only the admin events made from this IP address. Used with eventType=admin-events.

String

camel.component.keycloak.auth-realm

The realm the admin client signs in to. If not set, the realm option is used. Set it to sign in to one realm, such as master, and manage another.

master

String

camel.component.keycloak.auth-realm-filter

Only the admin events made by a caller signed in to the realm with this ID (the realm ID, which can differ from the realm name). Used with eventType=admin-events.

String

camel.component.keycloak.auth-user

Only the admin events made by the user with this user ID. Used with eventType=admin-events.

String

camel.component.keycloak.autowired-enabled

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

Boolean

camel.component.keycloak.bridge-error-handler

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

Boolean

camel.component.keycloak.client

Only the user events of the client with this client ID. Used with eventType=events.

String

camel.component.keycloak.client-id

The client ID to authenticate with. With clientSecret, the admin client signs in with the client credentials grant, when neither accessToken nor username and password are set. revokeAccessToken, revokeRefreshToken, introspectToken and evaluatePermission always authenticate with clientId and clientSecret.

String

camel.component.keycloak.client-secret

The secret of the client set in clientId.

String

camel.component.keycloak.configuration

Component configuration. The option is a org.apache.camel.component.keycloak.KeycloakConfiguration type.

KeycloakConfiguration

camel.component.keycloak.date-from

Only the events from this date on: a date in the yyyy-MM-dd format, or, with a Keycloak server version that supports it, a time in milliseconds since the epoch. Used with both event types.

String

camel.component.keycloak.date-to

Only the events up to this date, inclusive, in the same formats as dateFrom. Used with both event types.

String

camel.component.keycloak.enabled

Whether to enable auto configuration of the keycloak component. This is enabled by default.

Boolean

camel.component.keycloak.event-type

The type of events the consumer reads: events, for user events such as LOGIN, or admin-events, for the changes made through the Admin API or the Admin Console.

events

String

camel.component.keycloak.first

The index of the first event each poll reads. Keycloak returns the newest events first, so a value above 0 leaves out that many of the newest events.

0

Integer

camel.component.keycloak.introspection-cache-enabled

Not used by this endpoint: introspectToken does not cache its results. Caching of introspection results is set on KeycloakSecurityPolicy.

true

Boolean

camel.component.keycloak.introspection-cache-ttl

Not used by this endpoint, see introspectionCacheEnabled.

60

Long

camel.component.keycloak.ip-address

Only the user events from this IP address. Used with eventType=events.

String

camel.component.keycloak.keycloak-client

An existing Keycloak admin client (org.keycloak.admin.client.Keycloak) to use. When set, the endpoint does not build its own admin client from serverUrl, authRealm and the credentials, and does not close it when it stops. revokeAccessToken, revokeRefreshToken, introspectToken and evaluatePermission still call serverUrl with clientId and clientSecret. The option is a org.keycloak.admin.client.Keycloak type.

Keycloak

camel.component.keycloak.lazy-start-producer

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

Boolean

camel.component.keycloak.max-results

The number of events the first poll retrieves, and the page size of the later polls, which read every event since the previous poll

100

Integer

camel.component.keycloak.operation

The operation to perform

KeycloakOperations

camel.component.keycloak.operation-types

Only the admin events of these operation types, as a comma-separated list of CREATE, UPDATE, DELETE and ACTION. Used with eventType=admin-events.

String

camel.component.keycloak.password

The password of the user set in username.

String

camel.component.keycloak.pojo-request

Whether the create and update operations take the Keycloak representation to send, such as a UserRepresentation for createUser, from the message body; a Map or JSON text of it is converted. Otherwise they build it from headers, and the operations that need a full representation, such as updateRealm and createResource, fail.

false

Boolean

camel.component.keycloak.realm

The realm the consumer reads events from, and the realm the admin client signs in to unless authRealm is set. Most producer operations take the realm from the CamelKeycloakRealmName header instead: revokeAccessToken, revokeRefreshToken and introspectToken use this option when the header is not set, and evaluatePermission always uses it.

master

String

camel.component.keycloak.resource-path

Only the admin events on this resource path, such as users/*, where * matches any characters. Used with eventType=admin-events.

String

camel.component.keycloak.server-url

The base URL of the Keycloak server, for example http://localhost:8080. Required unless keycloakClient is set.

String

camel.component.keycloak.types

Only the user events of these types, as a comma-separated list such as LOGIN,LOGOUT. Used with eventType=events.

String

camel.component.keycloak.use-token-introspection

Not used by this endpoint: no operation of the endpoint validates tokens, and introspectToken always calls the token introspection endpoint of Keycloak. Token introspection for routes is set on KeycloakSecurityPolicy.

false

Boolean

camel.component.keycloak.user

Only the user events of the user with this user ID. Used with eventType=events.

String

camel.component.keycloak.username

The username the admin client signs in with, together with password, through the admin-cli client (password grant), when accessToken is not set. evaluatePermission also uses username and password when the CamelKeycloakAccessToken header is not set.

String