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

AttributeImporterIdentityProviderMapper

Allows for creating and managing an attribute importer identity provider mapper within Keycloak.

The attribute importer mapper can be used to map attributes from externally defined users to attributes or properties of the imported Keycloak user: - For the OIDC identity provider, this will map a claim on the ID or access token to an attribute for the imported Keycloak user. - For the SAML identity provider, this will map a SAML attribute found within the assertion to an attribute for the imported Keycloak user. - For social identity providers, this will map a JSON field from the user profile to an attribute for the imported Keycloak user.

If you are using Keycloak 10 or higher, you will need to specify the extra_config argument in order to define a syncMode for the mapper.

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 oidcIdentityProvider = new Keycloak.Oidc.IdentityProvider("oidcIdentityProvider", new Keycloak.Oidc.IdentityProviderArgs
        {
            Realm = realm.Id,
            Alias = "oidc",
            AuthorizationUrl = "https://example.com/auth",
            TokenUrl = "https://example.com/token",
            ClientId = "example_id",
            ClientSecret = "example_token",
            DefaultScopes = "openid random profile",
        });
        var oidcAttributeImporterIdentityProviderMapper = new Keycloak.AttributeImporterIdentityProviderMapper("oidcAttributeImporterIdentityProviderMapper", new Keycloak.AttributeImporterIdentityProviderMapperArgs
        {
            Realm = realm.Id,
            ClaimName = "my-email-claim",
            IdentityProviderAlias = oidcIdentityProvider.Alias,
            UserAttribute = "email",
            ExtraConfig = 
            {
                { "syncMode", "INHERIT" },
            },
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-keycloak/sdk/v3/go/keycloak"
    "github.com/pulumi/pulumi-keycloak/sdk/v3/go/keycloak/oidc"
    "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
        }
        oidcIdentityProvider, err := oidc.NewIdentityProvider(ctx, "oidcIdentityProvider", &oidc.IdentityProviderArgs{
            Realm:            realm.ID(),
            Alias:            pulumi.String("oidc"),
            AuthorizationUrl: pulumi.String("https://example.com/auth"),
            TokenUrl:         pulumi.String("https://example.com/token"),
            ClientId:         pulumi.String("example_id"),
            ClientSecret:     pulumi.String("example_token"),
            DefaultScopes:    pulumi.String("openid random profile"),
        })
        if err != nil {
            return err
        }
        _, err = keycloak.NewAttributeImporterIdentityProviderMapper(ctx, "oidcAttributeImporterIdentityProviderMapper", &keycloak.AttributeImporterIdentityProviderMapperArgs{
            Realm:                 realm.ID(),
            ClaimName:             pulumi.String("my-email-claim"),
            IdentityProviderAlias: oidcIdentityProvider.Alias,
            UserAttribute:         pulumi.String("email"),
            ExtraConfig: pulumi.StringMap{
                "syncMode": pulumi.String("INHERIT"),
            },
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    realm="my-realm",
    enabled=True)
oidc_identity_provider = keycloak.oidc.IdentityProvider("oidcIdentityProvider",
    realm=realm.id,
    alias="oidc",
    authorization_url="https://example.com/auth",
    token_url="https://example.com/token",
    client_id="example_id",
    client_secret="example_token",
    default_scopes="openid random profile")
oidc_attribute_importer_identity_provider_mapper = keycloak.AttributeImporterIdentityProviderMapper("oidcAttributeImporterIdentityProviderMapper",
    realm=realm.id,
    claim_name="my-email-claim",
    identity_provider_alias=oidc_identity_provider.alias,
    user_attribute="email",
    extra_config={
        "syncMode": "INHERIT",
    })
import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";

const realm = new keycloak.Realm("realm", {
    realm: "my-realm",
    enabled: true,
});
const oidcIdentityProvider = new keycloak.oidc.IdentityProvider("oidcIdentityProvider", {
    realm: realm.id,
    alias: "oidc",
    authorizationUrl: "https://example.com/auth",
    tokenUrl: "https://example.com/token",
    clientId: "example_id",
    clientSecret: "example_token",
    defaultScopes: "openid random profile",
});
const oidcAttributeImporterIdentityProviderMapper = new keycloak.AttributeImporterIdentityProviderMapper("oidcAttributeImporterIdentityProviderMapper", {
    realm: realm.id,
    claimName: "my-email-claim",
    identityProviderAlias: oidcIdentityProvider.alias,
    userAttribute: "email",
    extraConfig: {
        syncMode: "INHERIT",
    },
});

Create a AttributeImporterIdentityProviderMapper Resource

new AttributeImporterIdentityProviderMapper(name: string, args: AttributeImporterIdentityProviderMapperArgs, opts?: CustomResourceOptions);
def AttributeImporterIdentityProviderMapper(resource_name: str, opts: Optional[ResourceOptions] = None, attribute_friendly_name: Optional[str] = None, attribute_name: Optional[str] = None, claim_name: Optional[str] = None, extra_config: Optional[Mapping[str, Any]] = None, identity_provider_alias: Optional[str] = None, name: Optional[str] = None, realm: Optional[str] = None, user_attribute: Optional[str] = None)
func NewAttributeImporterIdentityProviderMapper(ctx *Context, name string, args AttributeImporterIdentityProviderMapperArgs, opts ...ResourceOption) (*AttributeImporterIdentityProviderMapper, error)
public AttributeImporterIdentityProviderMapper(string name, AttributeImporterIdentityProviderMapperArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args AttributeImporterIdentityProviderMapperArgs
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 AttributeImporterIdentityProviderMapperArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args AttributeImporterIdentityProviderMapperArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

AttributeImporterIdentityProviderMapper Resource Properties

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

Inputs

The AttributeImporterIdentityProviderMapper resource accepts the following input properties:

IdentityProviderAlias string

The alias of the associated identity provider.

Realm string

The name of the realm.

UserAttribute string

The user attribute or property name to store the mapped result.

AttributeFriendlyName string

For SAML based providers, this is the friendly name of the attribute to search for in the assertion. Conflicts with attribute_name.

AttributeName string

For SAML based providers, this is the name of the attribute to search for in the assertion. Conflicts with attribute_friendly_name.

ClaimName string

For OIDC based providers, this is the name of the claim to use.

ExtraConfig Dictionary<string, object>

Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.

Name string

The name of the mapper.

IdentityProviderAlias string

The alias of the associated identity provider.

Realm string

The name of the realm.

UserAttribute string

The user attribute or property name to store the mapped result.

AttributeFriendlyName string

For SAML based providers, this is the friendly name of the attribute to search for in the assertion. Conflicts with attribute_name.

AttributeName string

For SAML based providers, this is the name of the attribute to search for in the assertion. Conflicts with attribute_friendly_name.

ClaimName string

For OIDC based providers, this is the name of the claim to use.

ExtraConfig map[string]interface{}

Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.

Name string

The name of the mapper.

identityProviderAlias string

The alias of the associated identity provider.

realm string

The name of the realm.

userAttribute string

The user attribute or property name to store the mapped result.

attributeFriendlyName string

For SAML based providers, this is the friendly name of the attribute to search for in the assertion. Conflicts with attribute_name.

attributeName string

For SAML based providers, this is the name of the attribute to search for in the assertion. Conflicts with attribute_friendly_name.

claimName string

For OIDC based providers, this is the name of the claim to use.

extraConfig {[key: string]: any}

Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.

name string

The name of the mapper.

identity_provider_alias str

The alias of the associated identity provider.

realm str

The name of the realm.

user_attribute str

The user attribute or property name to store the mapped result.

attribute_friendly_name str

For SAML based providers, this is the friendly name of the attribute to search for in the assertion. Conflicts with attribute_name.

attribute_name str

For SAML based providers, this is the name of the attribute to search for in the assertion. Conflicts with attribute_friendly_name.

claim_name str

For OIDC based providers, this is the name of the claim to use.

extra_config Mapping[str, Any]

Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.

name str

The name of the mapper.

Outputs

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

Get an existing AttributeImporterIdentityProviderMapper 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?: AttributeImporterIdentityProviderMapperState, opts?: CustomResourceOptions): AttributeImporterIdentityProviderMapper
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, attribute_friendly_name: Optional[str] = None, attribute_name: Optional[str] = None, claim_name: Optional[str] = None, extra_config: Optional[Mapping[str, Any]] = None, identity_provider_alias: Optional[str] = None, name: Optional[str] = None, realm: Optional[str] = None, user_attribute: Optional[str] = None) -> AttributeImporterIdentityProviderMapper
func GetAttributeImporterIdentityProviderMapper(ctx *Context, name string, id IDInput, state *AttributeImporterIdentityProviderMapperState, opts ...ResourceOption) (*AttributeImporterIdentityProviderMapper, error)
public static AttributeImporterIdentityProviderMapper Get(string name, Input<string> id, AttributeImporterIdentityProviderMapperState? 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:

AttributeFriendlyName string

For SAML based providers, this is the friendly name of the attribute to search for in the assertion. Conflicts with attribute_name.

AttributeName string

For SAML based providers, this is the name of the attribute to search for in the assertion. Conflicts with attribute_friendly_name.

ClaimName string

For OIDC based providers, this is the name of the claim to use.

ExtraConfig Dictionary<string, object>

Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.

IdentityProviderAlias string

The alias of the associated identity provider.

Name string

The name of the mapper.

Realm string

The name of the realm.

UserAttribute string

The user attribute or property name to store the mapped result.

AttributeFriendlyName string

For SAML based providers, this is the friendly name of the attribute to search for in the assertion. Conflicts with attribute_name.

AttributeName string

For SAML based providers, this is the name of the attribute to search for in the assertion. Conflicts with attribute_friendly_name.

ClaimName string

For OIDC based providers, this is the name of the claim to use.

ExtraConfig map[string]interface{}

Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.

IdentityProviderAlias string

The alias of the associated identity provider.

Name string

The name of the mapper.

Realm string

The name of the realm.

UserAttribute string

The user attribute or property name to store the mapped result.

attributeFriendlyName string

For SAML based providers, this is the friendly name of the attribute to search for in the assertion. Conflicts with attribute_name.

attributeName string

For SAML based providers, this is the name of the attribute to search for in the assertion. Conflicts with attribute_friendly_name.

claimName string

For OIDC based providers, this is the name of the claim to use.

extraConfig {[key: string]: any}

Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.

identityProviderAlias string

The alias of the associated identity provider.

name string

The name of the mapper.

realm string

The name of the realm.

userAttribute string

The user attribute or property name to store the mapped result.

attribute_friendly_name str

For SAML based providers, this is the friendly name of the attribute to search for in the assertion. Conflicts with attribute_name.

attribute_name str

For SAML based providers, this is the name of the attribute to search for in the assertion. Conflicts with attribute_friendly_name.

claim_name str

For OIDC based providers, this is the name of the claim to use.

extra_config Mapping[str, Any]

Key/value attributes to add to the identity provider mapper model that is persisted to Keycloak. This can be used to extend the base model with new Keycloak features.

identity_provider_alias str

The alias of the associated identity provider.

name str

The name of the mapper.

realm str

The name of the realm.

user_attribute str

The user attribute or property name to store the mapped result.

Import

Identity provider mappers can be imported using the format {{realm_id}}/{{idp_alias}}/{{idp_mapper_id}}, where idp_alias is the identity provider alias, and idp_mapper_id is the unique ID that Keycloak assigns to the mapper upon creation. This value can be found in the URI when editing this mapper in the GUI, and is typically a GUID. Examplebash

 $ pulumi import keycloak:index/attributeImporterIdentityProviderMapper:AttributeImporterIdentityProviderMapper test_mapper my-realm/my-mapper/f446db98-7133-4e30-b18a-3d28fde7ca1b

Package Details

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