UserAttributeProtocolMapper

# keycloak.openid.UserAttributeProtocolMapper

Allows for creating and managing user attribute protocol mappers within Keycloak.

User attribute protocol mappers allow you to map custom attributes defined for a user within Keycloak to a claim in a token. Protocol mappers can be defined for a single client, or they can be defined for a client scope which can be shared between multiple different clients.

Example Usage (Client)

import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";

const realm = new keycloak.Realm("realm", {
    enabled: true,
    realm: "my-realm",
});
const openidClient = new keycloak.openid.Client("openid_client", {
    accessType: "CONFIDENTIAL",
    clientId: "test-client",
    enabled: true,
    realmId: realm.id,
    validRedirectUris: ["http://localhost:8080/openid-callback"],
});
const userAttributeMapper = new keycloak.openid.UserAttributeProtocolMapper("user_attribute_mapper", {
    claimName: "bar",
    clientId: openidClient.id,
    realmId: realm.id,
    userAttribute: "foo",
});
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    enabled=True,
    realm="my-realm")
openid_client = keycloak.openid.Client("openidClient",
    access_type="CONFIDENTIAL",
    client_id="test-client",
    enabled=True,
    realm_id=realm.id,
    valid_redirect_uris=["http://localhost:8080/openid-callback"])
user_attribute_mapper = keycloak.openid.UserAttributeProtocolMapper("userAttributeMapper",
    claim_name="bar",
    client_id=openid_client.id,
    realm_id=realm.id,
    user_attribute="foo")
using Pulumi;
using Keycloak = Pulumi.Keycloak;

class MyStack : Stack
{
    public MyStack()
    {
        var realm = new Keycloak.Realm("realm", new Keycloak.RealmArgs
        {
            Enabled = true,
            Realm = "my-realm",
        });
        var openidClient = new Keycloak.OpenId.Client("openidClient", new Keycloak.OpenId.ClientArgs
        {
            AccessType = "CONFIDENTIAL",
            ClientId = "test-client",
            Enabled = true,
            RealmId = realm.Id,
            ValidRedirectUris = 
            {
                "http://localhost:8080/openid-callback",
            },
        });
        var userAttributeMapper = new Keycloak.OpenId.UserAttributeProtocolMapper("userAttributeMapper", new Keycloak.OpenId.UserAttributeProtocolMapperArgs
        {
            ClaimName = "bar",
            ClientId = openidClient.Id,
            RealmId = realm.Id,
            UserAttribute = "foo",
        });
    }

}

Example Usage (Client Scope)

import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";

const realm = new keycloak.Realm("realm", {
    enabled: true,
    realm: "my-realm",
});
const clientScope = new keycloak.openid.ClientScope("client_scope", {
    realmId: realm.id,
});
const userAttributeMapper = new keycloak.openid.UserAttributeProtocolMapper("user_attribute_mapper", {
    claimName: "bar",
    clientScopeId: clientScope.id,
    realmId: realm.id,
    userAttribute: "foo",
});
import pulumi
import pulumi_keycloak as keycloak

realm = keycloak.Realm("realm",
    enabled=True,
    realm="my-realm")
client_scope = keycloak.openid.ClientScope("clientScope", realm_id=realm.id)
user_attribute_mapper = keycloak.openid.UserAttributeProtocolMapper("userAttributeMapper",
    claim_name="bar",
    client_scope_id=client_scope.id,
    realm_id=realm.id,
    user_attribute="foo")
using Pulumi;
using Keycloak = Pulumi.Keycloak;

class MyStack : Stack
{
    public MyStack()
    {
        var realm = new Keycloak.Realm("realm", new Keycloak.RealmArgs
        {
            Enabled = true,
            Realm = "my-realm",
        });
        var clientScope = new Keycloak.OpenId.ClientScope("clientScope", new Keycloak.OpenId.ClientScopeArgs
        {
            RealmId = realm.Id,
        });
        var userAttributeMapper = new Keycloak.OpenId.UserAttributeProtocolMapper("userAttributeMapper", new Keycloak.OpenId.UserAttributeProtocolMapperArgs
        {
            ClaimName = "bar",
            ClientScopeId = clientScope.Id,
            RealmId = realm.Id,
            UserAttribute = "foo",
        });
    }

}

Argument Reference

The following arguments are supported:

  • realm_id - (Required) The realm this protocol mapper exists within.
  • client_id - (Required if client_scope_id is not specified) The client this protocol mapper is attached to.
  • client_scope_id - (Required if client_id is not specified) The client scope this protocol mapper is attached to.
  • name - (Required) The display name of this protocol mapper in the GUI.
  • user_attribute - (Required) The custom user attribute to map a claim for.
  • claim_name - (Required) The name of the claim to insert into a token.
  • claim_value_type - (Optional) The claim type used when serializing JSON tokens. Can be one of String, long, int, or boolean. Defaults to String.
  • multivalued - (Optional) Indicates whether this attribute is a single value or an array of values. Defaults to false.
  • add_to_id_token - (Optional) Indicates if the attribute should be added as a claim to the id token. Defaults to true.
  • add_to_access_token - (Optional) Indicates if the attribute should be added as a claim to the access token. Defaults to true.
  • add_to_userinfo - (Optional) Indicates if the attribute should be added as a claim to the UserInfo response body. Defaults to true.

Create a UserAttributeProtocolMapper Resource

def UserAttributeProtocolMapper(resource_name, opts=None, add_to_access_token=None, add_to_id_token=None, add_to_userinfo=None, aggregate_attributes=None, claim_name=None, claim_value_type=None, client_id=None, client_scope_id=None, multivalued=None, name=None, realm_id=None, user_attribute=None, __props__=None);
name string
The unique name of the resource.
args UserAttributeProtocolMapperArgs
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 UserAttributeProtocolMapperArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args UserAttributeProtocolMapperArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

UserAttributeProtocolMapper Resource Properties

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

Inputs

The UserAttributeProtocolMapper resource accepts the following input properties:

ClaimName string
RealmId string

The realm id where the associated client or client scope exists.

UserAttribute string
AddToAccessToken bool

Indicates if the attribute should be a claim in the access token.

AddToIdToken bool

Indicates if the attribute should be a claim in the id token.

AddToUserinfo bool

Indicates if the attribute should appear in the userinfo response body.

AggregateAttributes bool

Indicates if attribute values should be aggregated within the group attributes

ClaimValueType string

Claim type used when serializing tokens.

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.

Multivalued bool

Indicates whether this attribute is a single value or an array of values.

Name string

A human-friendly name that will appear in the Keycloak console.

ClaimName string
RealmId string

The realm id where the associated client or client scope exists.

UserAttribute string
AddToAccessToken bool

Indicates if the attribute should be a claim in the access token.

AddToIdToken bool

Indicates if the attribute should be a claim in the id token.

AddToUserinfo bool

Indicates if the attribute should appear in the userinfo response body.

AggregateAttributes bool

Indicates if attribute values should be aggregated within the group attributes

ClaimValueType string

Claim type used when serializing tokens.

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.

Multivalued bool

Indicates whether this attribute is a single value or an array of values.

Name string

A human-friendly name that will appear in the Keycloak console.

claimName string
realmId string

The realm id where the associated client or client scope exists.

userAttribute string
addToAccessToken boolean

Indicates if the attribute should be a claim in the access token.

addToIdToken boolean

Indicates if the attribute should be a claim in the id token.

addToUserinfo boolean

Indicates if the attribute should appear in the userinfo response body.

aggregateAttributes boolean

Indicates if attribute values should be aggregated within the group attributes

claimValueType string

Claim type used when serializing tokens.

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.

multivalued boolean

Indicates whether this attribute is a single value or an array of values.

name string

A human-friendly name that will appear in the Keycloak console.

claim_name str
realm_id str

The realm id where the associated client or client scope exists.

user_attribute str
add_to_access_token bool

Indicates if the attribute should be a claim in the access token.

add_to_id_token bool

Indicates if the attribute should be a claim in the id token.

add_to_userinfo bool

Indicates if the attribute should appear in the userinfo response body.

aggregate_attributes bool

Indicates if attribute values should be aggregated within the group attributes

claim_value_type str

Claim type used when serializing tokens.

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.

multivalued bool

Indicates whether this attribute is a single value or an array of values.

name str

A human-friendly name that will appear in the Keycloak console.

Outputs

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

Get an existing UserAttributeProtocolMapper resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

static get(resource_name, id, opts=None, add_to_access_token=None, add_to_id_token=None, add_to_userinfo=None, aggregate_attributes=None, claim_name=None, claim_value_type=None, client_id=None, client_scope_id=None, multivalued=None, name=None, realm_id=None, user_attribute=None, __props__=None);
func GetUserAttributeProtocolMapper(ctx *Context, name string, id IDInput, state *UserAttributeProtocolMapperState, opts ...ResourceOption) (*UserAttributeProtocolMapper, error)
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:

AddToAccessToken bool

Indicates if the attribute should be a claim in the access token.

AddToIdToken bool

Indicates if the attribute should be a claim in the id token.

AddToUserinfo bool

Indicates if the attribute should appear in the userinfo response body.

AggregateAttributes bool

Indicates if attribute values should be aggregated within the group attributes

ClaimName string
ClaimValueType string

Claim type used when serializing tokens.

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.

Multivalued bool

Indicates whether this attribute is a single value or an array of values.

Name string

A human-friendly name that will appear in the Keycloak console.

RealmId string

The realm id where the associated client or client scope exists.

UserAttribute string
AddToAccessToken bool

Indicates if the attribute should be a claim in the access token.

AddToIdToken bool

Indicates if the attribute should be a claim in the id token.

AddToUserinfo bool

Indicates if the attribute should appear in the userinfo response body.

AggregateAttributes bool

Indicates if attribute values should be aggregated within the group attributes

ClaimName string
ClaimValueType string

Claim type used when serializing tokens.

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.

Multivalued bool

Indicates whether this attribute is a single value or an array of values.

Name string

A human-friendly name that will appear in the Keycloak console.

RealmId string

The realm id where the associated client or client scope exists.

UserAttribute string
addToAccessToken boolean

Indicates if the attribute should be a claim in the access token.

addToIdToken boolean

Indicates if the attribute should be a claim in the id token.

addToUserinfo boolean

Indicates if the attribute should appear in the userinfo response body.

aggregateAttributes boolean

Indicates if attribute values should be aggregated within the group attributes

claimName string
claimValueType string

Claim type used when serializing tokens.

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.

multivalued boolean

Indicates whether this attribute is a single value or an array of values.

name string

A human-friendly name that will appear in the Keycloak console.

realmId string

The realm id where the associated client or client scope exists.

userAttribute string
add_to_access_token bool

Indicates if the attribute should be a claim in the access token.

add_to_id_token bool

Indicates if the attribute should be a claim in the id token.

add_to_userinfo bool

Indicates if the attribute should appear in the userinfo response body.

aggregate_attributes bool

Indicates if attribute values should be aggregated within the group attributes

claim_name str
claim_value_type str

Claim type used when serializing tokens.

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.

multivalued bool

Indicates whether this attribute is a single value or an array of values.

name str

A human-friendly name that will appear in the Keycloak console.

realm_id str

The realm id where the associated client or client scope exists.

user_attribute str

Package Details

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