80 String roleObjectClasses = LDAPConstants.GROUP_OF_NAMES;
81 String mode = LDAPGroupMapperMode.LDAP_ONLY.toString();
82 String membershipUserAttribute = LDAPConstants.UID;
83 boolean importEnabled =
true;
85 LDAPConfig config =
new LDAPConfig(parent.getConfig());
86 roleObjectClasses = config.isActiveDirectory() ? LDAPConstants.GROUP : LDAPConstants.GROUP_OF_NAMES;
87 mode = config.getEditMode() == UserStorageProvider.EditMode.WRITABLE ? LDAPGroupMapperMode.LDAP_ONLY.toString() : LDAPGroupMapperMode.READ_ONLY.toString();
88 membershipUserAttribute = config.getUsernameLdapAttribute();
89 importEnabled =
new UserStorageProviderModel(parent).isImportEnabled();
93 ProviderConfigurationBuilder config = ProviderConfigurationBuilder.create()
94 .property().name(RoleMapperConfig.ROLES_DN)
95 .label(
"LDAP Roles DN")
96 .helpText(
"LDAP DN where are roles of this tree saved. For example 'ou=finance,dc=example,dc=org' ")
97 .type(ProviderConfigProperty.STRING_TYPE)
99 .property().name(RoleMapperConfig.ROLE_NAME_LDAP_ATTRIBUTE)
100 .label(
"Role Name LDAP Attribute")
101 .helpText(
"Name of LDAP attribute, which is used in role objects for name and RDN of role. Usually it will be 'cn' . In this case typical group/role object may have DN like 'cn=role1,ou=finance,dc=example,dc=org' ")
102 .type(ProviderConfigProperty.STRING_TYPE)
103 .defaultValue(LDAPConstants.CN)
105 .property().name(RoleMapperConfig.ROLE_OBJECT_CLASSES)
106 .label(
"Role Object Classes")
107 .helpText(
"Object class (or classes) of the role object. It's divided by comma if more classes needed. In typical LDAP deployment it could be 'groupOfNames' . In Active Directory it's usually 'group' ")
108 .type(ProviderConfigProperty.STRING_TYPE)
109 .defaultValue(roleObjectClasses)
111 .property().name(RoleMapperConfig.MEMBERSHIP_LDAP_ATTRIBUTE)
112 .label(
"Membership LDAP Attribute")
113 .helpText(
"Name of LDAP attribute on role, which is used for membership mappings. Usually it will be 'member' ." +
114 "However when 'Membership Attribute Type' is 'UID' then 'Membership LDAP Attribute' could be typically 'memberUid' .")
115 .type(ProviderConfigProperty.STRING_TYPE)
116 .defaultValue(LDAPConstants.MEMBER)
118 .property().name(RoleMapperConfig.MEMBERSHIP_ATTRIBUTE_TYPE)
119 .label(
"Membership Attribute Type")
120 .helpText(
"DN means that LDAP role has it's members declared in form of their full DN. For example 'member: uid=john,ou=users,dc=example,dc=com' . " +
121 "UID means that LDAP role has it's members declared in form of pure user uids. For example 'memberUid: john' .")
122 .type(ProviderConfigProperty.LIST_TYPE)
124 .defaultValue(MembershipType.DN.toString())
126 .property().name(RoleMapperConfig.MEMBERSHIP_USER_LDAP_ATTRIBUTE)
127 .label(
"Membership User LDAP Attribute")
128 .helpText(
"Used just if Membership Attribute Type is UID. It is name of LDAP attribute on user, which is used for membership mappings. Usually it will be 'uid' . For example if value of " +
129 "'Membership User LDAP Attribute' is 'uid' and " +
130 " LDAP group has 'memberUid: john', then it is expected that particular LDAP user will have attribute 'uid: john' .")
131 .type(ProviderConfigProperty.STRING_TYPE)
132 .defaultValue(membershipUserAttribute)
134 .property().name(RoleMapperConfig.ROLES_LDAP_FILTER)
135 .label(
"LDAP Filter")
136 .helpText(
"LDAP Filter adds additional custom filter to the whole query for retrieve LDAP roles. Leave this empty if no additional filtering is needed and you want to retrieve all roles from LDAP. Otherwise make sure that filter starts with '(' and ends with ')'")
137 .type(ProviderConfigProperty.STRING_TYPE)
141 config.property().name(RoleMapperConfig.MODE)
143 .helpText(
"LDAP_ONLY means that all role mappings are retrieved from LDAP and saved into LDAP. READ_ONLY is Read-only LDAP mode where role mappings are " +
144 "retrieved from both LDAP and DB and merged together. New role grants are not saved to LDAP but to DB. IMPORT is Read-only LDAP mode where role mappings are retrieved from LDAP just at the time when user is imported from LDAP and then " +
145 "they are saved to local keycloak DB.")
146 .type(ProviderConfigProperty.LIST_TYPE)
151 config.property().name(RoleMapperConfig.MODE)
153 .helpText(
"LDAP_ONLY means that specified role mappings are writable to LDAP. READ_ONLY means LDAP is readonly.")
154 .type(ProviderConfigProperty.LIST_TYPE)
161 config.property().name(RoleMapperConfig.USER_ROLES_RETRIEVE_STRATEGY)
162 .label(
"User Roles Retrieve Strategy")
163 .helpText(
"Specify how to retrieve roles of user. LOAD_ROLES_BY_MEMBER_ATTRIBUTE means that roles of user will be retrieved by sending LDAP query to retrieve all roles where 'member' is our user. " +
164 "GET_ROLES_FROM_USER_MEMBEROF_ATTRIBUTE means that roles of user will be retrieved from 'memberOf' attribute of our user. Or from the other attribute specified by 'Member-Of LDAP Attribute' . " +
165 "LOAD_ROLES_BY_MEMBER_ATTRIBUTE_RECURSIVELY is applicable just in Active Directory and it means that roles of user will be retrieved recursively with usage of LDAP_MATCHING_RULE_IN_CHAIN Ldap extension.")
166 .type(ProviderConfigProperty.LIST_TYPE)
168 .defaultValue(RoleMapperConfig.LOAD_ROLES_BY_MEMBER_ATTRIBUTE)
170 .property().name(GroupMapperConfig.MEMBEROF_LDAP_ATTRIBUTE)
171 .label(
"Member-Of LDAP Attribute")
172 .helpText(
"Used just when 'User Roles Retrieve Strategy' is GET_ROLES_FROM_USER_MEMBEROF_ATTRIBUTE . " +
173 "It specifies the name of the LDAP attribute on the LDAP user, which contains the roles (LDAP Groups), which the user is member of. " +
174 "Usually it will be 'memberOf' and that's also the default value.")
175 .type(ProviderConfigProperty.STRING_TYPE)
176 .defaultValue(LDAPConstants.MEMBER_OF)
178 .property().name(RoleMapperConfig.USE_REALM_ROLES_MAPPING)
179 .label(
"Use Realm Roles Mapping")
180 .helpText(
"If true, then LDAP role mappings will be mapped to realm role mappings in Keycloak. Otherwise it will be mapped to client role mappings")
181 .type(ProviderConfigProperty.BOOLEAN_TYPE)
182 .defaultValue(
"true")
184 .property().name(RoleMapperConfig.CLIENT_ID)
186 .helpText(
"Client ID of client to which LDAP role mappings will be mapped. Applicable just if 'Use Realm Roles Mapping' is false")
187 .type(ProviderConfigProperty.CLIENT_LIST_TYPE)
189 return config.build();
static final List< String > MEMBERSHIP_TYPES
Definition: RoleLDAPStorageMapperFactory.java:54
static final List< String > roleRetrievers
Definition: RoleLDAPStorageMapperFactory.java:57
static final List< String > NO_IMPORT_MODES
Definition: RoleLDAPStorageMapperFactory.java:56
static final List< String > MODES
Definition: RoleLDAPStorageMapperFactory.java:55