Generic Client Protocol Mapper
!>WARNING: This resource is deprecated and will be removed in the next major version. Please use keycloak.GenericProtocolMapper
instead. 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
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.GenericClientProtocolMapper("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.GenericClientProtocolMapper("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",
})
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.GenericClientProtocolMapper("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 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.NewGenericClientProtocolMapper(ctx, "saml_hardcode_attribute_mapper", &keycloak.GenericClientProtocolMapperArgs{
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
})
}
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()
.realm("my-realm")
.enabled(true)
.build());
var samlClient = new Client("samlClient", ClientArgs.builder()
.realmId(realm.id())
.clientId("test-client")
.build());
var samlHardcodeAttributeMapper = new GenericClientProtocolMapper("samlHardcodeAttributeMapper", GenericClientProtocolMapperArgs.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:GenericClientProtocolMapper
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
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/genericClientProtocolMapper:GenericClientProtocolMapper saml_hardcode_attribute_mapper my-realm/client/a7202154-8793-4656-b655-1dd18c181e14/71602afa-f7d1-4788-8c49-ef8fd00af0f4
Properties
The mapper's associated client scope. Cannot be used at the same time as client_id.
The name of the protocol mapper. The protocol mapper must be compatible with the specified client.