Required action to verify email by code
This Keycloak plugin adds a required action to verify email by code.
- Send code on your email
- Verify email by code
The version 23.0.x of this plugin is compatible with Keycloak 23.0.x
and higher.
Download a release (*.jar file) that works with your Keycloak version from the list of releases.
Copy the jar to the providers
folder and execute the following command:
${kc.home.dir}/bin/kc.sh build
You can also clone the Github Repository and install the plugin locally.
For Docker-based setups mount or copy the jar to /opt/keycloak/providers
.
You may want to check docker-compose.yml as an example.
Verify required action is deploy in keycloak. Got to {keycloak url}/admin/master/console/#/master/providers.
Once the installation is complete, the Verify Email by code
required action appears in "
authentication/required-actions" on your realm. Register and enable "VERIFY_EMAIL_CODE" and disable "VERIFY_EMAIL"
Once enabled, you can add the following action on user edit page:
You can override individual templates in your own theme. To create a custom email message for the mytheme theme copy themes/base/email/email-verification-with-code.ftl (in keycloak theme) to themes/mytheme/email/
To create a custom email verify form for the mytheme theme copy template login-verify-email-code.ftl to themes/mytheme/login
Verify email code is generated using org.keycloak.common.util.RandomString
. By default generated code will be 8 characters long and will use alphanumeric symbols. You may customize this behavior using SPI configuration in your standalone.xml
file:
- property
code-length
is a numeric value representing the number of symbols, defaults to8
- property
code-symbols
is a string value listing all accepted symbols, defaults toRandomString.alphanum
e.g. configure action to generate a code of 6 digits :
bin/kc.[sh|bat] start --spi-required-action-VERIFY_EMAIL_CODE-code-length=6 --spi-required-action-VERIFY_EMAIL_CODE-code-symbols=0123456789