keycloak-2fa-sms-authenticator/sms-authenticator
2024-04-26 08:00:41 +02:00
..
src Add missing default translations 2024-03-27 15:20:12 +01:00
pom.xml Merge pull request #78 from netzbegruenung/feature/release-2.0.6 2024-04-26 08:00:41 +02:00
README.md Improve SMS Authenticator documentation 2024-03-27 15:19:23 +01:00

Keycloak 2FA SMS Authenticator

Keycloak Authentication Provider implementation to get a 2nd-factor authentication with a OTP/code/token send via SMS with a configurable HTTPS API. It should be possible to interact with most SMS providers. Issues and pull requests to support more SMS providers are welcome.

This is a fork of a great demo implementation by @dasniko, and also takes huge chunks of code from the original authenticator provider documentation and example from Keycloak itself.

Installing

  1. Go to https://github.com/netzbegruenung/keycloak-mfa-plugins/releases and download the latest .jar file.
  2. Copy the created jar file into the providers directory of your Keycloak:
    cp netzbegruenung.keycloak-2fa-sms-authenticator.jar /path/to/keycloak/providers
    
  3. Run the build command and restart Keycloak:
    /path/to/keycloak/bin/kc.sh build [your-additional-flags]
    systemctl restart keycloak.service
    

Setup

  1. Add a new execution to the 2FA flow of your Browser flow, choose "SMS Authentication (2FA)".
  2. Make sure that you name it "sms-2fa". This is currently a hack that will hopefully be fixed. Additional executions with other names can be added. But this first execution will be used for the confirmation SMS when setting up a new phone number.
  3. Go into the config of the execution and configure the plugin so that it works with the API of your SMS proivder.
  4. Go to /admin/master/console/#/realm/authentication/required-actions and enable required actions "Phone Validation" and "Update Mobile Number"

Usage

After successfully configured the authenticator and the required actions users can set up SMS Authentication in the account console /realms/realm/account/#/account-security/signing-in by entering and confirming their phone number.

Enforce SMS 2FA

If the option Force 2FA in the SMS Authenticator config is enabled and a user has no other 2FA method already enabled, users will have to set up the SMS Authenticator.