Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support ldap userfilter attribute #1378

Merged
merged 1 commit into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions vault/resource_ldap_auth_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ func ldapAuthBackendResource() *schema.Resource {
return strings.ToLower(v.(string))
},
},
"userfilter": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"discoverdn": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -240,6 +245,10 @@ func ldapAuthBackendUpdate(d *schema.ResourceData, meta interface{}) error {
data["userattr"] = v.(string)
}

if v, ok := d.GetOk("userfilter"); ok {
data["userfilter"] = v.(string)
}

if v, ok := d.GetOkExists("discoverdn"); ok {
data["discoverdn"] = v.(bool)
}
Expand Down Expand Up @@ -339,6 +348,7 @@ func ldapAuthBackendRead(d *schema.ResourceData, meta interface{}) error {
d.Set("case_sensitive_names", resp.Data["case_sensitive_names"])
d.Set("userdn", resp.Data["userdn"])
d.Set("userattr", resp.Data["userattr"])
d.Set("userfilter", resp.Data["userfilter"])
d.Set("discoverdn", resp.Data["discoverdn"])
d.Set("deny_null_bind", resp.Data["deny_null_bind"])
d.Set("upndomain", resp.Data["upndomain"])
Expand Down
3 changes: 2 additions & 1 deletion vault/resource_ldap_auth_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func testLDAPAuthBackendCheck_attrs(path string) resource.TestCheckFunc {
"binddn": "binddn",
"userdn": "userdn",
"userattr": "userattr",
"userfilter": "userfilter",
"discoverdn": "discoverdn",
"deny_null_bind": "deny_null_bind",
"upndomain": "upndomain",
Expand Down Expand Up @@ -283,7 +284,7 @@ resource "vault_ldap_auth_backend" "test" {
discoverdn = false
deny_null_bind = true
description = "example"

userfilter = "({{.UserAttr}}={{.Username}})"
use_token_groups = %s
}
`, path, local, use_token_groups)
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/ldap_auth_backend.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ The following arguments are supported:

* `userattr` - (Optional) Attribute on user object matching username passed in

* `userfilter` - (Optional) LDAP user search filter

* `upndomain` - (Optional) The userPrincipalDomain used to construct UPN string

* `discoverdn`: (Optional) Use anonymous bind to discover the bind DN of a user.
Expand Down