Hello, I am trying to implement a custom SPI, however is not working properly.
This is the error I am getting
[org.keycloak.services] (default task-11) KC-SERVICES0013: Failed authentication: java.lang.RuntimeException: Unable to find factory for Required Action: CONFIGURE_SMS_OTP did you forget to declare it in a META-INF/services file?
at org.keycloak.keycloak-services@13.0.1//org.keycloak.services.managers.AuthenticationManager.toRequiredActionFactory(AuthenticationManager.java:1327)
For the time being I am not doing anything special, just copying the default Browser flow and substitute the first Forms execution with my own SPI:
In the code I am simply wrapping the UsernameAndPassoword class
public class UsernamePasswordOrPhoneAuthenticator extends UsernamePasswordForm {
@Override
public void authenticate(AuthenticationFlowContext context) {
super.authenticate(context);
}
@Override
public void action(AuthenticationFlowContext context) {
super.action(context);
}
}
public class UsernamePasswordOrPhoneAuthenticatorFactory extends UsernamePasswordFormFactory {
public static final String PROVIDER_ID = "phone-authenticator";
public static final UsernamePasswordOrPhoneAuthenticator SINGLETON = new UsernamePasswordOrPhoneAuthenticator();
@Override
public Authenticator create(KeycloakSession session) {
return SINGLETON;
}
@Override
public String getId() {
return PROVIDER_ID;
}
@Override
public String getDisplayType() {
return "Username Password Or Phone Form";
}
@Override
public AuthenticationExecutionModel.Requirement[] getRequirementChoices() {
return new AuthenticationExecutionModel.Requirement[]{
AuthenticationExecutionModel.Requirement.REQUIRED,
};
}
@Override
public String getHelpText() {
return "Validates a username and password or phone from login form.";
}
}
Than I declare this as a service: com.gitlab.doctorworld.keycloakauthenticator.UsernamePasswordOrPhoneAuthenticatorFactory
This gets loaded correctly and is working, however after I click on login the application throws that error
I have even tried to remove the OTP part, but still the same error.
That’s it, that is all I am doing, however this is not working.