Search in sources :

Example 1 with FlowUtil

use of org.keycloak.testsuite.util.FlowUtil in project keycloak by keycloak.

the class BrokerRunOnServerUtil method configureBrokerFlowToReAuthenticationWithPasswordOrTotp.

// Configure the variant of firstBrokerLogin flow, which will allow to reauthenticate user with password OR totp
// TOTP will be available just if configured for the user
static void configureBrokerFlowToReAuthenticationWithPasswordOrTotp(KeycloakTestingClient testingClient, String consumerRealmName, String idpAlias, String newFlowAlias) {
    testingClient.server(consumerRealmName).run(session -> FlowUtil.inCurrentRealm(session).copyFirstBrokerLoginFlow(newFlowAlias));
    testingClient.server(consumerRealmName).run(session -> {
        AuthenticationFlowModel flowModel = FlowUtil.createFlowModel("password or otp", "basic-flow", "Flow to authenticate user with password or otp", false, true);
        FlowUtil.inCurrentRealm(session).selectFlow(newFlowAlias).inVerifyExistingAccountByReAuthentication(flowUtil -> flowUtil.clear().addAuthenticatorExecution(AuthenticationExecutionModel.Requirement.REQUIRED, IdpAutoLinkAuthenticatorFactory.PROVIDER_ID).addSubFlowExecution(flowModel, AuthenticationExecutionModel.Requirement.REQUIRED, subFlow -> subFlow.addAuthenticatorExecution(AuthenticationExecutionModel.Requirement.ALTERNATIVE, PasswordFormFactory.PROVIDER_ID).addAuthenticatorExecution(AuthenticationExecutionModel.Requirement.ALTERNATIVE, OTPFormAuthenticatorFactory.PROVIDER_ID))).usesInIdentityProvider(idpAlias);
    });
}
Also used : ClientModel(org.keycloak.models.ClientModel) RealmModel(org.keycloak.models.RealmModel) Constants(org.keycloak.models.Constants) RoleModel(org.keycloak.models.RoleModel) IdentityProviderModel(org.keycloak.models.IdentityProviderModel) UserSessionModel(org.keycloak.models.UserSessionModel) KeycloakTestingClient(org.keycloak.testsuite.client.KeycloakTestingClient) PasswordFormFactory(org.keycloak.authentication.authenticators.browser.PasswordFormFactory) OTPFormAuthenticatorFactory(org.keycloak.authentication.authenticators.browser.OTPFormAuthenticatorFactory) List(java.util.List) UserModel(org.keycloak.models.UserModel) IdpAutoLinkAuthenticatorFactory(org.keycloak.authentication.authenticators.broker.IdpAutoLinkAuthenticatorFactory) AuthenticationExecutionModel(org.keycloak.models.AuthenticationExecutionModel) AuthenticationFlowModel(org.keycloak.models.AuthenticationFlowModel) FlowUtil(org.keycloak.testsuite.util.FlowUtil) RunOnServer(org.keycloak.testsuite.runonserver.RunOnServer) Assert.assertEquals(org.junit.Assert.assertEquals) AuthenticationFlowModel(org.keycloak.models.AuthenticationFlowModel)

Aggregations

List (java.util.List)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 IdpAutoLinkAuthenticatorFactory (org.keycloak.authentication.authenticators.broker.IdpAutoLinkAuthenticatorFactory)1 OTPFormAuthenticatorFactory (org.keycloak.authentication.authenticators.browser.OTPFormAuthenticatorFactory)1 PasswordFormFactory (org.keycloak.authentication.authenticators.browser.PasswordFormFactory)1 AuthenticationExecutionModel (org.keycloak.models.AuthenticationExecutionModel)1 AuthenticationFlowModel (org.keycloak.models.AuthenticationFlowModel)1 ClientModel (org.keycloak.models.ClientModel)1 Constants (org.keycloak.models.Constants)1 IdentityProviderModel (org.keycloak.models.IdentityProviderModel)1 RealmModel (org.keycloak.models.RealmModel)1 RoleModel (org.keycloak.models.RoleModel)1 UserModel (org.keycloak.models.UserModel)1 UserSessionModel (org.keycloak.models.UserSessionModel)1 KeycloakTestingClient (org.keycloak.testsuite.client.KeycloakTestingClient)1 RunOnServer (org.keycloak.testsuite.runonserver.RunOnServer)1 FlowUtil (org.keycloak.testsuite.util.FlowUtil)1