Search in sources :

Example 11 with AuthenticationFlowRepresentation

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());
}
Also used : AuthenticationFlowRepresentation(org.keycloak.representations.idm.AuthenticationFlowRepresentation)

Example 12 with AuthenticationFlowRepresentation

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);
}
Also used : IdentityProviderMapperRepresentation(org.keycloak.representations.idm.IdentityProviderMapperRepresentation) IdentityProviderResource(org.keycloak.admin.client.resource.IdentityProviderResource) AuthenticationFlowRepresentation(org.keycloak.representations.idm.AuthenticationFlowRepresentation) AuthenticationExecutionInfoRepresentation(org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation) IdentityProviderRepresentation(org.keycloak.representations.idm.IdentityProviderRepresentation) Creator(org.keycloak.testsuite.updaters.Creator) Before(org.junit.Before)

Example 13 with AuthenticationFlowRepresentation

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);
}
Also used : AuthenticationFlowRepresentation(org.keycloak.representations.idm.AuthenticationFlowRepresentation) UserRepresentation(org.keycloak.representations.idm.UserRepresentation) Before(org.junit.Before)

Example 14 with AuthenticationFlowRepresentation

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;
}
Also used : Response(javax.ws.rs.core.Response) AuthenticationFlowRepresentation(org.keycloak.representations.idm.AuthenticationFlowRepresentation)

Example 15 with AuthenticationFlowRepresentation

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;
}
Also used : AuthenticationFlowRepresentation(org.keycloak.representations.idm.AuthenticationFlowRepresentation)

Aggregations

AuthenticationFlowRepresentation (org.keycloak.representations.idm.AuthenticationFlowRepresentation)42 Test (org.junit.Test)17 HashMap (java.util.HashMap)15 Response (javax.ws.rs.core.Response)14 AuthenticationExecutionInfoRepresentation (org.keycloak.representations.idm.AuthenticationExecutionInfoRepresentation)10 AuthenticationExecutionRepresentation (org.keycloak.representations.idm.AuthenticationExecutionRepresentation)8 Before (org.junit.Before)7 RealmRepresentation (org.keycloak.representations.idm.RealmRepresentation)7 BadRequestException (javax.ws.rs.BadRequestException)5 NotFoundException (javax.ws.rs.NotFoundException)5 RealmResource (org.keycloak.admin.client.resource.RealmResource)5 ClientErrorException (javax.ws.rs.ClientErrorException)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 AuthenticationExecutionExportRepresentation (org.keycloak.representations.idm.AuthenticationExecutionExportRepresentation)4 AuthenticatorConfigRepresentation (org.keycloak.representations.idm.AuthenticatorConfigRepresentation)4 IdentityProviderRepresentation (org.keycloak.representations.idm.IdentityProviderRepresentation)4 LinkedList (java.util.LinkedList)3 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)3 AuthenticationManagementResource (org.keycloak.admin.client.resource.AuthenticationManagementResource)3 IdentityProviderResource (org.keycloak.admin.client.resource.IdentityProviderResource)2