Skip to content

Instantly share code, notes, and snippets.

View thomasdarimont's full-sized avatar
🏠
Working from home

Thomas Darimont thomasdarimont

🏠
Working from home
View GitHub Profile
@thomasdarimont
thomasdarimont / ChunkedJpaRealmProvider.java
Created August 25, 2026 09:09
Keycloak JpaRealmProvider Workaround for SQL Server's limit of 2100 bind parameters per statement https://github.com/keycloak/keycloak/issues/51510
import com.google.auto.service.AutoService;
import jakarta.persistence.EntityManager;
import jakarta.persistence.TypedQuery;
import lombok.extern.jbosslog.JBossLog;
import org.keycloak.Config;
import org.keycloak.connections.jpa.JpaConnectionProvider;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.RealmModel;
import org.keycloak.models.RoleModel;
@thomasdarimont
thomasdarimont / AllowRefreshTokenReuseExecutor.java
Last active August 25, 2026 08:55
Keycloak Client Policy Executor that allows reuse of refresh tokens per Client even if it is disabled on Realm level. Temporary workaround (based on 26.7.2+) until https://github.com/keycloak/keycloak/pull/51798 is merged
import com.google.auto.service.AutoService;
import org.jboss.logging.Logger;
import org.keycloak.Config;
import org.keycloak.OAuth2Constants;
import org.keycloak.models.AuthenticatedClientSessionModel;
import org.keycloak.models.Constants;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.representations.RefreshToken;
@thomasdarimont
thomasdarimont / RedirectUtils.java
Created August 20, 2026 10:30
Patched RedirectUtils that allows to disable the too strict OIDC Parameter validation in redirect URIs in 26.7.2
/*
* PATCHED Version of RedirectUtils to work around issue https://github.com/keycloak/keycloak/issues/51712 based on https://github.com/keycloak/keycloak/blob/26.7.2/services/src/main/java/org/keycloak/protocol/oidc/utils/RedirectUtils.java.
* See PATCH:BEGIN / PATCH:END sections for the changes.
*
* To allow OIDC-Parameters in redirect URIs start Keycloak with the env variable KC_PATCH_ALLOW_OIDC_PARAMS_IN_REDIRECT_URIS=true.
*
* Note: These class must be adapted/aligned with every Keycloak version update.
*/
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates
@thomasdarimont
thomasdarimont / Dockerfile
Last active August 25, 2026 18:36
./build-dockerized.sh 26.6.6 acme/keycloak
# Builder image for compiling Keycloak from source, see build-dockerized.sh
ARG JAVA_VERSION=21
FROM eclipse-temurin:${JAVA_VERSION}-jdk
# Node / pnpm versions should match the ones declared in the Keycloak js/pom.xml
# (node.version / pnpm.version) of the version being built.
ARG NODE_VERSION=24.9.0
ARG PNPM_VERSION=10.14.0
RUN apt-get update && \
@thomasdarimont
thomasdarimont / readme.md
Last active August 28, 2026 07:00
Keycloak / Apple Business / Apple School Manager Integration PoC Doc

Keycloak + Apple Business Integration

This guide describes how to integrate Keycloak with Apple Business Manager (ABM) as a Custom Identity Provider, using OIDC for authentication and SSF (Shared Signals Framework) for propagating session and credential change events.

Note that the frontend hostname that Keycloak uses as issuer for the ssf-configuration endpoint.

Keycloak Setup

@thomasdarimont
thomasdarimont / idjag-test.sh
Last active June 24, 2026 10:42
Example script for creating an idjag token with Keycloak
#!/usr/bin/env zsh
# Manual end-to-end test for the Identity Assertion JWT (ID-JAG) token-exchange flow.
#
# Prereq: start Keycloak with the experimental feature enabled, e.g.
# bin/kc.sh start-dev --features=identity-assertion-jwt,token-exchange
#
# Requires: curl, jq, openssl (all standard on macOS).
set -u
BASE=${BASE:-http://localhost:8081}
@thomasdarimont
thomasdarimont / MyEventListenerProvider.java
Last active August 25, 2026 12:47
Keycloak example extension with @KeycloakProvider without Service Manifest Files
package demo;
import org.jboss.logging.Logger;
import org.keycloak.Config;
import org.keycloak.events.Event;
import org.keycloak.events.EventListenerProvider;
import org.keycloak.events.EventListenerProviderFactory;
import org.keycloak.events.admin.AdminEvent;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
@thomasdarimont
thomasdarimont / ssf-support-design.md
Last active May 6, 2026 08:22
Design Document for Shared Signals Framework Transmitter Capability for Keycloak.

SSF Transmitter Support in Keycloak

Design-and-scope overview of the Shared Signals Framework (SSF) transmitter feature landed on branch issue/gh-xxx-ssf-tx-support-v1. Keycloak acts as an SSF Transmitter — receivers authenticated via OAuth pull or are pushed signed Security Event Tokens (SETs) describing user / session / credential events that happen in the realm.

Feature flag: Profile.Feature.SSF — experimental, opt-in.

<div>
<span>A</span>
<input type="text" id="inputWithKeyboard">
</div>
<div>
<span>B</span>
<input id="inputWithoutKeyboard" type="text" readonly autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
</div>
@thomasdarimont
thomasdarimont / CustomAzureOidcIdentityProvider.java
Created February 3, 2026 17:22
Custom CustomAzureOidcIdentityProvider to support client assertions with managed identities
package com.github.thomasdarimont.keycloak.custom.idp.azure;
import com.google.auto.service.AutoService;
import lombok.val;
import org.keycloak.authentication.ClientAuthenticationFlowContext;
import org.keycloak.authentication.authenticators.client.FederatedJWTClientValidator;
import org.keycloak.broker.oidc.OIDCIdentityProvider;
import org.keycloak.broker.oidc.OIDCIdentityProviderConfig;
import org.keycloak.broker.oidc.OIDCIdentityProviderFactory;
import org.keycloak.broker.provider.IdentityProviderFactory;