io.phasetwo.keycloak.magic.auth.EmailOtpAuthenticatorFactory Maven / Gradle / Ivy
The newest version!
package io.phasetwo.keycloak.magic.auth;
import com.google.auto.service.AutoService;
import com.google.common.collect.ImmutableList;
import java.util.List;
import lombok.extern.jbosslog.JBossLog;
import org.keycloak.Config;
import org.keycloak.authentication.Authenticator;
import org.keycloak.authentication.AuthenticatorFactory;
import org.keycloak.models.AuthenticationExecutionModel;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.provider.ProviderConfigProperty;
@JBossLog
@AutoService(AuthenticatorFactory.class)
public class EmailOtpAuthenticatorFactory implements AuthenticatorFactory {
public static final String PROVIDER_ID = "ext-email-otp";
private static final AuthenticationExecutionModel.Requirement[] REQUIREMENT_CHOICES = {
AuthenticationExecutionModel.Requirement.REQUIRED,
AuthenticationExecutionModel.Requirement.ALTERNATIVE,
AuthenticationExecutionModel.Requirement.DISABLED
};
@Override
public Authenticator create(KeycloakSession session) {
return new EmailOtpAuthenticator();
}
@Override
public String getId() {
return PROVIDER_ID;
}
@Override
public String getReferenceCategory() {
return "alternate-auth";
}
@Override
public boolean isConfigurable() {
return false;
}
@Override
public boolean isUserSetupAllowed() {
return false;
}
@Override
public AuthenticationExecutionModel.Requirement[] getRequirementChoices() {
return REQUIREMENT_CHOICES;
}
@Override
public String getDisplayType() {
return "Email OTP";
}
@Override
public String getHelpText() {
return "Sign in with a one-time-password that will be sent to your email.";
}
@Override
public List getConfigProperties() {
return ImmutableList.of();
}
@Override
public void init(Config.Scope config) {}
@Override
public void postInit(KeycloakSessionFactory factory) {}
@Override
public void close() {}
}