This module extends Keycloak's authentication workflows by integrating demographic validation and PIN-based authentication. It includes custom authenticators, form actions, credential providers, and services to validate demographic data and secure user access using a PIN.
- Demographic Authentication: Validates user demographic data during registration or login.
- PIN Authentication: Allows users to authenticate using a secure PIN.
- Custom Authenticators: Implements authentication logic for both demographic verification and PIN entry.
- Credential Management: Supports PIN storage and validation through Keycloak's credential framework.
- Integration with External Services: Enables validation of demographic data via external APIs.
- Configurable Authentication Flows: Admins can integrate these authenticators into Keycloak's authentication workflows.
Handles communication with external verification systems to validate user demographic information.
Example:
DemographicVerificationServiceImpl
: Implements external demographic validation.
Handles authentication logic for validating demographic information and PINs during authentication workflows.
Examples:
DemographicAuthenticatorImpl
: Validates demographic data and integrates withDemographicVerificationService
.PinAuthenticator
: Validates user-entered PINs.
Responsible for creating instances of authenticators and providing necessary dependencies.
Examples:
DemographicAuthenticatorFactory
: InstantiatesDemographicAuthenticatorImpl
.PinAuthenticatorFactory
: InstantiatesPinAuthenticator
.
Defines additional processing steps for user interactions with forms in Keycloak.
Example:
DemographicRegistrationFormAction
: Collects and processes demographic data during user registration.
Manages PIN storage, retrieval, and validation within Keycloak's credential framework.
Example:
PinCredentialProvider
: Handles PIN storage and validation.PinCredentialProviderFactory
: Factory for creatingPinCredentialProvider
instances.
Required actions are prompts that users must complete to continue authentication.
Example:
PinRequiredAction
: Forces users to set up a PIN if they don’t have one.
Allows users to authenticate using a token link received via email.
Examples:
TokenAuthenticator
: Validates user tokens and identifies users.TokenAuthenticatorFactory
: Factory for creating token authenticators.UserTokenGenerator
: Generates and assigns authentication tokens to users.
DemographicAuthenticatorImpl
: Handles demographic validation workflows during authentication.DemographicAuthenticatorFactory
: Manages demographic authenticator instances.DemographicVerificationService
: Defines the contract for verifying demographic data.DemographicVerificationServiceImpl
: Implements verification logic.DemographicRegistrationFormAction
: Processes demographic data during user registration.
PinAuthenticator
: Validates user-entered PINs.PinAuthenticatorFactory
: Creates instances ofPinAuthenticator
.PinCredentialModel
: Represents stored PIN credentials.PinCredentialProvider
: Handles PIN storage and validation.PinCredentialProviderFactory
: Factory forPinCredentialProvider
.PinRequiredAction
: Forces users to set up a PIN if missing.
TokenAuthenticator
: Authenticates users based on a token received via email.TokenAuthenticatorFactory
: Factory for creatingTokenAuthenticator
instances.UserTokenGenerator
: Generates unique, non-expiring login tokens.
- Build the module using Gradle:
./gradlew build
- Ensure all dependencies are properly resolved before deployment.
- Copy the compiled JAR file to the
providers
directory of your Keycloak server. - Add the following settings to your Keycloak configuration:
-Dkeycloak.profile.feature.registration-form-action=enabled
- Restart the Keycloak server to apply changes.
- Use the Keycloak admin console to add the appropriate authenticators or form actions to authentication flows.
- Configure the PIN and token authentication settings as needed.
- Set the baseUrl for DemographicVerificationService via Keycloak's authentication flow configuration.
To integrate demographic and PIN authentication into Keycloak:
- Add
DemographicAuthenticatorFactory
,PinAuthenticatorFactory
, orTokenAuthenticatorFactory
to your authentication flow. - Configure the
baseUrl
property inDemographicAuthenticatorFactory
to point to the external verification service. - Enable
PinRequiredAction
to ensure users set up a PIN. - Customize form templates for demographic and PIN input.
- Deploy and test the authentication process.