UserPropertyProtocolMapper
# keycloak.openid.UserPropertyProtocolMapper
Allows for creating and managing user property protocol mappers within Keycloak.
User property protocol mappers allow you to map built in properties defined on the Keycloak user interface 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 userPropertyMapper = new keycloak.openid.UserPropertyProtocolMapper("user_property_mapper", {
claimName: "email",
clientId: openidClient.id,
realmId: realm.id,
userProperty: "email",
});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_property_mapper = keycloak.openid.UserPropertyProtocolMapper("userPropertyMapper",
claim_name="email",
client_id=openid_client.id,
realm_id=realm.id,
user_property="email")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 userPropertyMapper = new Keycloak.OpenId.UserPropertyProtocolMapper("userPropertyMapper", new Keycloak.OpenId.UserPropertyProtocolMapperArgs
{
ClaimName = "email",
ClientId = openidClient.Id,
RealmId = realm.Id,
UserProperty = "email",
});
}
}
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 userPropertyMapper = new keycloak.openid.UserPropertyProtocolMapper("user_property_mapper", {
claimName: "email",
clientScopeId: clientScope.id,
realmId: realm.id,
userProperty: "email",
});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_property_mapper = keycloak.openid.UserPropertyProtocolMapper("userPropertyMapper",
claim_name="email",
client_scope_id=client_scope.id,
realm_id=realm.id,
user_property="email")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 userPropertyMapper = new Keycloak.OpenId.UserPropertyProtocolMapper("userPropertyMapper", new Keycloak.OpenId.UserPropertyProtocolMapperArgs
{
ClaimName = "email",
ClientScopeId = clientScope.Id,
RealmId = realm.Id,
UserProperty = "email",
});
}
}
Argument Reference
The following arguments are supported:
realm_id- (Required) The realm this protocol mapper exists within.client_id- (Required ifclient_scope_idis not specified) The client this protocol mapper is attached to.client_scope_id- (Required ifclient_idis not specified) The client scope this protocol mapper is attached to.name- (Required) The display name of this protocol mapper in the GUI.user_property- (Required) The built in user property (such as email) 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 ofString,long,int, orboolean. Defaults toString.add_to_id_token- (Optional) Indicates if the property should be added as a claim to the id token. Defaults totrue.add_to_access_token- (Optional) Indicates if the property should be added as a claim to the access token. Defaults totrue.add_to_userinfo- (Optional) Indicates if the property should be added as a claim to the UserInfo response body. Defaults totrue.
Create a UserPropertyProtocolMapper Resource
new UserPropertyProtocolMapper(name: string, args: UserPropertyProtocolMapperArgs, opts?: CustomResourceOptions);def UserPropertyProtocolMapper(resource_name, opts=None, add_to_access_token=None, add_to_id_token=None, add_to_userinfo=None, claim_name=None, claim_value_type=None, client_id=None, client_scope_id=None, name=None, realm_id=None, user_property=None, __props__=None);func NewUserPropertyProtocolMapper(ctx *Context, name string, args UserPropertyProtocolMapperArgs, opts ...ResourceOption) (*UserPropertyProtocolMapper, error)public UserPropertyProtocolMapper(string name, UserPropertyProtocolMapperArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args UserPropertyProtocolMapperArgs
- 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 UserPropertyProtocolMapperArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args UserPropertyProtocolMapperArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
UserPropertyProtocolMapper Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The UserPropertyProtocolMapper resource accepts the following input properties:
- Claim
Name string - Realm
Id string The realm id where the associated client or client scope exists.
- User
Property string - Add
To boolAccess Token Indicates if the property should be a claim in the access token.
- Add
To boolId Token Indicates if the property should be a claim in the id token.
- Add
To boolUserinfo Indicates if the property should appear in the userinfo response body.
- Claim
Value stringType Claim type used when serializing tokens.
- Client
Id string The mapper’s associated client. Cannot be used at the same time as client_scope_id.
- Client
Scope stringId 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.
- Claim
Name string - Realm
Id string The realm id where the associated client or client scope exists.
- User
Property string - Add
To boolAccess Token Indicates if the property should be a claim in the access token.
- Add
To boolId Token Indicates if the property should be a claim in the id token.
- Add
To boolUserinfo Indicates if the property should appear in the userinfo response body.
- Claim
Value stringType Claim type used when serializing tokens.
- Client
Id string The mapper’s associated client. Cannot be used at the same time as client_scope_id.
- Client
Scope stringId 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.
- claim
Name string - realm
Id string The realm id where the associated client or client scope exists.
- user
Property string - add
To booleanAccess Token Indicates if the property should be a claim in the access token.
- add
To booleanId Token Indicates if the property should be a claim in the id token.
- add
To booleanUserinfo Indicates if the property should appear in the userinfo response body.
- claim
Value stringType Claim type used when serializing tokens.
- client
Id string The mapper’s associated client. Cannot be used at the same time as client_scope_id.
- client
Scope stringId 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.
- claim_
name str - realm_
id str The realm id where the associated client or client scope exists.
- user_
property str - add_
to_ boolaccess_ token Indicates if the property should be a claim in the access token.
- add_
to_ boolid_ token Indicates if the property should be a claim in the id token.
- add_
to_ booluserinfo Indicates if the property should appear in the userinfo response body.
- claim_
value_ strtype 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_ strid 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.
Outputs
All input properties are implicitly available as output properties. Additionally, the UserPropertyProtocolMapper resource produces the following output properties:
Look up an Existing UserPropertyProtocolMapper Resource
Get an existing UserPropertyProtocolMapper 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?: UserPropertyProtocolMapperState, opts?: CustomResourceOptions): UserPropertyProtocolMapperstatic get(resource_name, id, opts=None, add_to_access_token=None, add_to_id_token=None, add_to_userinfo=None, claim_name=None, claim_value_type=None, client_id=None, client_scope_id=None, name=None, realm_id=None, user_property=None, __props__=None);func GetUserPropertyProtocolMapper(ctx *Context, name string, id IDInput, state *UserPropertyProtocolMapperState, opts ...ResourceOption) (*UserPropertyProtocolMapper, error)public static UserPropertyProtocolMapper Get(string name, Input<string> id, UserPropertyProtocolMapperState? 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:
- Add
To boolAccess Token Indicates if the property should be a claim in the access token.
- Add
To boolId Token Indicates if the property should be a claim in the id token.
- Add
To boolUserinfo Indicates if the property should appear in the userinfo response body.
- Claim
Name string - Claim
Value stringType Claim type used when serializing tokens.
- Client
Id string The mapper’s associated client. Cannot be used at the same time as client_scope_id.
- Client
Scope stringId 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.
- Realm
Id string The realm id where the associated client or client scope exists.
- User
Property string
- Add
To boolAccess Token Indicates if the property should be a claim in the access token.
- Add
To boolId Token Indicates if the property should be a claim in the id token.
- Add
To boolUserinfo Indicates if the property should appear in the userinfo response body.
- Claim
Name string - Claim
Value stringType Claim type used when serializing tokens.
- Client
Id string The mapper’s associated client. Cannot be used at the same time as client_scope_id.
- Client
Scope stringId 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.
- Realm
Id string The realm id where the associated client or client scope exists.
- User
Property string
- add
To booleanAccess Token Indicates if the property should be a claim in the access token.
- add
To booleanId Token Indicates if the property should be a claim in the id token.
- add
To booleanUserinfo Indicates if the property should appear in the userinfo response body.
- claim
Name string - claim
Value stringType Claim type used when serializing tokens.
- client
Id string The mapper’s associated client. Cannot be used at the same time as client_scope_id.
- client
Scope stringId 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.
- realm
Id string The realm id where the associated client or client scope exists.
- user
Property string
- add_
to_ boolaccess_ token Indicates if the property should be a claim in the access token.
- add_
to_ boolid_ token Indicates if the property should be a claim in the id token.
- add_
to_ booluserinfo Indicates if the property should appear in the userinfo response body.
- claim_
name str - claim_
value_ strtype 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_ strid 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.
- realm_
id str The realm id where the associated client or client scope exists.
- user_
property str
Package Details
- Repository
- https://github.com/pulumi/pulumi-keycloak
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
keycloakTerraform Provider.