This project provides a Keycloak user storage provider backed by an external SQL database. It exposes a subset of database columns as user attributes and synchronises changes back to that database.
mvn package
-
Build the project so the jar is available for Keycloak:
mvn package -
Start the environment:
docker compose upThis brings up Keycloak along with MariaDB and PostgreSQL using the configuration from
docker-compose.yml. Keycloak will be available athttp://localhost:8080.The initial administrator account can be customised using the environment variables
KC_BOOTSTRAP_ADMIN_USERNAMEandKC_BOOTSTRAP_ADMIN_PASSWORDdefined in the compose files.
The sql/ directory contains the scripts used to initialize the MariaDB
database. cas_schema.sql creates a table called adherents with all the
columns expected by the provider and cas_data.sql inserts two example rows.
These files are mounted into the MariaDB container via
./sql:/docker-entrypoint-initdb.d so they run automatically on the first
startup.
If you need to reset the database simply remove the mariadb_data volume and
restart the compose environment.
Execute the unit tests using Maven:
mvn test
The provider expects a Keycloak configuration file conf/user-profile.json to be mounted so
the additional attributes (ldapLogin, createdAt, isNaina, etc.) are visible in the admin
console.
The adapter maps the following attributes to database columns:
| Attribute | Column |
|---|---|
email |
mail |
firstName |
prenom |
lastName |
nom |
ldapLogin |
ldap_login |
createdAt |
created_at |
isNaina |
is_naina |
createdAt is converted to and from milliseconds since epoch when stored in Keycloak.