Keycloak

v4.11.0 published on Thursday, Aug 4, 2022 by Pulumi

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

using Pulumi;
using Keycloak = Pulumi.Keycloak;

class MyStack : Stack
{
    public MyStack()
    {
        var realm = new Keycloak.Realm("realm", new Keycloak.RealmArgs
        {
            RealmName = "my-realm",
            Enabled = true,
        });
        var flow = new Keycloak.Authentication.Flow("flow", new Keycloak.Authentication.FlowArgs
        {
            RealmId = realm.Id,
            Alias = "my-flow-alias",
        });
        var execution = new Keycloak.Authentication.Execution("execution", new Keycloak.Authentication.ExecutionArgs
        {
            RealmId = realm.Id,
            ParentFlowAlias = flow.Alias,
            Authenticator = "identity-provider-redirector",
            Requirement = "REQUIRED",
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-keycloak/sdk/v4/go/keycloak"
	"github.com/pulumi/pulumi-keycloak/sdk/v4/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());

    }
}
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")
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",
});
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

Create a Flow Resource

new Flow(name: string, args: FlowArgs, opts?: CustomResourceOptions);
@overload
def Flow(resource_name: str,
         opts: Optional[ResourceOptions] = None,
         alias: Optional[str] = None,
         description: Optional[str] = None,
         provider_id: Optional[str] = None,
         realm_id: Optional[str] = None)
@overload
def Flow(resource_name: str,
         args: FlowArgs,
         opts: Optional[ResourceOptions] = None)
func NewFlow(ctx *Context, name string, args FlowArgs, opts ...ResourceOption) (*Flow, error)
public Flow(string name, FlowArgs args, CustomResourceOptions? opts = null)
public Flow(String name, FlowArgs args)
public Flow(String name, FlowArgs args, CustomResourceOptions options)
type: keycloak:authentication:Flow
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args FlowArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args FlowArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args FlowArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args FlowArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args FlowArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Flow Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The Flow resource accepts the following input properties:

Alias string

The alias for this authentication flow.

RealmId string

The realm that the authentication flow exists in.

Description string

A description for the authentication flow.

ProviderId string

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

Alias string

The alias for this authentication flow.

RealmId string

The realm that the authentication flow exists in.

Description string

A description for the authentication flow.

ProviderId string

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

alias String

The alias for this authentication flow.

realmId String

The realm that the authentication flow exists in.

description String

A description for the authentication flow.

providerId String

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

alias string

The alias for this authentication flow.

realmId string

The realm that the authentication flow exists in.

description string

A description for the authentication flow.

providerId string

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

alias str

The alias for this authentication flow.

realm_id str

The realm that the authentication flow exists in.

description str

A description for the authentication flow.

provider_id str

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

alias String

The alias for this authentication flow.

realmId String

The realm that the authentication flow exists in.

description String

A description for the authentication flow.

providerId String

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

Outputs

All input properties are implicitly available as output properties. Additionally, the Flow resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up an Existing Flow Resource

Get an existing Flow resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: FlowState, opts?: CustomResourceOptions): Flow
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        alias: Optional[str] = None,
        description: Optional[str] = None,
        provider_id: Optional[str] = None,
        realm_id: Optional[str] = None) -> Flow
func GetFlow(ctx *Context, name string, id IDInput, state *FlowState, opts ...ResourceOption) (*Flow, error)
public static Flow Get(string name, Input<string> id, FlowState? state, CustomResourceOptions? opts = null)
public static Flow get(String name, Output<String> id, FlowState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Alias string

The alias for this authentication flow.

Description string

A description for the authentication flow.

ProviderId string

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

RealmId string

The realm that the authentication flow exists in.

Alias string

The alias for this authentication flow.

Description string

A description for the authentication flow.

ProviderId string

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

RealmId string

The realm that the authentication flow exists in.

alias String

The alias for this authentication flow.

description String

A description for the authentication flow.

providerId String

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

realmId String

The realm that the authentication flow exists in.

alias string

The alias for this authentication flow.

description string

A description for the authentication flow.

providerId string

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

realmId string

The realm that the authentication flow exists in.

alias str

The alias for this authentication flow.

description str

A description for the authentication flow.

provider_id str

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

realm_id str

The realm that the authentication flow exists in.

alias String

The alias for this authentication flow.

description String

A description for the authentication flow.

providerId String

The type of authentication flow to create. Valid choices include basic-flow and client-flow. Defaults to basic-flow.

realmId String

The realm that the authentication flow exists in.

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. Examplebash

 $ pulumi import keycloak:authentication/flow:Flow flow my-realm/e9a5641e-778c-4daf-89c0-f4ef617987d1

Package Details

Repository
https://github.com/pulumi/pulumi-keycloak
License
Apache-2.0
Notes

This Pulumi package is based on the keycloak Terraform Provider.