• Stars
    star
    540
  • Rank 82,257 (Top 2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple project environment for creating custom Keycloak extensions

Keycloak Extension Playground

Simple project environment for developing custom Keycloak extensions.
This example uses the in-process KeycloakServer from the keycloak-testsuite-utils project to ease development.

Note that you might need to build the keycloak project locally with the version referenced in this pom.xml since the required library keycloak-testsuite-utils is not distributed to maven central.

Building Keycloak

To build the Keycloak Project simply clone it into a directory like

# The Keycloak version referenced in the pom.xml 
KC_VERSION=19.0.2
git clone https://github.com/keycloak/keycloak
git fetch origin --tags
git checkout $KC_VERSION
mvn clean install -DskipTests

Note that the current Keycloak release also needs the new keycloak-admin-ui dependency. If this dependency cannot be resolved, then you need to build the admin ui keycloak-theme first.

IDE Setup

Create a new launch configuration and configure com.github.thomasdarimont.keycloak.server.KeycloakPlaygroundServer as the main class. Additionally configure keycloak-playground-server as the working directory.

Note, that you can configure Keycloak to use an h2 or PostgreSQL database, depending on your needs.

The following set of JVM options configure Keycloak with:

  • h2 or PostgreSQL as database
  • listen on all local interfaces on port 8081
  • Keycloak Admin User admin with password admin
  • preview Profile features enabled

You can access the local Keycloak instance via the URL: http://localhost:8081/auth

Developing with a local h2 database

-Dkeycloak.bind.address=0.0.0.0
-Djava.net.preferIPv4Stack=true
-Dkeycloak.connectionsJpa.url=jdbc:h2:file:./data/keycloak_17_0_0_0000_master;DB_CLOSE_ON_EXIT=FALSE
-Dkeycloak.connectionsJpa.driver=org.h2.Driver
-Dkeycloak.connectionsJpa.driverDialect=org.hibernate.dialect.H2Dialect
-Dkeycloak.connectionsJpa.user=sa
-Dkeycloak.connectionsJpa.password=
-Dkeycloak.connectionsJpa.showSql=false
-Dkeycloak.connectionsJpa.formatSql=true
-Dprofile=COMMUNITY
-Dproduct.default-profile=COMMUNITY
-Dkeycloak.password.blacklists.path=./data/blacklists/
-Dcom.sun.net.ssl.checkRevocation=false
-Dkeycloak.truststore.disabled=true
-Dkeycloak.profile=COMMUNITY
-Dkeycloak.product.name=keycloak
-Dproduct.name=keycloak
-Dkeycloak.profile=preview
-Dkeycloak.hostname.frontendUrl=http://localhost:8081/auth
-Dkeycloak.profile.feature.account2=enabled
-Dkeycloak.profile.feature.account_api=enabled
-Dkeycloak.profile.feature.scripts=enabled
-Dkeycloak.profile.feature.device_activity=enabled
-Dkeycloak.profile.feature.tokenexchange=enabled
-Dkeycloak.profile.feature.ciba=enabled
-Dkeycloak.profile.feature.client_policies=enabled
-Dkeycloak.profile.feature.map_storage=disabled
-Dkeycloak.ciba-auth-channel.ciba-http-auth-channel.httpAuthenticationChannelUri=http://localhost:7777/ciba/auth
-Dkeycloak.theme.welcomeTheme=keycloak
-Dkeycloak.theme.dir=../simple-theme/
-Dresources=../simple-theme/

Developing with a PostgreSQL database

-Dkeycloak.bind.address=127.0.0.1
-Djava.net.preferIPv4Stack=true
-Dkeycloak.connectionsJpa.url=jdbc:postgresql://localhost:5432/keycloak_playground
-Dkeycloak.connectionsJpa.driver=org.postgresql.Driver
-Dkeycloak.connectionsJpa.driverDialect=org.hibernate.dialect.PostgreSQLDialect
-Dkeycloak.connectionsJpa.user=keycloak
-Dkeycloak.connectionsJpa.password=keycloak
-Dkeycloak.connectionsJpa.showSql=true
-Dkeycloak.connectionsJpa.formatSql=true
-Dprofile=COMMUNITY
-Dproduct.default-profile=COMMUNITY
-Dkeycloak.password.blacklists.path=/home/tom/dev/tmp/blacklists/
-Dcom.sun.net.ssl.checkRevocation=false
-Dkeycloak.truststore.disabled=true
-Dkeycloak.profile=COMMUNITY
-Dkeycloak.product.name=keycloak
-Dproduct.name=keycloak
-Dkeycloak.profile=preview
-Dkeycloak.profile.feature.account2=enabled
-Dkeycloak.profile.feature.account_api=enabled
-Dkeycloak.profile.feature.scripts=enabled
-Dkeycloak.profile.feature.device_activity=enabled
-Dkeycloak.profile.feature.tokenexchange=enabled
-Dkeycloak.profile.feature.ciba=enabled
-Dkeycloak.profile.feature.client_policies=enabled
-Dkeycloak.profile.feature.map_storage=disabled
-Dkeycloak.theme.welcomeTheme=keycloak
-Dkeycloak.theme.dir=../simple-theme/
-Dresources=../simple-theme/

Developing a Keycloak extension

To develop your extension, simply create a new maven module, e.g. simple-auth-extension in the keycloak-extension-playground. Then add the module as a dependency to the keycloak-playground-server project.

The Server Development part of the Keycloak reference documentation contains additional resources and examples for developing custom Keycloak extensions.

Examples

The Keycloak project on github provides a useful set of examples for Keycloak extensions.

Simple Auth Extension

The simple-auth-extension project provides an example project that can be used as a starting point.

Simple Themes

The simple-themes example project demonstrates how to use custom themes with keycloak.

More Repositories

1

awesome-keycloak

A curated list of resources for learning about http://www.keycloak.org
1,458
star
2

embedded-spring-boot-keycloak-server

Keycloak JAX-RS application embedded in a Spring-Boot App.
Java
263
star
3

keycloak-project-example

An example project for Keycloak Customizations
Java
237
star
4

keycloak-docker-demo

Repository for Keycloak Demos
Java
182
star
5

spring-boot-2-keycloak-oauth-example

PoC for Spring Boot 2 + Spring Security 5 + Keycloak 3.4.3 without Keycloak Adapter
Java
142
star
6

keycloak-health-checks

Keycloak Extension for health checks
Java
134
star
7

spring-labs

Here be dragons
Java
94
star
8

spring-boot-keycloak-server-example

THIS PROJECT MOVED: PoC for embedding Keycloak's JAX-RS application in a Spring-Boot App. New Location:
Java
92
star
9

keycloak-user-storage-provider-demo

Simple custom User Storage Provider extension for Keycloak. Deployed as .ear with dependencies & jboss-cli based setup.
Java
89
star
10

springio18-spring-keycloak

Slides & Code from my "How to secure your Spring Boot Apps with Keycloak" talk at Spring I/O 2018
Java
88
star
11

keycloak-avatar-minio-extension

Simple example for managing avatar images with Keycloak
Java
69
star
12

spring-boot-admin-keycloak-example

Example for protecting Spring Boot Admin & Spring Boot Actuator endpoints with Keycloak
Java
57
star
13

spring-boot-prometheus-example

Simple example for exposing Metrics in a Spring Boot App for consumption by Prometheus
Shell
51
star
14

kc-dnc-demo

PoC for securing AspNetCore based Web Apps with Keycloak.
C#
38
star
15

keycloak-freeradius-demo

PoC for delegating a free-radius authentication to Keycloak via PAM
Dockerfile
25
star
16

screen-casting-app

Spring Boot App which periodically captures Screenshots of the current system and exposes them via a simple Web-Interface
Java
22
star
17

quarkus-keycloak-demo

Simple example for a stateless JAX-RS webservice that can be accessed with JWTs issued by Keycloak
HTML
22
star
18

vertx-playground

Some experiments with the Vert.x Web Framework
Java
21
star
19

keycloak-custom-server

Custom Keycloak.X Server Distribution with selective features
Java
20
star
20

spring-boot-protobuf-example

Revised version of Josh Longs Spring Boot Protobuf example from 2015 https://spring.io/blog/2015/03/22/using-google-protocol-buffers-with-spring-mvc-based-rest-services
Shell
19
star
21

spring-boot-micro-frontend-example

Simple Spring Boot frontend integration with ParcelJS
Java
18
star
22

keycloak-tc-extension-playground

Example for testing Keycloak extensions in docker with testcontainers
Java
16
star
23

keycloak_mod_auth_oidc_example

Demonstrates the configuration of the mod_auth_oidc Apache Module for use with Keycloak.
PHP
14
star
24

wjax2018-spring-keycloak

Code & Slides for my "Securing Spring Apps with Keycloak" talk at WJAX 2018
Java
13
star
25

prometheus-spring-boot-starter

An unofficial spring-boot-starter for the Prometheus Monitoring System
Shell
12
star
26

spring-boot-keycloak-jwe-example

PoC: Spring Boot Keycloak Signed & Encrypted JWT Example
Java
12
star
27

keycloak-infini-kube

PoC for a Keycloak Dockerimage with service discovery via KUBE_PING
Shell
12
star
28

keycloak-extensions-talk

Talk and Slides of my talk about Keycloak Extension Development
Java
10
star
29

keycloak-opa-config-validation

PoC for Validating Keycloak Configurations with Open Policy Agent Polices
Open Policy Agent
9
star
30

custom-opa-spicedb

OPA Authzed experiments
Go
9
star
31

go-kc-example

PoC for Keycloak OIDC Support in Golang
Go
7
star
32

custom-opa-openfga

OPA OpenFGA experiments
Go
6
star
33

spring-data-in-memory-poc

Java
6
star
34

keycloak-graalvm-js-scripting-provider

GraalVM.JS based JavaScript ScriptingProvider extension for Keycloak.
Java
5
star
35

jcon2017-keycloak

Code & Slides of my SSO with Keycloak talk at JCON 2017
Java
5
star
36

spring-boot-keycloak-graphql-demo

Example for securing a Spring Boot based GraphQL app with Keycloak
Java
5
star
37

de.tutorials.training.spring311

Tutorials.de Example Demonstrating some Spring 3.1.1 Goodness
JavaScript
5
star
38

quarkus-jumpstart-talk

Java
5
star
39

spring-boot-jee-web-example

Java
4
star
40

asw-web2-examples

Examples for the Course Web2 at ASW Berufsakademie Saarland
Java
4
star
41

sd-repositories-best-practices-javaland

Code & Slides from Spring Data Repositories Best Practices Talk at JavaLand 2016
Java
4
star
42

spring-boot-custom-starter-example

Java
4
star
43

spring-boot-cdi-instance-example

Prototypic implementation of support for CDI Instance<T> backed by a Spring BeanFactory.
Java
3
star
44

zitadel-spring-boot-examples

Zitadel.ch Example Project with Spring Boot and Spring Security
Java
3
star
45

wildfly-buildpack

Ruby
3
star
46

extism-java-example

Simple example for using the java-sdk of the extism web assembly plugin system.
Java
3
star
47

acme-keycloakx-demo

FreeMarker
2
star
48

java16-panama-win-dll-demo

Demo for calling a function from a Windows 64-bit DLL with Panama's Foreign Linker API
C
2
star
49

quarkus-demo

HTML
2
star
50

js-storytelling

JavaScript
2
star
51

thomasdarimont.github.com

The GitHub Page of thomasdarimont
JavaScript
2
star
52

java-docker-training

Java
2
star
53

spring-boot-k8s-app

Example spring-boot app with custom Java Image that can be run in Kubernetes
Dockerfile
2
star
54

keycloak-13.0.1-docker-microprofile-workaround

Workaround for removed Smallrye / Microprofile components for Keycloak 13.0.x
Dockerfile
2
star
55

spring-boot-dockerized-service-example

Shell
1
star
56

jvmoa

JVM Option Analyzer - A java based tool to list jvm settings of a local or a remote jvm
Java
1
star
57

spring-boot-keycloak-actuator-example

Shell
1
star
58

keycloakify-demo-app

TypeScript
1
star
59

java-workbench

Java Workbench for trying out things in various JDKs
Java
1
star
60

spring-boot2-training

Some experiments with Spring Boot 2
Java
1
star
61

spring-boot-keycloak-server-gist

Embedded Keycloak Server in Spring Boot
Java
1
star
62

embedded-quarkus-keycloak-server-example

PoC for an embedded keycloak server with Quarkus
HTML
1
star
63

spring-boot-layered-dockerimage-with-fabric8-demo

Example for building a layered Docker Image with fabric8 Maven Plugin and Spring Boot 2.3.0+
Java
1
star
64

reified-java-demo

Java
1
star
65

spring-boot-graal-demo

Java
1
star
66

spring-boot-camel-hawt-io-example

Java
1
star
67

git-training

Training project to learn how to do distributed development using git
1
star
68

de.thomasdarimont.labs.jpa

Plain JPA Examples Repository - Mostly for reporting bugs in the persistence providers
Java
1
star
69

201905-dubjug-keycloak-talk

Notes & Slides from Keycloak talk at Dublin Java User Group 2019
1
star
70

spring-boot-thymeleaf-layout-example

Shell
1
star
71

spring-boot-tls-with-san

Simple example for x509 Client Authentication with Mutual TLS
Java
1
star
72

javaland2023-authz-for-java-devs-with-opa

Slides & Code
1
star
73

jwks-aggregator

Java
1
star
74

goexercises

Go
1
star
75

archetype-demo

Custom Maven Archtetype Example that can be fetched via jitpack
Java
1
star
76

spring-training-spring-boot-keycloak-direct-access-grant-form-auth

PoC for using Keycloaks direct access grants as backing auth mechanism for form-based auth in a traditional spring security application
Java
1
star
77

springxd-smartgrid-demo

springxd-smartgrid-demo
1
star
78

keycloak-patches

backported patches for existing Keycloak versions
Java
1
star