Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

GenericClientProtocolMapper

Allows for creating and managing protocol mappers for both types of clients (openid-connect and saml) within Keycloak.

There are two uses cases for using this resource: * If you implemented a custom protocol mapper, this resource can be used to configure it * If the provider doesn’t support a particular protocol mapper, this resource can be used instead.

Due to the generic nature of this mapper, it is less user-friendly and more prone to configuration errors. Therefore, if possible, a specific mapper should be used.

Example Usage

using Pulumi;
using Keycloak = Pulumi.Keycloak;

class MyStack : Stack
{
    public MyStack()
    {
        var realm = new Keycloak.Realm("realm", new Keycloak.RealmArgs
        {
            Realm = "my-realm",
            Enabled = true,
        });
        var samlClient = new Keycloak.Saml.Client("samlClient", new Keycloak.Saml.ClientArgs
        {
            RealmId = realm.Id,
            ClientId = "test-client",
        });
        var samlHardcodeAttributeMapper = new Keycloak.GenericClientProtocolMapper("samlHardcodeAttributeMapper", new Keycloak.GenericClientProtocolMapperArgs
        {
            RealmId = realm.Id,
            ClientId = samlClient.Id,
            Protocol = "saml",
            ProtocolMapper = "saml-hardcode-attribute-mapper",
            Config = 
            {
                { "attribute.name", "name" },
                { "attribute.nameformat", "Basic" },
                { "attribute.value", "value" },
                { "friendly.name", "display name" },
            },
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-keycloak/sdk/v3/go/keycloak"
    "github.com/pulumi/pulumi-keycloak/sdk/v3/go/keycloak/saml"
    "github.com/pulumi/pulumi/sdk/v2/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
        }
        samlClient, err := saml.NewClient(ctx, "samlClient", &saml.ClientArgs{
            RealmId:  realm.ID(),
            ClientId: pulumi.String("test-client"),
        })
        if err != nil {
            return err
        }
        _, err = keycloak.NewGenericClientProtocolMapper(ctx, "samlHardcodeAttributeMapper", &keycloak.GenericClientProtocolMapperArgs{
            RealmId:        realm.ID(),
            ClientId:       samlClient.ID(),
            Protocol:       pulumi.String("saml"),
            ProtocolMapper: pulumi.String("saml-hardcode-attribute-mapper"),
            Config: pulumi.StringMap{
                "attribute.name":       pulumi.String("name"),
                "attribute.nameformat": pulumi.String("Basic"),
                "attribute.value":      pulumi.String("value"),
                "friendly.name":        pulumi.String("display name"),
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    realm="my-realm",
    enabled=True)
saml_client = keycloak.saml.Client("samlClient",
    realm_id=realm.id,
    client_id="test-client")
saml_hardcode_attribute_mapper = keycloak.GenericClientProtocolMapper("samlHardcodeAttributeMapper",
    realm_id=realm.id,
    client_id=saml_client.id,
    protocol="saml",
    protocol_mapper="saml-hardcode-attribute-mapper",
    config={
        "attribute.name": "name",
        "attribute.nameformat": "Basic",
        "attribute.value": "value",
        "friendly.name": "display name",
    })
import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";

const realm = new keycloak.Realm("realm", {
    realm: "my-realm",
    enabled: true,
});
const samlClient = new keycloak.saml.Client("samlClient", {
    realmId: realm.id,
    clientId: "test-client",
});
const samlHardcodeAttributeMapper = new keycloak.GenericClientProtocolMapper("samlHardcodeAttributeMapper", {
    realmId: realm.id,
    clientId: samlClient.id,
    protocol: "saml",
    protocolMapper: "saml-hardcode-attribute-mapper",
    config: {
        "attribute.name": "name",
        "attribute.nameformat": "Basic",
        "attribute.value": "value",
        "friendly.name": "display name",
    },
});

Create a GenericClientProtocolMapper Resource

new GenericClientProtocolMapper(name: string, args: GenericClientProtocolMapperArgs, opts?: CustomResourceOptions);
def GenericClientProtocolMapper(resource_name: str, opts: Optional[ResourceOptions] = None, client_id: Optional[str] = None, client_scope_id: Optional[str] = None, config: Optional[Mapping[str, Any]] = None, name: Optional[str] = None, protocol: Optional[str] = None, protocol_mapper: Optional[str] = None, realm_id: Optional[str] = None)
func NewGenericClientProtocolMapper(ctx *Context, name string, args GenericClientProtocolMapperArgs, opts ...ResourceOption) (*GenericClientProtocolMapper, error)
public GenericClientProtocolMapper(string name, GenericClientProtocolMapperArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args GenericClientProtocolMapperArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args GenericClientProtocolMapperArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args GenericClientProtocolMapperArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

GenericClientProtocolMapper Resource Properties

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

Inputs

The GenericClientProtocolMapper resource accepts the following input properties:

Config Dictionary<string, object>

A map with key / value pairs for configuring the protocol mapper. The supported keys depends on the protocol mapper.

Protocol string

The type of client (either openid-connect or saml). The type must match the type of the client.

ProtocolMapper string

The name of the protocol mapper. The protocol mapper must be compatible with the specified client.

RealmId string

The realm this protocol mapper exists within.

ClientId string

The client this protocol mapper is attached to.

ClientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

Name string

The display name of this protocol mapper in the GUI.

Config map[string]interface{}

A map with key / value pairs for configuring the protocol mapper. The supported keys depends on the protocol mapper.

Protocol string

The type of client (either openid-connect or saml). The type must match the type of the client.

ProtocolMapper string

The name of the protocol mapper. The protocol mapper must be compatible with the specified client.

RealmId string

The realm this protocol mapper exists within.

ClientId string

The client this protocol mapper is attached to.

ClientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

Name string

The display name of this protocol mapper in the GUI.

config {[key: string]: any}

A map with key / value pairs for configuring the protocol mapper. The supported keys depends on the protocol mapper.

protocol string

The type of client (either openid-connect or saml). The type must match the type of the client.

protocolMapper string

The name of the protocol mapper. The protocol mapper must be compatible with the specified client.

realmId string

The realm this protocol mapper exists within.

clientId string

The client this protocol mapper is attached to.

clientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

name string

The display name of this protocol mapper in the GUI.

config Mapping[str, Any]

A map with key / value pairs for configuring the protocol mapper. The supported keys depends on the protocol mapper.

protocol str

The type of client (either openid-connect or saml). The type must match the type of the client.

protocol_mapper str

The name of the protocol mapper. The protocol mapper must be compatible with the specified client.

realm_id str

The realm this protocol mapper exists within.

client_id str

The client this protocol mapper is attached to.

client_scope_id str

The mapper’s associated client scope. Cannot be used at the same time as client_id.

name str

The display name of this protocol mapper in the GUI.

Outputs

All input properties are implicitly available as output properties. Additionally, the GenericClientProtocolMapper 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 str
The provider-assigned unique ID for this managed resource.

Look up an Existing GenericClientProtocolMapper Resource

Get an existing GenericClientProtocolMapper 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?: GenericClientProtocolMapperState, opts?: CustomResourceOptions): GenericClientProtocolMapper
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, client_id: Optional[str] = None, client_scope_id: Optional[str] = None, config: Optional[Mapping[str, Any]] = None, name: Optional[str] = None, protocol: Optional[str] = None, protocol_mapper: Optional[str] = None, realm_id: Optional[str] = None) -> GenericClientProtocolMapper
func GetGenericClientProtocolMapper(ctx *Context, name string, id IDInput, state *GenericClientProtocolMapperState, opts ...ResourceOption) (*GenericClientProtocolMapper, error)
public static GenericClientProtocolMapper Get(string name, Input<string> id, GenericClientProtocolMapperState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

ClientId string

The client this protocol mapper is attached to.

ClientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

Config Dictionary<string, object>

A map with key / value pairs for configuring the protocol mapper. The supported keys depends on the protocol mapper.

Name string

The display name of this protocol mapper in the GUI.

Protocol string

The type of client (either openid-connect or saml). The type must match the type of the client.

ProtocolMapper string

The name of the protocol mapper. The protocol mapper must be compatible with the specified client.

RealmId string

The realm this protocol mapper exists within.

ClientId string

The client this protocol mapper is attached to.

ClientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

Config map[string]interface{}

A map with key / value pairs for configuring the protocol mapper. The supported keys depends on the protocol mapper.

Name string

The display name of this protocol mapper in the GUI.

Protocol string

The type of client (either openid-connect or saml). The type must match the type of the client.

ProtocolMapper string

The name of the protocol mapper. The protocol mapper must be compatible with the specified client.

RealmId string

The realm this protocol mapper exists within.

clientId string

The client this protocol mapper is attached to.

clientScopeId string

The mapper’s associated client scope. Cannot be used at the same time as client_id.

config {[key: string]: any}

A map with key / value pairs for configuring the protocol mapper. The supported keys depends on the protocol mapper.

name string

The display name of this protocol mapper in the GUI.

protocol string

The type of client (either openid-connect or saml). The type must match the type of the client.

protocolMapper string

The name of the protocol mapper. The protocol mapper must be compatible with the specified client.

realmId string

The realm this protocol mapper exists within.

client_id str

The client this protocol mapper is attached to.

client_scope_id str

The mapper’s associated client scope. Cannot be used at the same time as client_id.

config Mapping[str, Any]

A map with key / value pairs for configuring the protocol mapper. The supported keys depends on the protocol mapper.

name str

The display name of this protocol mapper in the GUI.

protocol str

The type of client (either openid-connect or saml). The type must match the type of the client.

protocol_mapper str

The name of the protocol mapper. The protocol mapper must be compatible with the specified client.

realm_id str

The realm this protocol mapper exists within.

Import

Protocol mappers can be imported using the following format{{realm_id}}/client/{{client_keycloak_id}}/{{protocol_mapper_id}} Examplebash

 $ pulumi import keycloak:index/genericClientProtocolMapper:GenericClientProtocolMapper saml_hardcode_attribute_mapper my-realm/client/a7202154-8793-4656-b655-1dd18c181e14/71602afa-f7d1-4788-8c49-ef8fd00af0f4

Package Details

Repository
https://github.com/pulumi/pulumi-keycloak
License
Apache-2.0
Notes
This Pulumi package is based on the keycloak Terraform Provider.