Search code examples
keycloakredhat-sso

Is is posible to use a custom authentication logic in Keycloak?


I have configured Keycloak with LDAP User Federation. When a user wants to login into an application, he is redirected to the Keycloak login page, enters the uid/pwd and is authenticated using an LDAP bind.

This isn't enough for my requirements since I would like to implement some custom authentication logic, e.g:

public boolean authenticate(String uid, String pwd) {

    //1.- validate against LDAP
    //2.- do some other validations
    return validationResult;
} 

How could I include my own authentication logic into Keycloak?


Solution

  • To add a new authentication mechanism, you implement the Authentication SPI. This is described in the Server Development guide > Authentication SPI section.