GroupMapper
# keycloak.ldap.GroupMapper
Allows for creating and managing group mappers for Keycloak users federated via LDAP.
The LDAP group mapper can be used to map an LDAP user’s groups from some DN to Keycloak groups. This group mapper will also create the groups within Keycloak if they do not already exist.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as keycloak from "@pulumi/keycloak";
const realm = new keycloak.Realm("realm", {
enabled: true,
realm: "test",
});
const ldapUserFederation = new keycloak.ldap.UserFederation("ldap_user_federation", {
bindCredential: "admin",
bindDn: "cn=admin,dc=example,dc=org",
connectionUrl: "ldap://openldap",
rdnLdapAttribute: "cn",
realmId: realm.id,
userObjectClasses: [
"simpleSecurityObject",
"organizationalRole",
],
usernameLdapAttribute: "cn",
usersDn: "dc=example,dc=org",
uuidLdapAttribute: "entryDN",
});
const ldapGroupMapper = new keycloak.ldap.GroupMapper("ldap_group_mapper", {
groupNameLdapAttribute: "cn",
groupObjectClasses: ["groupOfNames"],
ldapGroupsDn: "dc=example,dc=org",
ldapUserFederationId: ldapUserFederation.id,
memberofLdapAttribute: "memberOf",
membershipAttributeType: "DN",
membershipLdapAttribute: "member",
membershipUserLdapAttribute: "cn",
realmId: realm.id,
});import pulumi
import pulumi_keycloak as keycloak
realm = keycloak.Realm("realm",
enabled=True,
realm="test")
ldap_user_federation = keycloak.ldap.UserFederation("ldapUserFederation",
bind_credential="admin",
bind_dn="cn=admin,dc=example,dc=org",
connection_url="ldap://openldap",
rdn_ldap_attribute="cn",
realm_id=realm.id,
user_object_classes=[
"simpleSecurityObject",
"organizationalRole",
],
username_ldap_attribute="cn",
users_dn="dc=example,dc=org",
uuid_ldap_attribute="entryDN")
ldap_group_mapper = keycloak.ldap.GroupMapper("ldapGroupMapper",
group_name_ldap_attribute="cn",
group_object_classes=["groupOfNames"],
ldap_groups_dn="dc=example,dc=org",
ldap_user_federation_id=ldap_user_federation.id,
memberof_ldap_attribute="memberOf",
membership_attribute_type="DN",
membership_ldap_attribute="member",
membership_user_ldap_attribute="cn",
realm_id=realm.id)using Pulumi;
using Keycloak = Pulumi.Keycloak;
class MyStack : Stack
{
public MyStack()
{
var realm = new Keycloak.Realm("realm", new Keycloak.RealmArgs
{
Enabled = true,
Realm = "test",
});
var ldapUserFederation = new Keycloak.Ldap.UserFederation("ldapUserFederation", new Keycloak.Ldap.UserFederationArgs
{
BindCredential = "admin",
BindDn = "cn=admin,dc=example,dc=org",
ConnectionUrl = "ldap://openldap",
RdnLdapAttribute = "cn",
RealmId = realm.Id,
UserObjectClasses =
{
"simpleSecurityObject",
"organizationalRole",
},
UsernameLdapAttribute = "cn",
UsersDn = "dc=example,dc=org",
UuidLdapAttribute = "entryDN",
});
var ldapGroupMapper = new Keycloak.Ldap.GroupMapper("ldapGroupMapper", new Keycloak.Ldap.GroupMapperArgs
{
GroupNameLdapAttribute = "cn",
GroupObjectClasses =
{
"groupOfNames",
},
LdapGroupsDn = "dc=example,dc=org",
LdapUserFederationId = ldapUserFederation.Id,
MemberofLdapAttribute = "memberOf",
MembershipAttributeType = "DN",
MembershipLdapAttribute = "member",
MembershipUserLdapAttribute = "cn",
RealmId = realm.Id,
});
}
}
Argument Reference
The following arguments are supported:
realm_id- (Required) The realm that this LDAP mapper will exist in.ldap_user_federation_id- (Required) The ID of the LDAP user federation provider to attach this mapper to.name- (Required) Display name of this mapper when displayed in the console.ldap_groups_dn- (Required) The LDAP DN where groups can be found.group_name_ldap_attribute- (Required) The name of the LDAP attribute that is used in group objects for the name and RDN of the group. Typicallycn.group_object_classes- (Required) Array of strings representing the object classes for the group. Must contain at least one.preserve_group_inheritance- (Optional) Whentrue, group inheritance will be propagated from LDAP to Keycloak. Whenfalse, all LDAP groups will be propagated as top level groups within Keycloak.ignore_missing_groups- (Optional) Whentrue, missing groups in the hierarchy will be ignored.membership_ldap_attribute- (Required) The name of the LDAP attribute that is used for membership mappings.membership_attribute_type- (Optional) Can be one ofDNorUID. Defaults toDN.membership_user_ldap_attribute- (Required) The name of the LDAP attribute on a user that is used for membership mappings.groups_ldap_filter- (Optional) When specified, adds an additional custom filter to be used when querying for groups. Must start with(and end with).mode- (Optional) Can be one ofREAD_ONLYorLDAP_ONLY. Defaults toREAD_ONLY.user_roles_retrieve_strategy- (Optional) Can be one ofLOAD_GROUPS_BY_MEMBER_ATTRIBUTE,GET_GROUPS_FROM_USER_MEMBEROF_ATTRIBUTE, orLOAD_GROUPS_BY_MEMBER_ATTRIBUTE_RECURSIVELY. Defaults toLOAD_GROUPS_BY_MEMBER_ATTRIBUTE.memberof_ldap_attribute- (Optional) Specifies the name of the LDAP attribute on the LDAP user that contains the groups the user is a member of. Defaults tomemberOf.mapped_group_attributes- (Optional) Array of strings representing attributes on the LDAP group which will be mapped to attributes on the Keycloak group.drop_non_existing_groups_during_sync- (Optional) Whentrue, groups that no longer exist within LDAP will be dropped in Keycloak during sync. Defaults tofalse.
Create a GroupMapper Resource
new GroupMapper(name: string, args: GroupMapperArgs, opts?: CustomResourceOptions);def GroupMapper(resource_name, opts=None, drop_non_existing_groups_during_sync=None, group_name_ldap_attribute=None, group_object_classes=None, groups_ldap_filter=None, ignore_missing_groups=None, ldap_groups_dn=None, ldap_user_federation_id=None, mapped_group_attributes=None, memberof_ldap_attribute=None, membership_attribute_type=None, membership_ldap_attribute=None, membership_user_ldap_attribute=None, mode=None, name=None, preserve_group_inheritance=None, realm_id=None, user_roles_retrieve_strategy=None, __props__=None);func NewGroupMapper(ctx *Context, name string, args GroupMapperArgs, opts ...ResourceOption) (*GroupMapper, error)public GroupMapper(string name, GroupMapperArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args GroupMapperArgs
- 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 GroupMapperArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args GroupMapperArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
GroupMapper Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The GroupMapper resource accepts the following input properties:
- Group
Name stringLdap Attribute - Group
Object List<string>Classes - Ldap
Groups stringDn - Ldap
User stringFederation Id The ldap user federation provider to attach this mapper to.
- Membership
Ldap stringAttribute - Membership
User stringLdap Attribute - Realm
Id string The realm in which the ldap user federation provider exists.
- Drop
Non boolExisting Groups During Sync - Groups
Ldap stringFilter - Ignore
Missing boolGroups - Mapped
Group List<string>Attributes - Memberof
Ldap stringAttribute - Membership
Attribute stringType - Mode string
- Name string
Display name of the mapper when displayed in the console.
- Preserve
Group boolInheritance - User
Roles stringRetrieve Strategy
- Group
Name stringLdap Attribute - Group
Object []stringClasses - Ldap
Groups stringDn - Ldap
User stringFederation Id The ldap user federation provider to attach this mapper to.
- Membership
Ldap stringAttribute - Membership
User stringLdap Attribute - Realm
Id string The realm in which the ldap user federation provider exists.
- Drop
Non boolExisting Groups During Sync - Groups
Ldap stringFilter - Ignore
Missing boolGroups - Mapped
Group []stringAttributes - Memberof
Ldap stringAttribute - Membership
Attribute stringType - Mode string
- Name string
Display name of the mapper when displayed in the console.
- Preserve
Group boolInheritance - User
Roles stringRetrieve Strategy
- group
Name stringLdap Attribute - group
Object string[]Classes - ldap
Groups stringDn - ldap
User stringFederation Id The ldap user federation provider to attach this mapper to.
- membership
Ldap stringAttribute - membership
User stringLdap Attribute - realm
Id string The realm in which the ldap user federation provider exists.
- drop
Non booleanExisting Groups During Sync - groups
Ldap stringFilter - ignore
Missing booleanGroups - mapped
Group string[]Attributes - memberof
Ldap stringAttribute - membership
Attribute stringType - mode string
- name string
Display name of the mapper when displayed in the console.
- preserve
Group booleanInheritance - user
Roles stringRetrieve Strategy
- group_
name_ strldap_ attribute - group_
object_ List[str]classes - ldap_
groups_ strdn - ldap_
user_ strfederation_ id The ldap user federation provider to attach this mapper to.
- membership_
ldap_ strattribute - membership_
user_ strldap_ attribute - realm_
id str The realm in which the ldap user federation provider exists.
- drop_
non_ boolexisting_ groups_ during_ sync - groups_
ldap_ strfilter - ignore_
missing_ boolgroups - mapped_
group_ List[str]attributes - memberof_
ldap_ strattribute - membership_
attribute_ strtype - mode str
- name str
Display name of the mapper when displayed in the console.
- preserve_
group_ boolinheritance - user_
roles_ strretrieve_ strategy
Outputs
All input properties are implicitly available as output properties. Additionally, the GroupMapper resource produces the following output properties:
Look up an Existing GroupMapper Resource
Get an existing GroupMapper 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?: GroupMapperState, opts?: CustomResourceOptions): GroupMapperstatic get(resource_name, id, opts=None, drop_non_existing_groups_during_sync=None, group_name_ldap_attribute=None, group_object_classes=None, groups_ldap_filter=None, ignore_missing_groups=None, ldap_groups_dn=None, ldap_user_federation_id=None, mapped_group_attributes=None, memberof_ldap_attribute=None, membership_attribute_type=None, membership_ldap_attribute=None, membership_user_ldap_attribute=None, mode=None, name=None, preserve_group_inheritance=None, realm_id=None, user_roles_retrieve_strategy=None, __props__=None);func GetGroupMapper(ctx *Context, name string, id IDInput, state *GroupMapperState, opts ...ResourceOption) (*GroupMapper, error)public static GroupMapper Get(string name, Input<string> id, GroupMapperState? 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:
- Drop
Non boolExisting Groups During Sync - Group
Name stringLdap Attribute - Group
Object List<string>Classes - Groups
Ldap stringFilter - Ignore
Missing boolGroups - Ldap
Groups stringDn - Ldap
User stringFederation Id The ldap user federation provider to attach this mapper to.
- Mapped
Group List<string>Attributes - Memberof
Ldap stringAttribute - Membership
Attribute stringType - Membership
Ldap stringAttribute - Membership
User stringLdap Attribute - Mode string
- Name string
Display name of the mapper when displayed in the console.
- Preserve
Group boolInheritance - Realm
Id string The realm in which the ldap user federation provider exists.
- User
Roles stringRetrieve Strategy
- Drop
Non boolExisting Groups During Sync - Group
Name stringLdap Attribute - Group
Object []stringClasses - Groups
Ldap stringFilter - Ignore
Missing boolGroups - Ldap
Groups stringDn - Ldap
User stringFederation Id The ldap user federation provider to attach this mapper to.
- Mapped
Group []stringAttributes - Memberof
Ldap stringAttribute - Membership
Attribute stringType - Membership
Ldap stringAttribute - Membership
User stringLdap Attribute - Mode string
- Name string
Display name of the mapper when displayed in the console.
- Preserve
Group boolInheritance - Realm
Id string The realm in which the ldap user federation provider exists.
- User
Roles stringRetrieve Strategy
- drop
Non booleanExisting Groups During Sync - group
Name stringLdap Attribute - group
Object string[]Classes - groups
Ldap stringFilter - ignore
Missing booleanGroups - ldap
Groups stringDn - ldap
User stringFederation Id The ldap user federation provider to attach this mapper to.
- mapped
Group string[]Attributes - memberof
Ldap stringAttribute - membership
Attribute stringType - membership
Ldap stringAttribute - membership
User stringLdap Attribute - mode string
- name string
Display name of the mapper when displayed in the console.
- preserve
Group booleanInheritance - realm
Id string The realm in which the ldap user federation provider exists.
- user
Roles stringRetrieve Strategy
- drop_
non_ boolexisting_ groups_ during_ sync - group_
name_ strldap_ attribute - group_
object_ List[str]classes - groups_
ldap_ strfilter - ignore_
missing_ boolgroups - ldap_
groups_ strdn - ldap_
user_ strfederation_ id The ldap user federation provider to attach this mapper to.
- mapped_
group_ List[str]attributes - memberof_
ldap_ strattribute - membership_
attribute_ strtype - membership_
ldap_ strattribute - membership_
user_ strldap_ attribute - mode str
- name str
Display name of the mapper when displayed in the console.
- preserve_
group_ boolinheritance - realm_
id str The realm in which the ldap user federation provider exists.
- user_
roles_ strretrieve_ strategy
Package Details
- Repository
- https://github.com/pulumi/pulumi-keycloak
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
keycloakTerraform Provider.