411 AuthenticationFlowModel firstBrokerLogin =
new AuthenticationFlowModel();
413 firstBrokerLogin.setDescription(
"Actions taken after first broker login with identity provider account, which is not yet linked to any Keycloak account");
414 firstBrokerLogin.setProviderId(
"basic-flow");
415 firstBrokerLogin.setTopLevel(
true);
416 firstBrokerLogin.setBuiltIn(
true);
417 firstBrokerLogin = realm.addAuthenticationFlow(firstBrokerLogin);
419 AuthenticatorConfigModel reviewProfileConfig =
new AuthenticatorConfigModel();
421 Map<String, String> config =
new HashMap<>();
422 config.put(
"update.profile.on.first.login", IdentityProviderRepresentation.UPFLM_MISSING);
423 reviewProfileConfig.setConfig(config);
424 reviewProfileConfig = realm.addAuthenticatorConfig(reviewProfileConfig);
426 AuthenticationExecutionModel execution =
new AuthenticationExecutionModel();
427 execution.setParentFlow(firstBrokerLogin.getId());
428 execution.setRequirement(AuthenticationExecutionModel.Requirement.REQUIRED);
429 execution.setAuthenticator(
"idp-review-profile");
430 execution.setPriority(10);
431 execution.setAuthenticatorFlow(
false);
432 execution.setAuthenticatorConfig(reviewProfileConfig.getId());
433 realm.addAuthenticatorExecution(execution);
436 AuthenticatorConfigModel createUserIfUniqueConfig =
new AuthenticatorConfigModel();
438 config =
new HashMap<>();
439 config.put(
"require.password.update.after.registration",
"false");
440 createUserIfUniqueConfig.setConfig(config);
441 createUserIfUniqueConfig = realm.addAuthenticatorConfig(createUserIfUniqueConfig);
443 execution =
new AuthenticationExecutionModel();
444 execution.setParentFlow(firstBrokerLogin.getId());
445 execution.setRequirement(AuthenticationExecutionModel.Requirement.ALTERNATIVE);
446 execution.setAuthenticator(
"idp-create-user-if-unique");
447 execution.setPriority(20);
448 execution.setAuthenticatorFlow(
false);
449 execution.setAuthenticatorConfig(createUserIfUniqueConfig.getId());
450 realm.addAuthenticatorExecution(execution);
453 AuthenticationFlowModel linkExistingAccountFlow =
new AuthenticationFlowModel();
454 linkExistingAccountFlow.setTopLevel(
false);
455 linkExistingAccountFlow.setBuiltIn(
true);
457 linkExistingAccountFlow.setDescription(
"Handle what to do if there is existing account with same email/username like authenticated identity provider");
458 linkExistingAccountFlow.setProviderId(
"basic-flow");
459 linkExistingAccountFlow = realm.addAuthenticationFlow(linkExistingAccountFlow);
460 execution =
new AuthenticationExecutionModel();
461 execution.setParentFlow(firstBrokerLogin.getId());
462 execution.setRequirement(AuthenticationExecutionModel.Requirement.ALTERNATIVE);
463 execution.setFlowId(linkExistingAccountFlow.getId());
464 execution.setPriority(30);
465 execution.setAuthenticatorFlow(
true);
466 realm.addAuthenticatorExecution(execution);
468 execution =
new AuthenticationExecutionModel();
469 execution.setParentFlow(linkExistingAccountFlow.getId());
470 execution.setRequirement(AuthenticationExecutionModel.Requirement.REQUIRED);
471 execution.setAuthenticator(
"idp-confirm-link");
472 execution.setPriority(10);
473 execution.setAuthenticatorFlow(
false);
474 realm.addAuthenticatorExecution(execution);
476 execution =
new AuthenticationExecutionModel();
477 execution.setParentFlow(linkExistingAccountFlow.getId());
478 execution.setRequirement(AuthenticationExecutionModel.Requirement.ALTERNATIVE);
479 execution.setAuthenticator(
"idp-email-verification");
480 execution.setPriority(20);
481 execution.setAuthenticatorFlow(
false);
482 realm.addAuthenticatorExecution(execution);
484 AuthenticationFlowModel verifyByReauthenticationAccountFlow =
new AuthenticationFlowModel();
485 verifyByReauthenticationAccountFlow.setTopLevel(
false);
486 verifyByReauthenticationAccountFlow.setBuiltIn(
true);
487 verifyByReauthenticationAccountFlow.setAlias(
"Verify Existing Account by Re-authentication");
488 verifyByReauthenticationAccountFlow.setDescription(
"Reauthentication of existing account");
489 verifyByReauthenticationAccountFlow.setProviderId(
"basic-flow");
490 verifyByReauthenticationAccountFlow = realm.addAuthenticationFlow(verifyByReauthenticationAccountFlow);
491 execution =
new AuthenticationExecutionModel();
492 execution.setParentFlow(linkExistingAccountFlow.getId());
493 execution.setRequirement(AuthenticationExecutionModel.Requirement.ALTERNATIVE);
494 execution.setFlowId(verifyByReauthenticationAccountFlow.getId());
495 execution.setPriority(30);
496 execution.setAuthenticatorFlow(
true);
497 realm.addAuthenticatorExecution(execution);
500 execution =
new AuthenticationExecutionModel();
501 execution.setParentFlow(verifyByReauthenticationAccountFlow.getId());
502 execution.setRequirement(AuthenticationExecutionModel.Requirement.REQUIRED);
503 execution.setAuthenticator(
"idp-username-password-form");
504 execution.setPriority(10);
505 execution.setAuthenticatorFlow(
false);
506 realm.addAuthenticatorExecution(execution);
508 execution =
new AuthenticationExecutionModel();
509 execution.setParentFlow(verifyByReauthenticationAccountFlow.getId());
510 execution.setRequirement(AuthenticationExecutionModel.Requirement.OPTIONAL);
514 AuthenticationFlowModel
browserFlow = realm.getBrowserFlow();
515 if (browserFlow == null) {
516 browserFlow = realm.getFlowByAlias(DefaultAuthenticationFlows.BROWSER_FLOW);
519 List<AuthenticationExecutionModel> browserExecutions =
new LinkedList<>();
520 KeycloakModelUtils.deepFindAuthenticationExecutions(realm, browserFlow, browserExecutions);
521 for (AuthenticationExecutionModel browserExecution : browserExecutions) {
522 if (browserExecution.getAuthenticator().equals(
"auth-otp-form")) {
523 execution.setRequirement(browserExecution.getRequirement());
528 execution.setAuthenticator(
"auth-otp-form");
529 execution.setPriority(20);
530 execution.setAuthenticatorFlow(
false);
531 realm.addAuthenticatorExecution(execution);
static final String FIRST_BROKER_LOGIN_HANDLE_EXISTING_SUBFLOW
Definition: DefaultAuthenticationFlows.java:50
static final String FIRST_BROKER_LOGIN_FLOW
Definition: DefaultAuthenticationFlows.java:49
static void browserFlow(RealmModel realm)
Definition: DefaultAuthenticationFlows.java:151
static final String IDP_CREATE_UNIQUE_USER_CONFIG_ALIAS
Definition: DefaultAuthenticationFlows.java:53
static final String IDP_REVIEW_PROFILE_CONFIG_ALIAS
Definition: DefaultAuthenticationFlows.java:52