Skip to content

an example of developed, deployed and consumed SPI implementation for keycloak

License

Notifications You must be signed in to change notification settings

witrdotnet/keycloak-hello-spi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keycloak SPI implementation example

This project is an example of developed, deployed and consumed SPI implementation for keycloak.

Keycloak Service Provider Interfaces (SPI) Keycloak is designed to cover most use-cases without requiring custom code, but we also want it to be customizable. To achieve this Keycloak has a number of Service Provider Interfaces (SPI) for which you can implement your own providers.

For more information, see Keycloak docs SPI

Start keycloak with our hello SPI implementation

  • build hello-spi java project
mvn package
  • launch docker compose
docker-compose up -d

Check deployed hello SPI

There are several ways to check deployed service:

1. Check with keycloak UI

  • browse http://localhost:8080
  • login as admin/admin
  • drop down account menu "Admin" and select "Server Info"
  • select tab "Providers"
  • search "witrdotnet" :
SPI Providers
realm-restapi-extension hello

2. Check in keycloak logs

  • Command
docker-compose logs | grep "helo-spi"
  • Result
Starting deployment of "hello-spi-1.0-SNAPSHOT.jar" (runtime-name: "hello-spi-1.0-SNAPSHOT.jar")
Deploying Keycloak provider: hello-spi-1.0-SNAPSHOT.jar
Deployed "hello-spi-1.0-SNAPSHOT.jar" (runtime-name : "hello-spi-1.0-SNAPSHOT.jar")

Consume hello service

  • Command
curl -X GET \
  -d "client_id=admin-cli" \
  -d "username=admin" \
  -d "password=admin" \
  -d "grant_type=password" \
  http://localhost:8080/auth/realms/master/witrdotnet/hello
  • Result:
Hello from realm master. I count 1 user(s).

About

an example of developed, deployed and consumed SPI implementation for keycloak

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages