A flexible, lightweight, and modern Keycloak 25+ (Quarkus / Jakarta EE) Authenticator SPI that:
- Enforces GitHub Organization Membership: Blocks authentication if the user does not belong to at least one of the configured GitHub organizations.
- Supports Multiple Organizations: Define a comma-separated list of allowed organizations.
- Optional Local Password Enforcement: Seamlessly prompts first-time federated users to create a local password credential (
UPDATE_PASSWORD), enabling autonomous offline access for CLIs and local logins. - Resilient API Strategy: Combines bulk checks (
/user/orgs) with individual membership fallbacks (/orgs/{org}/members/{user}).
- Multi-Org Filtering: Supports one or multiple GitHub organizations (e.g.,
cloudlabs-ufscar, other-org). - First Broker Login Integration: Acts as an admission gatekeeper before any user record is persisted in Keycloak's database.
- Autonomous Local Passwords (Optional): Injects Keycloak's native
UPDATE_PASSWORDrequired action so users can subsequently log in using username & password without touching GitHub. - Custom Error Messages: Tailor the rejection message shown to unauthorized users with dynamic
{user}and{orgs}placeholders. - Modern Stack: Built for Keycloak 25+ using Java 17,
jakarta.*packages, and Quarkus-native provider loading.
- Java 17+
- Apache Maven 3.8+
mvn clean packageThe resulting JAR file will be located at:
target/keycloak-github-org-validator.jar
- Copy the
.jarto Keycloak'sproviders/directory:- Bare-metal / Container:
/opt/keycloak/providers/keycloak-github-org-validator.jar - In Docker Compose: Mount it into
/opt/keycloak/providers/
- Bare-metal / Container:
- Restart Keycloak.
- Go to Identity Providers ➔ github.
- Ensure the Default Scopes field contains:
openid user:email read:org
- Go to Authentication ➔ Flows.
- Duplicate the built-in
first broker loginflow and name it (e.g.,cloudlabs-first-broker-login). - Click Add step / Add execution and select:
GitHub Organization Validator
- Set its requirement to
REQUIREDand position it at the top of the flow. - Click on the ⚙️ gear icon next to the execution to configure:
- Organizações Permitidas:
cloudlabs-ufscar, lab-secundario - Exigir Criação de Senha Local:
true(orfalse) - Mensagem de Erro Customizada: (Optional)
Acesso restrito: você precisa ser membro de {orgs} para acessar.
- Organizações Permitidas:
- Return to Identity Providers ➔ github and set First Login Flow to your newly created flow.
Apache License 2.0. Developed for the CloudLabs UFSCar project and the open-source community.