flow alias lookup
This commit is contained in:
parent
c52d16da6d
commit
fa99b5415d
10 changed files with 58 additions and 16 deletions
|
@ -187,6 +187,7 @@ public interface RealmModel extends RoleContainerModel {
|
|||
void setSmtpConfig(Map<String, String> smtpConfig);
|
||||
|
||||
List<AuthenticationFlowModel> getAuthenticationFlows();
|
||||
AuthenticationFlowModel getFlowByAlias(String alias);
|
||||
AuthenticationFlowModel addAuthenticationFlow(AuthenticationFlowModel model);
|
||||
AuthenticationFlowModel getAuthenticationFlowById(String id);
|
||||
void removeAuthenticationFlow(AuthenticationFlowModel model);
|
||||
|
|
|
@ -90,7 +90,7 @@ public class DefaultAuthenticationFlows {
|
|||
execution.setRequirement(AuthenticationExecutionModel.Requirement.REQUIRED);
|
||||
execution.setAuthenticator(password.getId());
|
||||
execution.setPriority(11);
|
||||
execution.setUserSetupAllowed(false);
|
||||
execution.setUserSetupAllowed(true);
|
||||
execution.setAutheticatorFlow(false);
|
||||
realm.addAuthenticatorExecution(execution);
|
||||
|
||||
|
|
|
@ -1213,6 +1213,19 @@ public class RealmAdapter implements RealmModel {
|
|||
return models;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public AuthenticationFlowModel getFlowByAlias(String alias) {
|
||||
for (AuthenticationFlowModel flow : getAuthenticationFlows()) {
|
||||
if (flow.getAlias().equals(alias)) {
|
||||
return flow;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected AuthenticationFlowModel entityToModel(AuthenticationFlowEntity entity) {
|
||||
AuthenticationFlowModel model = new AuthenticationFlowModel();
|
||||
model.setId(entity.getId());
|
||||
|
|
|
@ -1024,6 +1024,16 @@ public class RealmAdapter implements RealmModel {
|
|||
return models;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationFlowModel getFlowByAlias(String alias) {
|
||||
for (AuthenticationFlowModel flow : getAuthenticationFlows()) {
|
||||
if (flow.getAlias().equals(alias)) {
|
||||
return flow;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationFlowModel addAuthenticationFlow(AuthenticationFlowModel model) {
|
||||
getDelegateForUpdate();
|
||||
|
|
|
@ -1519,6 +1519,17 @@ public class RealmAdapter implements RealmModel {
|
|||
return models;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationFlowModel getFlowByAlias(String alias) {
|
||||
for (AuthenticationFlowModel flow : getAuthenticationFlows()) {
|
||||
if (flow.getAlias().equals(alias)) {
|
||||
return flow;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected AuthenticationFlowModel entityToModel(AuthenticationFlowEntity entity) {
|
||||
AuthenticationFlowModel model = new AuthenticationFlowModel();
|
||||
model.setId(entity.getId());
|
||||
|
|
|
@ -1244,6 +1244,17 @@ public class RealmAdapter extends AbstractMongoAdapter<MongoRealmEntity> impleme
|
|||
return models;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationFlowModel getFlowByAlias(String alias) {
|
||||
for (AuthenticationFlowModel flow : getAuthenticationFlows()) {
|
||||
if (flow.getAlias().equals(alias)) {
|
||||
return flow;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected AuthenticationFlowModel entityToModel(AuthenticationFlowEntity entity) {
|
||||
AuthenticationFlowModel model = new AuthenticationFlowModel();
|
||||
model.setId(entity.getId());
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.keycloak.models.IdentityProviderModel;
|
|||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.UserSessionModel;
|
||||
import org.keycloak.models.utils.DefaultAuthenticationFlows;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
import org.keycloak.protocol.oidc.utils.RedirectUtils;
|
||||
import org.keycloak.saml.common.constants.GeneralConstants;
|
||||
|
@ -335,14 +336,8 @@ public class SamlService {
|
|||
return buildRedirectToIdentityProvider(identityProvider.getAlias(), new ClientSessionCode(realm, clientSession).getCode() );
|
||||
}
|
||||
}
|
||||
|
||||
String flowId = null;
|
||||
for (AuthenticationFlowModel flow : realm.getAuthenticationFlows()) {
|
||||
if (flow.getAlias().equals("browser")) {
|
||||
flowId = flow.getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
AuthenticationFlowModel flow = realm.getFlowByAlias(DefaultAuthenticationFlows.BROWSER_FLOW);
|
||||
String flowId = flow.getId();
|
||||
AuthenticationProcessor processor = new AuthenticationProcessor();
|
||||
processor.setClientSession(clientSession)
|
||||
.setFlowId(flowId)
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.net.URI;
|
|||
public class AbstractFormAuthenticator {
|
||||
|
||||
public static final String LOGIN_FORM_ACTION = "login_form";
|
||||
public static final String REGISTRATION_FORM_ACTION = "registration_form";
|
||||
public static final String ACTION = "action";
|
||||
|
||||
protected boolean isAction(AuthenticatorContext context, String action) {
|
||||
|
|
|
@ -33,6 +33,10 @@ public class LoginFormUsernameAuthenticator extends AbstractFormAuthenticator im
|
|||
|
||||
@Override
|
||||
public void authenticate(AuthenticatorContext context) {
|
||||
if (isAction(context, REGISTRATION_FORM_ACTION) && context.getUser() != null) {
|
||||
context.success();
|
||||
return;
|
||||
}
|
||||
if (!isAction(context, LOGIN_FORM_ACTION)) {
|
||||
MultivaluedMap<String, String> formData = new MultivaluedMapImpl<>();
|
||||
String loginHint = context.getClientSession().getNote(OIDCLoginProtocol.LOGIN_HINT_PARAM);
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.keycloak.models.IdentityProviderModel;
|
|||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.models.RealmModel;
|
||||
import org.keycloak.models.RequiredCredentialModel;
|
||||
import org.keycloak.models.utils.DefaultAuthenticationFlows;
|
||||
import org.keycloak.models.utils.KeycloakModelUtils;
|
||||
import org.keycloak.protocol.oidc.OIDCLoginProtocol;
|
||||
import org.keycloak.protocol.oidc.utils.RedirectUtils;
|
||||
|
@ -259,13 +260,8 @@ public class AuthorizationEndpoint {
|
|||
}
|
||||
clientSession.setNote(Details.AUTH_TYPE, CODE_AUTH_TYPE);
|
||||
|
||||
String flowId = null;
|
||||
for (AuthenticationFlowModel flow : realm.getAuthenticationFlows()) {
|
||||
if (flow.getAlias().equals("browser")) {
|
||||
flowId = flow.getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
AuthenticationFlowModel flow = realm.getFlowByAlias(DefaultAuthenticationFlows.BROWSER_FLOW);
|
||||
String flowId = flow.getId();
|
||||
AuthenticationProcessor processor = new AuthenticationProcessor();
|
||||
processor.setClientSession(clientSession)
|
||||
.setFlowId(flowId)
|
||||
|
|
Loading…
Reference in a new issue