1. Packages
  2. Keycloak
  3. API Docs
  4. GenericClientProtocolMapper
Keycloak v5.3.1 published on Monday, Mar 11, 2024 by Pulumi

keycloak.GenericClientProtocolMapper

Explore with Pulumi AI

keycloak logo
Keycloak v5.3.1 published on Monday, Mar 11, 2024 by Pulumi

    # keycloak.GenericClientProtocolMapper

    Allows for creating and managing protocol mapper 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

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

    Argument Reference

    The following arguments are supported:

    • realm_id - (Required) The realm this protocol mapper exists within.
    • client_id - (Required) The client this protocol mapper is attached to.
    • name - (Required) The display name of this protocol mapper in the GUI.
    • protocol - (Required) The type of client (either openid-connect or saml). The type must match the type of the client.
    • protocol_mapper - (Required) The name of the protocol mapper. The protocol mapper must be compatible with the specified client.
    • config - (Required) A map with key / value pairs for configuring the protocol mapper. The supported keys depends on the protocol mapper.

    Import

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

    Example:

    $ terraform import keycloak_generic_client_protocol_mapper.saml_hardcode_attribute_mapper my-realm/client/a7202154-8793-4656-b655-1dd18c181e14/71602afa-f7d1-4788-8c49-ef8fd00af0f4
    

    Create GenericClientProtocolMapper Resource

    new GenericClientProtocolMapper(name: string, args: GenericClientProtocolMapperArgs, opts?: CustomResourceOptions);
    @overload
    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)
    @overload
    def GenericClientProtocolMapper(resource_name: str,
                                    args: GenericClientProtocolMapperArgs,
                                    opts: Optional[ResourceOptions] = None)
    func NewGenericClientProtocolMapper(ctx *Context, name string, args GenericClientProtocolMapperArgs, opts ...ResourceOption) (*GenericClientProtocolMapper, error)
    public GenericClientProtocolMapper(string name, GenericClientProtocolMapperArgs args, CustomResourceOptions? opts = null)
    public GenericClientProtocolMapper(String name, GenericClientProtocolMapperArgs args)
    public GenericClientProtocolMapper(String name, GenericClientProtocolMapperArgs args, CustomResourceOptions options)
    
    type: keycloak:GenericClientProtocolMapper
    properties: # The arguments to resource properties.
    options: # 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.
    resource_name str
    The unique name of the resource.
    args GenericClientProtocolMapperArgs
    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 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.
    name String
    The unique name of the resource.
    args GenericClientProtocolMapperArgs
    The arguments to resource properties.
    options 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 Architecture and Concepts docs.

    Inputs

    The GenericClientProtocolMapper resource accepts the following input properties:

    Config Dictionary<string, object>
    Protocol string
    The protocol of the client (openid-connect / saml).
    ProtocolMapper string
    The type of the protocol mapper.
    RealmId string
    The realm id where the associated client or client scope exists.
    ClientId string
    The mapper's associated client. Cannot be used at the same time as client_scope_id.
    ClientScopeId string
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    Name string
    A human-friendly name that will appear in the Keycloak console.
    Config map[string]interface{}
    Protocol string
    The protocol of the client (openid-connect / saml).
    ProtocolMapper string
    The type of the protocol mapper.
    RealmId string
    The realm id where the associated client or client scope exists.
    ClientId string
    The mapper's associated client. Cannot be used at the same time as client_scope_id.
    ClientScopeId string
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    Name string
    A human-friendly name that will appear in the Keycloak console.
    config Map<String,Object>
    protocol String
    The protocol of the client (openid-connect / saml).
    protocolMapper String
    The type of the protocol mapper.
    realmId String
    The realm id where the associated client or client scope exists.
    clientId String
    The mapper's associated client. Cannot be used at the same time as client_scope_id.
    clientScopeId String
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    name String
    A human-friendly name that will appear in the Keycloak console.
    config {[key: string]: any}
    protocol string
    The protocol of the client (openid-connect / saml).
    protocolMapper string
    The type of the protocol mapper.
    realmId string
    The realm id where the associated client or client scope exists.
    clientId string
    The mapper's associated client. Cannot be used at the same time as client_scope_id.
    clientScopeId string
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    name string
    A human-friendly name that will appear in the Keycloak console.
    config Mapping[str, Any]
    protocol str
    The protocol of the client (openid-connect / saml).
    protocol_mapper str
    The type of the protocol mapper.
    realm_id str
    The realm id where the associated client or client scope exists.
    client_id str
    The mapper's associated client. Cannot be used at the same time as client_scope_id.
    client_scope_id str
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    name str
    A human-friendly name that will appear in the Keycloak console.
    config Map<Any>
    protocol String
    The protocol of the client (openid-connect / saml).
    protocolMapper String
    The type of the protocol mapper.
    realmId String
    The realm id where the associated client or client scope exists.
    clientId String
    The mapper's associated client. Cannot be used at the same time as client_scope_id.
    clientScopeId String
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    name String
    A human-friendly name that will appear in the Keycloak console.

    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 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 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)
    public static GenericClientProtocolMapper get(String name, Output<String> id, GenericClientProtocolMapperState 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 mapper's associated client. Cannot be used at the same time as client_scope_id.
    ClientScopeId string
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    Config Dictionary<string, object>
    Name string
    A human-friendly name that will appear in the Keycloak console.
    Protocol string
    The protocol of the client (openid-connect / saml).
    ProtocolMapper string
    The type of the protocol mapper.
    RealmId string
    The realm id where the associated client or client scope exists.
    ClientId string
    The mapper's associated client. Cannot be used at the same time as client_scope_id.
    ClientScopeId string
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    Config map[string]interface{}
    Name string
    A human-friendly name that will appear in the Keycloak console.
    Protocol string
    The protocol of the client (openid-connect / saml).
    ProtocolMapper string
    The type of the protocol mapper.
    RealmId string
    The realm id where the associated client or client scope exists.
    clientId String
    The mapper's associated client. Cannot be used at the same time as client_scope_id.
    clientScopeId String
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    config Map<String,Object>
    name String
    A human-friendly name that will appear in the Keycloak console.
    protocol String
    The protocol of the client (openid-connect / saml).
    protocolMapper String
    The type of the protocol mapper.
    realmId String
    The realm id where the associated client or client scope exists.
    clientId string
    The mapper's associated client. Cannot be used at the same time as client_scope_id.
    clientScopeId string
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    config {[key: string]: any}
    name string
    A human-friendly name that will appear in the Keycloak console.
    protocol string
    The protocol of the client (openid-connect / saml).
    protocolMapper string
    The type of the protocol mapper.
    realmId string
    The realm id where the associated client or client scope exists.
    client_id str
    The mapper's associated client. Cannot be used at the same time as client_scope_id.
    client_scope_id str
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    config Mapping[str, Any]
    name str
    A human-friendly name that will appear in the Keycloak console.
    protocol str
    The protocol of the client (openid-connect / saml).
    protocol_mapper str
    The type of the protocol mapper.
    realm_id str
    The realm id where the associated client or client scope exists.
    clientId String
    The mapper's associated client. Cannot be used at the same time as client_scope_id.
    clientScopeId String
    The mapper's associated client scope. Cannot be used at the same time as client_id.
    config Map<Any>
    name String
    A human-friendly name that will appear in the Keycloak console.
    protocol String
    The protocol of the client (openid-connect / saml).
    protocolMapper String
    The type of the protocol mapper.
    realmId String
    The realm id where the associated client or client scope exists.

    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.1 published on Monday, Mar 11, 2024 by Pulumi