Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.keycloak.authentication.authenticators.browser.UsernamePasswordForm;
import org.keycloak.events.Details;
import org.keycloak.events.Errors;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.AuthenticatorConfigModel;
import org.keycloak.models.ModelDuplicateException;
import org.keycloak.models.UserModel;
Expand Down Expand Up @@ -41,6 +42,14 @@ public class AttributeUsernamePasswordForm extends UsernamePasswordForm implemen
*/
public static final String AUTHORIZE_ANY_PASSWORD = "authorize.any.password";

public AttributeUsernamePasswordForm() {
super();
}

public AttributeUsernamePasswordForm(KeycloakSession session) {
super(session);
}

private UserModel getUserByAttribute(AuthenticationFlowContext context, String userName) {
return getUserModel(context, userName, ATTRIBUTE_KEY, ATTRIBUTE_REGEX);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.credential.PasswordCredentialModel;
import org.keycloak.models.credential.WebAuthnCredentialModel;
import org.keycloak.provider.ProviderConfigProperty;
import org.keycloak.authentication.authenticators.browser.WebAuthnConditionalUIAuthenticator;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;

/**
* Form factory for Attribute Username Password
Expand All @@ -21,18 +25,14 @@ public class AttributeUsernamePasswordFormFactory implements AuthenticatorFactor
* Provider Id
*/
public static final String PROVIDER_ID = "attribute-username-password-form";
/**
* Singleton instance
*/
public static final AttributeUsernamePasswordForm SINGLETON = new AttributeUsernamePasswordForm();

/**
* @param session keycloak user session
* @return authenticator
*/
@Override
public Authenticator create(KeycloakSession session) {
return SINGLETON;
return new AttributeUsernamePasswordForm(session);
}

/**
Expand Down Expand Up @@ -75,6 +75,13 @@ public String getReferenceCategory() {
return PasswordCredentialModel.TYPE;
}

@Override
public Set<String> getOptionalReferenceCategories(KeycloakSession session) {
return WebAuthnConditionalUIAuthenticator.isPasskeysEnabled(session)
? Collections.singleton(WebAuthnCredentialModel.TYPE_PASSWORDLESS)
: AuthenticatorFactory.super.getOptionalReferenceCategories(session);
}

/**
* @return configurable provider
*/
Expand Down