1. Packages
  2. Keycloak Provider
  3. API Docs
  4. GenericProtocolMapper
Keycloak v5.3.5 published on Wednesday, Oct 16, 2024 by Pulumi

keycloak.GenericProtocolMapper

Explore with Pulumi AI

keycloak logo
Keycloak v5.3.5 published on Wednesday, Oct 16, 2024 by Pulumi

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

    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 samlClient = new keycloak.saml.Client("saml_client", {
        realmId: realm.id,
        clientId: "test-client",
    });
    const samlHardcodeAttributeMapper = new keycloak.GenericProtocolMapper("saml_hardcode_attribute_mapper", {
        realmId: realm.id,
        clientId: samlClient.id,
        name: "test-mapper",
        protocol: "saml",
        protocolMapper: "saml-hardcode-attribute-mapper",
        config: {
            "attribute.name": "name",
            "attribute.nameformat": "Basic",
            "attribute.value": "value",
            "friendly.name": "display name",
        },
    });
    
    import pulumi
    import pulumi_keycloak as keycloak
    
    realm = keycloak.Realm("realm",
        realm="my-realm",
        enabled=True)
    saml_client = keycloak.saml.Client("saml_client",
        realm_id=realm.id,
        client_id="test-client")
    saml_hardcode_attribute_mapper = keycloak.GenericProtocolMapper("saml_hardcode_attribute_mapper",
        realm_id=realm.id,
        client_id=saml_client.id,
        name="test-mapper",
        protocol="saml",
        protocol_mapper="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/v5/go/keycloak"
    	"github.com/pulumi/pulumi-keycloak/sdk/v5/go/keycloak/saml"
    	"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
    		}
    		samlClient, err := saml.NewClient(ctx, "saml_client", &saml.ClientArgs{
    			RealmId:  realm.ID(),
    			ClientId: pulumi.String("test-client"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = keycloak.NewGenericProtocolMapper(ctx, "saml_hardcode_attribute_mapper", &keycloak.GenericProtocolMapperArgs{
    			RealmId:        realm.ID(),
    			ClientId:       samlClient.ID(),
    			Name:           pulumi.String("test-mapper"),
    			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
    	})
    }
    
    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 samlClient = new Keycloak.Saml.Client("saml_client", new()
        {
            RealmId = realm.Id,
            ClientId = "test-client",
        });
    
        var samlHardcodeAttributeMapper = new Keycloak.GenericProtocolMapper("saml_hardcode_attribute_mapper", new()
        {
            RealmId = realm.Id,
            ClientId = samlClient.Id,
            Name = "test-mapper",
            Protocol = "saml",
            ProtocolMapper = "saml-hardcode-attribute-mapper",
            Config = 
            {
                { "attribute.name", "name" },
                { "attribute.nameformat", "Basic" },
                { "attribute.value", "value" },
                { "friendly.name", "display name" },
            },
        });
    
    });
    
    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.saml.Client;
    import com.pulumi.keycloak.saml.ClientArgs;
    import com.pulumi.keycloak.GenericProtocolMapper;
    import com.pulumi.keycloak.GenericProtocolMapperArgs;
    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 samlClient = new Client("samlClient", ClientArgs.builder()
                .realmId(realm.id())
                .clientId("test-client")
                .build());
    
            var samlHardcodeAttributeMapper = new GenericProtocolMapper("samlHardcodeAttributeMapper", GenericProtocolMapperArgs.builder()
                .realmId(realm.id())
                .clientId(samlClient.id())
                .name("test-mapper")
                .protocol("saml")
                .protocolMapper("saml-hardcode-attribute-mapper")
                .config(Map.ofEntries(
                    Map.entry("attribute.name", "name"),
                    Map.entry("attribute.nameformat", "Basic"),
                    Map.entry("attribute.value", "value"),
                    Map.entry("friendly.name", "display name")
                ))
                .build());
    
        }
    }
    
    resources:
      realm:
        type: keycloak:Realm
        properties:
          realm: my-realm
          enabled: true
      samlClient:
        type: keycloak:saml:Client
        name: saml_client
        properties:
          realmId: ${realm.id}
          clientId: test-client
      samlHardcodeAttributeMapper:
        type: keycloak:GenericProtocolMapper
        name: saml_hardcode_attribute_mapper
        properties:
          realmId: ${realm.id}
          clientId: ${samlClient.id}
          name: test-mapper
          protocol: saml
          protocolMapper: saml-hardcode-attribute-mapper
          config:
            attribute.name: name
            attribute.nameformat: Basic
            attribute.value: value
            friendly.name: display name
    

    Create GenericProtocolMapper Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new GenericProtocolMapper(name: string, args: GenericProtocolMapperArgs, opts?: CustomResourceOptions);
    @overload
    def GenericProtocolMapper(resource_name: str,
                              args: GenericProtocolMapperArgs,
                              opts: Optional[ResourceOptions] = None)
    
    @overload
    def GenericProtocolMapper(resource_name: str,
                              opts: Optional[ResourceOptions] = None,
                              config: Optional[Mapping[str, str]] = None,
                              protocol: Optional[str] = None,
                              protocol_mapper: Optional[str] = None,
                              realm_id: Optional[str] = None,
                              client_id: Optional[str] = None,
                              client_scope_id: Optional[str] = None,
                              name: Optional[str] = None)
    func NewGenericProtocolMapper(ctx *Context, name string, args GenericProtocolMapperArgs, opts ...ResourceOption) (*GenericProtocolMapper, error)
    public GenericProtocolMapper(string name, GenericProtocolMapperArgs args, CustomResourceOptions? opts = null)
    public GenericProtocolMapper(String name, GenericProtocolMapperArgs args)
    public GenericProtocolMapper(String name, GenericProtocolMapperArgs args, CustomResourceOptions options)
    
    type: keycloak:GenericProtocolMapper
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args GenericProtocolMapperArgs
    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 GenericProtocolMapperArgs
    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 GenericProtocolMapperArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GenericProtocolMapperArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GenericProtocolMapperArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var genericProtocolMapperResource = new Keycloak.GenericProtocolMapper("genericProtocolMapperResource", new()
    {
        Config = 
        {
            { "string", "string" },
        },
        Protocol = "string",
        ProtocolMapper = "string",
        RealmId = "string",
        ClientId = "string",
        ClientScopeId = "string",
        Name = "string",
    });
    
    example, err := keycloak.NewGenericProtocolMapper(ctx, "genericProtocolMapperResource", &keycloak.GenericProtocolMapperArgs{
    	Config: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	Protocol:       pulumi.String("string"),
    	ProtocolMapper: pulumi.String("string"),
    	RealmId:        pulumi.String("string"),
    	ClientId:       pulumi.String("string"),
    	ClientScopeId:  pulumi.String("string"),
    	Name:           pulumi.String("string"),
    })
    
    var genericProtocolMapperResource = new GenericProtocolMapper("genericProtocolMapperResource", GenericProtocolMapperArgs.builder()
        .config(Map.of("string", "string"))
        .protocol("string")
        .protocolMapper("string")
        .realmId("string")
        .clientId("string")
        .clientScopeId("string")
        .name("string")
        .build());
    
    generic_protocol_mapper_resource = keycloak.GenericProtocolMapper("genericProtocolMapperResource",
        config={
            "string": "string",
        },
        protocol="string",
        protocol_mapper="string",
        realm_id="string",
        client_id="string",
        client_scope_id="string",
        name="string")
    
    const genericProtocolMapperResource = new keycloak.GenericProtocolMapper("genericProtocolMapperResource", {
        config: {
            string: "string",
        },
        protocol: "string",
        protocolMapper: "string",
        realmId: "string",
        clientId: "string",
        clientScopeId: "string",
        name: "string",
    });
    
    type: keycloak:GenericProtocolMapper
    properties:
        clientId: string
        clientScopeId: string
        config:
            string: string
        name: string
        protocol: string
        protocolMapper: string
        realmId: string
    

    GenericProtocolMapper Resource Properties

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

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The GenericProtocolMapper resource accepts the following input properties:

    Config Dictionary<string, string>
    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 ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    Name string
    The display name of this protocol mapper in the GUI.
    Config map[string]string
    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 ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    Name string
    The display name of this protocol mapper in the GUI.
    config Map<String,String>
    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 ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    name String
    The display name of this protocol mapper in the GUI.
    config {[key: string]: string}
    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 ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId string
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    name string
    The display name of this protocol mapper in the GUI.
    config Mapping[str, str]
    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 ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    client_scope_id str
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    name str
    The display name of this protocol mapper in the GUI.
    config Map<String>
    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 ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    name String
    The display name of this protocol mapper in the GUI.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the GenericProtocolMapper 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 Existing GenericProtocolMapper Resource

    Get an existing GenericProtocolMapper 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?: GenericProtocolMapperState, opts?: CustomResourceOptions): GenericProtocolMapper
    @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, str]] = None,
            name: Optional[str] = None,
            protocol: Optional[str] = None,
            protocol_mapper: Optional[str] = None,
            realm_id: Optional[str] = None) -> GenericProtocolMapper
    func GetGenericProtocolMapper(ctx *Context, name string, id IDInput, state *GenericProtocolMapperState, opts ...ResourceOption) (*GenericProtocolMapper, error)
    public static GenericProtocolMapper Get(string name, Input<string> id, GenericProtocolMapperState? state, CustomResourceOptions? opts = null)
    public static GenericProtocolMapper get(String name, Output<String> id, GenericProtocolMapperState 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:
    ClientId string
    The ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    Config Dictionary<string, string>
    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 ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    ClientScopeId string
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    Config map[string]string
    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 ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    config Map<String,String>
    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 ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId string
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    config {[key: string]: string}
    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 ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    client_scope_id str
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    config Mapping[str, str]
    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.
    clientId String
    The ID of the client this protocol mapper should be added to. Conflicts with client_scope_id. This argument is required if client_scope_id is not set.
    clientScopeId String
    The ID of the client scope this protocol mapper should be added to. Conflicts with client_id. This argument is required if client_id is not set.
    config Map<String>
    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.

    Import

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

    Example:

    bash

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

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Keycloak pulumi/pulumi-keycloak
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the keycloak Terraform Provider.
    keycloak logo
    Keycloak v5.3.5 published on Wednesday, Oct 16, 2024 by Pulumi