Providing user storage in a read-only mode, via an external PostgreSQL.
Features:
- Use JDBC driver to provide user data for keycloak via external database.
- Password hashing for authentication with hex hash digest algorithm.
- User's field in the database are automatically mapped as user's attribute in the client scope.
- Group and role mapping are using internal keycloak mapping.
- Beneficiary Authentication use multiple custom card numbers combined with phone number and password as credential.
- SMS OTP authentication with simulation mode and AWS SNS.
- Email OTP authentication.
- Use sample.sql as sample data, import into existing database.
- Install OpenSPP user federation provider by copy file from
dist
folder to keycloak'sproviders
folder. - Create or use existing realm.
- Login as admin.
- Go to User federation menu.
- Select OpenSPP user provider.
- Enter name, JDBC url, username, password.
- Save and it is ready to use.
- Verify: go to Users menu, show all users by using
*
as the search keyword.
- Create new Authentication flow
- Add step
- Search for Beneficiary Authentication and add to the flow
- Select
Requirement
asRequire
- Click on the cog icon to open Settings dialog.
- Enter alias and update settings to fit your usage.
- Create or update existing client
- Go to Advanced tab and Select above authentication flow in the section
Authentication flow overrides
- Add SMS or Email OTP as a new step in the authentication flow.
- Select
Requirement
asRequire
- Click on the cog icon to open Settings dialog.
- Enter alias and update settings to fit your usage.
- SenderId: enter sender id to use as SMS sender.
- Optional: turn on simulation mode to print the OTP code to console log instead of send SMS.
- Optional: enter email in
Simulation email
to receive email with OTP code in simulation code.
Note: you need setup AWS SNS credential to send SMS. Check this document.
# Compile and package
mvn compile package
# Or clean compile
mvn clean compile package
Copy all files from dist
folder to keycloak's providers folder and run following command to build.
/opt/keycloak/bin/kc.sh build
# Create a new interactive keycloak container, replace PASSWORD with your
docker run -it --rm --name keycloak-dev -p 8080:8080 \
-e KEYCLOAK_ADMIN=admin \
-e KEYCLOAK_ADMIN_PASSWORD=PASSWORD \
--entrypoint=/bin/bash quay.io/keycloak/keycloak:21.0.1
# OS shell
# Copy OpenSPP user storage provider to keycloak's container
docker cp dist/. keycloak-dev:/opt/keycloak/providers/
# Keycloak container shell
/opt/keycloak/bin/kc.sh start-dev
To deploy new build you need to stop the keycloak server and copy new files from dist folder into /opt/keycloak/providers/
and start the server again.