Flow
Allows for creating and managing an authentication flow within Keycloak. Authentication flows describe a sequence of actions that a user or service must perform in order to be authenticated to Keycloak. The authentication flow itself is a container for these actions, which are otherwise known as executions.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";
const realm = new keycloak.Realm("realm", {
realm: "my-realm",
enabled: true,
});
const flow = new keycloak.authentication.Flow("flow", {
realmId: realm.id,
alias: "my-flow-alias",
});
const execution = new keycloak.authentication.Execution("execution", {
realmId: realm.id,
parentFlowAlias: flow.alias,
authenticator: "identity-provider-redirector",
requirement: "REQUIRED",
});
import pulumi
import pulumi_keycloak as keycloak
realm = keycloak.Realm("realm",
realm="my-realm",
enabled=True)
flow = keycloak.authentication.Flow("flow",
realm_id=realm.id,
alias="my-flow-alias")
execution = keycloak.authentication.Execution("execution",
realm_id=realm.id,
parent_flow_alias=flow.alias,
authenticator="identity-provider-redirector",
requirement="REQUIRED")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Keycloak = Pulumi.Keycloak;
return await Deployment.RunAsync(() =>
{
var realm = new Keycloak.Realm("realm", new()
{
RealmName = "my-realm",
Enabled = true,
});
var flow = new Keycloak.Authentication.Flow("flow", new()
{
RealmId = realm.Id,
Alias = "my-flow-alias",
});
var execution = new Keycloak.Authentication.Execution("execution", new()
{
RealmId = realm.Id,
ParentFlowAlias = flow.Alias,
Authenticator = "identity-provider-redirector",
Requirement = "REQUIRED",
});
});
package main
import (
"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak"
"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak/authentication"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
realm, err := keycloak.NewRealm(ctx, "realm", &keycloak.RealmArgs{
Realm: pulumi.String("my-realm"),
Enabled: pulumi.Bool(true),
})
if err != nil {
return err
}
flow, err := authentication.NewFlow(ctx, "flow", &authentication.FlowArgs{
RealmId: realm.ID(),
Alias: pulumi.String("my-flow-alias"),
})
if err != nil {
return err
}
_, err = authentication.NewExecution(ctx, "execution", &authentication.ExecutionArgs{
RealmId: realm.ID(),
ParentFlowAlias: flow.Alias,
Authenticator: pulumi.String("identity-provider-redirector"),
Requirement: pulumi.String("REQUIRED"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.keycloak.Realm;
import com.pulumi.keycloak.RealmArgs;
import com.pulumi.keycloak.authentication.Flow;
import com.pulumi.keycloak.authentication.FlowArgs;
import com.pulumi.keycloak.authentication.Execution;
import com.pulumi.keycloak.authentication.ExecutionArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var realm = new Realm("realm", RealmArgs.builder()
.realm("my-realm")
.enabled(true)
.build());
var flow = new Flow("flow", FlowArgs.builder()
.realmId(realm.id())
.alias("my-flow-alias")
.build());
var execution = new Execution("execution", ExecutionArgs.builder()
.realmId(realm.id())
.parentFlowAlias(flow.alias())
.authenticator("identity-provider-redirector")
.requirement("REQUIRED")
.build());
}
}
resources:
realm:
type: keycloak:Realm
properties:
realm: my-realm
enabled: true
flow:
type: keycloak:authentication:Flow
properties:
realmId: ${realm.id}
alias: my-flow-alias
execution:
type: keycloak:authentication:Execution
properties:
realmId: ${realm.id}
parentFlowAlias: ${flow.alias}
authenticator: identity-provider-redirector
requirement: REQUIRED
Import
Authentication flows can be imported using the format {{realmId}}/{{authenticationFlowId}}
. The authentication flow ID is typically a GUID which is autogenerated when the flow is created via Keycloak. Unfortunately, it is not trivial to retrieve the authentication flow ID from the UI. The best way to do this is to visit the "Authentication" page in Keycloak, and use the network tab of your browser to view the response of the API call to /auth/admin/realms/${realm}/authentication/flows
, which will be a list of authentication flows. Example: bash
$ pulumi import keycloak:authentication/flow:Flow flow my-realm/e9a5641e-778c-4daf-89c0-f4ef617987d1