use of org.keycloak.representations.idm.AuthenticationFlowRepresentation in project keycloak by keycloak.
the class AccountRestServiceTest method removeWebAuthnFlow.
private void removeWebAuthnFlow(String flowToDeleteAlias) {
List<AuthenticationFlowRepresentation> flows = testRealm().flows().getFlows();
AuthenticationFlowRepresentation flowRepresentation = AbstractAuthenticationTest.findFlowByAlias(flowToDeleteAlias, flows);
testRealm().flows().deleteFlow(flowRepresentation.getId());
}
use of org.keycloak.representations.idm.AuthenticationFlowRepresentation in project keycloak by keycloak.
the class LDAPSamlIdPInitiatedVaryingLetterCaseTest method setupIdentityProvider.
@Before
public void setupIdentityProvider() {
// Configure autolink flow
AuthenticationFlowRepresentation newFlow = new AuthenticationFlowRepresentation();
newFlow.setAlias(FLOW_AUTO_LINK);
newFlow.setDescription("Auto-link flow");
newFlow.setProviderId("basic-flow");
newFlow.setBuiltIn(false);
newFlow.setTopLevel(true);
Creator.Flow amr = Creator.create(testRealm(), newFlow);
AuthenticationExecutionInfoRepresentation exCreateUser = amr.addExecution(IdpCreateUserIfUniqueAuthenticatorFactory.PROVIDER_ID);
exCreateUser.setRequirement(Requirement.ALTERNATIVE.name());
testRealm().flows().updateExecutions(FLOW_AUTO_LINK, exCreateUser);
AuthenticationExecutionInfoRepresentation exAutoLink = amr.addExecution(IdpAutoLinkAuthenticatorFactory.PROVIDER_ID);
exAutoLink.setRequirement(Requirement.ALTERNATIVE.name());
testRealm().flows().updateExecutions(FLOW_AUTO_LINK, exAutoLink);
getCleanup().addCleanup(amr);
// Configure identity provider
IdentityProviderRepresentation idp = KcSamlBrokerConfiguration.INSTANCE.setUpIdentityProvider();
idp.getConfig().put(SAMLIdentityProviderConfig.NAME_ID_POLICY_FORMAT, JBossSAMLURIConstants.NAMEID_FORMAT_UNSPECIFIED.get());
idp.setFirstBrokerLoginFlowAlias(FLOW_AUTO_LINK);
final Creator<IdentityProviderResource> idpCreator = Creator.create(testRealm(), idp);
IdentityProviderMapperRepresentation samlNameIdMapper = new IdentityProviderMapperRepresentation();
samlNameIdMapper.setName("username-nameid-mapper");
idpAlias = idp.getAlias();
samlNameIdMapper.setIdentityProviderAlias(idpAlias);
samlNameIdMapper.setIdentityProviderMapper(UsernameTemplateMapper.PROVIDER_ID);
samlNameIdMapper.setConfig(ImmutableMap.<String, String>builder().put(IdentityProviderMapperModel.SYNC_MODE, "IMPORT").put(UsernameTemplateMapper.TEMPLATE, "${NAMEID | lowercase}").put(UsernameTemplateMapper.TARGET, Target.BROKER_ID.name()).build());
idpCreator.resource().addMapper(samlNameIdMapper);
getCleanup().addCleanup(idpCreator);
}
use of org.keycloak.representations.idm.AuthenticationFlowRepresentation in project keycloak by keycloak.
the class AbstractX509AuthenticationTest method configureFlows.
@Before
public void configureFlows() {
authMgmtResource = adminClient.realms().realm(REALM_NAME).flows();
AuthenticationFlowRepresentation browserFlow = copyBrowserFlow();
Assert.assertNotNull(browserFlow);
AuthenticationFlowRepresentation directGrantFlow = createDirectGrantFlow();
Assert.assertNotNull(directGrantFlow);
setBrowserFlow(browserFlow);
Assert.assertEquals(testRealm().toRepresentation().getBrowserFlow(), browserFlow.getAlias());
setDirectGrantFlow(directGrantFlow);
Assert.assertEquals(testRealm().toRepresentation().getDirectGrantFlow(), directGrantFlow.getAlias());
Assert.assertEquals(0, directGrantFlow.getAuthenticationExecutions().size());
// Add X509 cert authenticator to the direct grant flow
directGrantExecution = addAssertExecution(directGrantFlow, ValidateX509CertificateUsernameFactory.PROVIDER_ID, REQUIRED);
Assert.assertNotNull(directGrantExecution);
directGrantFlow = authMgmtResource.getFlow(directGrantFlow.getId());
Assert.assertNotNull(directGrantFlow.getAuthenticationExecutions());
Assert.assertEquals(1, directGrantFlow.getAuthenticationExecutions().size());
// Add X509 authenticator to the browser flow
browserExecution = addAssertExecution(browserFlow, X509ClientCertificateAuthenticatorFactory.PROVIDER_ID, ALTERNATIVE);
Assert.assertNotNull(browserExecution);
// Raise the priority of the authenticator to position it right before
// the Username/password authentication
// TODO find a better, more explicit way to specify the position
// of authenticator within the flow relative to other authenticators
authMgmtResource.raisePriority(browserExecution.getId());
// TODO raising the priority didn't generate the event?
// assertAdminEvents.assertEvent(REALM_NAME, OperationType.UPDATE, AdminEventPaths.authRaiseExecutionPath(exec.getId()));
UserRepresentation user = findUser("test-user@localhost");
userId = user.getId();
user.singleAttribute("x509_certificate_identity", "-");
user.singleAttribute("alternative_email", "test-user-altmail@localhost");
user.singleAttribute("upn", "test_upn_name@localhost");
updateUser(user);
}
use of org.keycloak.representations.idm.AuthenticationFlowRepresentation in project keycloak by keycloak.
the class AbstractX509AuthenticationTest method createFlow.
AuthenticationFlowRepresentation createFlow(AuthenticationFlowRepresentation flowRep) {
Response response = authMgmtResource.createFlow(flowRep);
try {
org.keycloak.testsuite.Assert.assertEquals(201, response.getStatus());
} finally {
response.close();
}
assertAdminEvents.assertEvent(REALM_NAME, OperationType.CREATE, AssertAdminEvents.isExpectedPrefixFollowedByUuid(AdminEventPaths.authFlowsPath()), flowRep, ResourceType.AUTH_FLOW);
for (AuthenticationFlowRepresentation flow : authMgmtResource.getFlows()) {
if (flow.getAlias().equalsIgnoreCase(flowRep.getAlias())) {
return flow;
}
}
return null;
}
use of org.keycloak.representations.idm.AuthenticationFlowRepresentation in project keycloak by keycloak.
the class AbstractX509AuthenticationTest method newFlow.
AuthenticationFlowRepresentation newFlow(String alias, String description, String providerId, boolean topLevel, boolean builtIn) {
AuthenticationFlowRepresentation flow = new AuthenticationFlowRepresentation();
flow.setAlias(alias);
flow.setDescription(description);
flow.setProviderId(providerId);
flow.setTopLevel(topLevel);
flow.setBuiltIn(builtIn);
return flow;
}
Aggregations