Skip to content

Commit 0a79a1c

Browse files
authored
Add group_search_filter, user_search_filter, and start_tls to LDAP Auth Config (#1173)
1 parent 7b9d01c commit 0a79a1c

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

rancher2/schema_auth_config_ldap.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func authConfigLdapFields() map[string]*schema.Schema {
3939
Type: schema.TypeString,
4040
Required: true,
4141
},
42+
"user_search_filter": {
43+
Type: schema.TypeString,
44+
Optional: true,
45+
},
4246
"certificate": {
4347
Type: schema.TypeString,
4448
Optional: true,
@@ -89,6 +93,10 @@ func authConfigLdapFields() map[string]*schema.Schema {
8993
Optional: true,
9094
Computed: true,
9195
},
96+
"group_search_filter": {
97+
Type: schema.TypeString,
98+
Optional: true,
99+
},
92100
"nested_group_membership_enabled": {
93101
Type: schema.TypeBool,
94102
Optional: true,
@@ -139,6 +147,11 @@ func authConfigLdapFields() map[string]*schema.Schema {
139147
Optional: true,
140148
Computed: true,
141149
},
150+
"start_tls": {
151+
Type: schema.TypeBool,
152+
Optional: true,
153+
Computed: true,
154+
},
142155
}
143156

144157
for k, v := range authConfigFields() {

rancher2/structure_auth_config_ldap.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ func flattenAuthConfigLdap(d *schema.ResourceData, in *managementClient.LdapConf
3333
}
3434

3535
d.Set("service_account_distinguished_name", in.ServiceAccountDistinguishedName)
36-
d.Set("user_search_base", in.UserSearchBase)
3736
d.Set("certificate", Base64Encode(in.Certificate))
3837
d.Set("connection_timeout", int(in.ConnectionTimeout))
3938
d.Set("group_dn_attribute", in.GroupDNAttribute)
@@ -43,16 +42,20 @@ func flattenAuthConfigLdap(d *schema.ResourceData, in *managementClient.LdapConf
4342
d.Set("group_object_class", in.GroupObjectClass)
4443
d.Set("group_search_attribute", in.GroupSearchAttribute)
4544
d.Set("group_search_base", in.GroupSearchBase)
45+
d.Set("group_search_filter", in.GroupSearchFilter)
4646
d.Set("nested_group_membership_enabled", in.NestedGroupMembershipEnabled)
4747
d.Set("port", int(in.Port))
4848
d.Set("tls", in.TLS)
49+
d.Set("start_tls", in.StartTLS)
4950
d.Set("user_disabled_bit_mask", int(in.UserDisabledBitMask))
5051
d.Set("user_enabled_attribute", in.UserEnabledAttribute)
5152
d.Set("user_login_attribute", in.UserLoginAttribute)
5253
d.Set("user_member_attribute", in.UserMemberAttribute)
5354
d.Set("user_name_attribute", in.UserNameAttribute)
5455
d.Set("user_object_class", in.UserObjectClass)
5556
d.Set("user_search_attribute", in.UserSearchAttribute)
57+
d.Set("user_search_base", in.UserSearchBase)
58+
d.Set("user_search_filter", in.UserSearchFilter)
5659

5760
return nil
5861
}
@@ -105,6 +108,10 @@ func expandAuthConfigLdap(in *schema.ResourceData) (*managementClient.LdapConfig
105108
obj.UserSearchBase = v
106109
}
107110

111+
if v, ok := in.Get("user_search_filter").(string); ok && len(v) > 0 {
112+
obj.UserSearchFilter = v
113+
}
114+
108115
if v, ok := in.Get("certificate").(string); ok && len(v) > 0 {
109116
cert, err := Base64Decode(v)
110117
if err != nil {
@@ -145,6 +152,10 @@ func expandAuthConfigLdap(in *schema.ResourceData) (*managementClient.LdapConfig
145152
obj.GroupSearchBase = v
146153
}
147154

155+
if v, ok := in.Get("group_search_filter").(string); ok && len(v) > 0 {
156+
obj.GroupSearchFilter = v
157+
}
158+
148159
if v, ok := in.Get("nested_group_membership_enabled").(bool); ok {
149160
obj.NestedGroupMembershipEnabled = v
150161
}
@@ -157,6 +168,10 @@ func expandAuthConfigLdap(in *schema.ResourceData) (*managementClient.LdapConfig
157168
obj.TLS = v
158169
}
159170

171+
if v, ok := in.Get("start_tls").(bool); ok {
172+
obj.StartTLS = v
173+
}
174+
160175
if v, ok := in.Get("user_disabled_bit_mask").(int); ok && v > 0 {
161176
obj.UserDisabledBitMask = int64(v)
162177
}

rancher2/structure_auth_config_ldap_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@ func init() {
3030
GroupObjectClass: "group_object_class",
3131
GroupSearchAttribute: "group_search_attribute",
3232
GroupSearchBase: "group_search_base",
33+
GroupSearchFilter: "(cn=$SEARCH_STRING)",
3334
NestedGroupMembershipEnabled: true,
3435
Port: 389,
3536
TLS: true,
37+
StartTLS: true,
3638
UserDisabledBitMask: 0,
3739
UserLoginAttribute: "user_login_attribute",
3840
UserMemberAttribute: "user_member_attribute",
3941
UserNameAttribute: "user_name_attribute",
4042
UserObjectClass: "user_object_class",
4143
UserSearchAttribute: "user_search_attribute",
44+
UserSearchFilter: "(|(cn=$SEARCH_STRING)(sAMAccountName=$SEARCH_STRING))",
4245
}
4346
testAuthConfigLdapInterface = map[string]interface{}{
4447
"access_mode": "access",
@@ -56,15 +59,18 @@ func init() {
5659
"group_object_class": "group_object_class",
5760
"group_search_attribute": "group_search_attribute",
5861
"group_search_base": "group_search_base",
62+
"group_search_filter": "(cn=$SEARCH_STRING)",
5963
"nested_group_membership_enabled": true,
6064
"port": 389,
6165
"tls": true,
66+
"start_tls": true,
6267
"user_disabled_bit_mask": 0,
6368
"user_login_attribute": "user_login_attribute",
6469
"user_member_attribute": "user_member_attribute",
6570
"user_name_attribute": "user_name_attribute",
6671
"user_object_class": "user_object_class",
6772
"user_search_attribute": "user_search_attribute",
73+
"user_search_filter": "(|(cn=$SEARCH_STRING)(sAMAccountName=$SEARCH_STRING))",
6874
}
6975
}
7076

0 commit comments

Comments
 (0)