AttributeImporterIdentityProviderMapper

class AttributeImporterIdentityProviderMapper : KotlinCustomResource

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

import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";
const realm = new keycloak.Realm("realm", {
realm: "my-realm",
enabled: true,
});
const oidc = new keycloak.oidc.IdentityProvider("oidc", {
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("oidc", {
realm: realm.id,
name: "email-attribute-importer",
claimName: "my-email-claim",
identityProviderAlias: oidc.alias,
userAttribute: "email",
extraConfig: {
syncMode: "INHERIT",
},
});
import pulumi
import pulumi_keycloak as keycloak
realm = keycloak.Realm("realm",
realm="my-realm",
enabled=True)
oidc = keycloak.oidc.IdentityProvider("oidc",
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("oidc",
realm=realm.id,
name="email-attribute-importer",
claim_name="my-email-claim",
identity_provider_alias=oidc.alias,
user_attribute="email",
extra_config={
"syncMode": "INHERIT",
})
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 oidc = new Keycloak.Oidc.IdentityProvider("oidc", new()
{
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("oidc", new()
{
Realm = realm.Id,
Name = "email-attribute-importer",
ClaimName = "my-email-claim",
IdentityProviderAlias = oidc.Alias,
UserAttribute = "email",
ExtraConfig =
{
{ "syncMode", "INHERIT" },
},
});
});
package main
import (
"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak"
"github.com/pulumi/pulumi-keycloak/sdk/v6/go/keycloak/oidc"
"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
}
oidc, err := oidc.NewIdentityProvider(ctx, "oidc", &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, "oidc", &keycloak.AttributeImporterIdentityProviderMapperArgs{
Realm: realm.ID(),
Name: pulumi.String("email-attribute-importer"),
ClaimName: pulumi.String("my-email-claim"),
IdentityProviderAlias: oidc.Alias,
UserAttribute: pulumi.String("email"),
ExtraConfig: pulumi.StringMap{
"syncMode": pulumi.String("INHERIT"),
},
})
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.oidc.IdentityProvider;
import com.pulumi.keycloak.oidc.IdentityProviderArgs;
import com.pulumi.keycloak.AttributeImporterIdentityProviderMapper;
import com.pulumi.keycloak.AttributeImporterIdentityProviderMapperArgs;
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 oidc = new IdentityProvider("oidc", IdentityProviderArgs.builder()
.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")
.build());
var oidcAttributeImporterIdentityProviderMapper = new AttributeImporterIdentityProviderMapper("oidcAttributeImporterIdentityProviderMapper", AttributeImporterIdentityProviderMapperArgs.builder()
.realm(realm.id())
.name("email-attribute-importer")
.claimName("my-email-claim")
.identityProviderAlias(oidc.alias())
.userAttribute("email")
.extraConfig(Map.of("syncMode", "INHERIT"))
.build());
}
}
resources:
realm:
type: keycloak:Realm
properties:
realm: my-realm
enabled: true
oidc:
type: keycloak:oidc:IdentityProvider
properties:
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
oidcAttributeImporterIdentityProviderMapper:
type: keycloak:AttributeImporterIdentityProviderMapper
name: oidc
properties:
realm: ${realm.id}
name: email-attribute-importer
claimName: my-email-claim
identityProviderAlias: ${oidc.alias}
userAttribute: email
extraConfig:
syncMode: INHERIT

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. Example: bash

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

Properties

Link copied to clipboard

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

Link copied to clipboard
val attributeName: Output<String>?

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

Link copied to clipboard
val claimName: Output<String>?

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

Link copied to clipboard
val extraConfig: Output<Map<String, String>>?

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.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard

The alias of the associated identity provider.

Link copied to clipboard
val name: Output<String>

The name of the mapper.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val realm: Output<String>

The name of the realm.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard
val userAttribute: Output<String>

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