mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
auth/ldap: add username_as_alias config flag (#14324)
This commit is contained in:
@@ -1205,6 +1205,7 @@ func TestLdapAuthBackend_ConfigUpgrade(t *testing.T) {
|
|||||||
CaseSensitiveNames: falseBool,
|
CaseSensitiveNames: falseBool,
|
||||||
UsePre111GroupCNBehavior: new(bool),
|
UsePre111GroupCNBehavior: new(bool),
|
||||||
RequestTimeout: cfg.RequestTimeout,
|
RequestTimeout: cfg.RequestTimeout,
|
||||||
|
UsernameAsAlias: false,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,10 @@ func (b *backend) pathLogin(ctx context.Context, req *logical.Request, d *framew
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg.UsernameAsAlias {
|
||||||
|
auth.Alias.Name = username
|
||||||
|
}
|
||||||
|
|
||||||
cfg.PopulateTokenAuth(auth)
|
cfg.PopulateTokenAuth(auth)
|
||||||
|
|
||||||
// Add in configured policies from mappings
|
// Add in configured policies from mappings
|
||||||
|
|||||||
3
changelog/14324.txt
Normal file
3
changelog/14324.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:improvement
|
||||||
|
auth/ldap: Add username_as_alias configurable to change how aliases are named
|
||||||
|
```
|
||||||
@@ -112,6 +112,12 @@ Default: ({{.UserAttr}}={{.Username}})`,
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"username_as_alias": {
|
||||||
|
Type: framework.TypeBool,
|
||||||
|
Default: false,
|
||||||
|
Description: "If true, sets the alias name to the username",
|
||||||
|
},
|
||||||
|
|
||||||
"userattr": {
|
"userattr": {
|
||||||
Type: framework.TypeString,
|
Type: framework.TypeString,
|
||||||
Default: "cn",
|
Default: "cn",
|
||||||
@@ -242,6 +248,10 @@ func NewConfigEntry(existing *ConfigEntry, d *framework.FieldData) (*ConfigEntry
|
|||||||
cfg.AnonymousGroupSearch = d.Get("anonymous_group_search").(bool)
|
cfg.AnonymousGroupSearch = d.Get("anonymous_group_search").(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := d.Raw["username_as_alias"]; ok || !hadExisting {
|
||||||
|
cfg.UsernameAsAlias = d.Get("username_as_alias").(bool)
|
||||||
|
}
|
||||||
|
|
||||||
if _, ok := d.Raw["url"]; ok || !hadExisting {
|
if _, ok := d.Raw["url"]; ok || !hadExisting {
|
||||||
cfg.Url = strings.ToLower(d.Get("url").(string))
|
cfg.Url = strings.ToLower(d.Get("url").(string))
|
||||||
}
|
}
|
||||||
@@ -393,6 +403,7 @@ type ConfigEntry struct {
|
|||||||
GroupFilter string `json:"groupfilter"`
|
GroupFilter string `json:"groupfilter"`
|
||||||
GroupAttr string `json:"groupattr"`
|
GroupAttr string `json:"groupattr"`
|
||||||
UPNDomain string `json:"upndomain"`
|
UPNDomain string `json:"upndomain"`
|
||||||
|
UsernameAsAlias bool `json:"username_as_alias"`
|
||||||
UserFilter string `json:"userfilter"`
|
UserFilter string `json:"userfilter"`
|
||||||
UserAttr string `json:"userattr"`
|
UserAttr string `json:"userattr"`
|
||||||
Certificate string `json:"certificate"`
|
Certificate string `json:"certificate"`
|
||||||
@@ -444,6 +455,7 @@ func (c *ConfigEntry) PasswordlessMap() map[string]interface{} {
|
|||||||
"use_token_groups": c.UseTokenGroups,
|
"use_token_groups": c.UseTokenGroups,
|
||||||
"anonymous_group_search": c.AnonymousGroupSearch,
|
"anonymous_group_search": c.AnonymousGroupSearch,
|
||||||
"request_timeout": c.RequestTimeout,
|
"request_timeout": c.RequestTimeout,
|
||||||
|
"username_as_alias": c.UsernameAsAlias,
|
||||||
}
|
}
|
||||||
if c.CaseSensitiveNames != nil {
|
if c.CaseSensitiveNames != nil {
|
||||||
m["case_sensitive_names"] = *c.CaseSensitiveNames
|
m["case_sensitive_names"] = *c.CaseSensitiveNames
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ var jsonConfigDefault = []byte(`
|
|||||||
"tls_max_version": "tls12",
|
"tls_max_version": "tls12",
|
||||||
"use_token_groups": false,
|
"use_token_groups": false,
|
||||||
"use_pre111_group_cn_behavior": null,
|
"use_pre111_group_cn_behavior": null,
|
||||||
|
"username_as_alias": false,
|
||||||
"request_timeout": 90,
|
"request_timeout": 90,
|
||||||
"CaseSensitiveNames": false,
|
"CaseSensitiveNames": false,
|
||||||
"ClientTLSCert": "",
|
"ClientTLSCert": "",
|
||||||
|
|||||||
@@ -87,6 +87,8 @@ This endpoint configures the LDAP auth method.
|
|||||||
`groupfilter` in order to enumerate user group membership. Examples: for
|
`groupfilter` in order to enumerate user group membership. Examples: for
|
||||||
groupfilter queries returning _group_ objects, use: `cn`. For queries
|
groupfilter queries returning _group_ objects, use: `cn`. For queries
|
||||||
returning _user_ objects, use: `memberOf`. The default is `cn`.
|
returning _user_ objects, use: `memberOf`. The default is `cn`.
|
||||||
|
- `username_as_alias` `(bool: false)` - If set to true, forces the auth method
|
||||||
|
to use the username passed by the user as the alias name.
|
||||||
|
|
||||||
@include 'tokenfields.mdx'
|
@include 'tokenfields.mdx'
|
||||||
|
|
||||||
@@ -117,6 +119,7 @@ $ curl \
|
|||||||
"tls_max_version": "tls12",
|
"tls_max_version": "tls12",
|
||||||
"tls_min_version": "tls12",
|
"tls_min_version": "tls12",
|
||||||
"url": "ldaps://ldap.myorg.com:636",
|
"url": "ldaps://ldap.myorg.com:636",
|
||||||
|
"username_as_alias": false,
|
||||||
"userattr": "samaccountname",
|
"userattr": "samaccountname",
|
||||||
"userdn": "ou=Users,dc=example,dc=com"
|
"userdn": "ou=Users,dc=example,dc=com"
|
||||||
}
|
}
|
||||||
@@ -160,6 +163,7 @@ $ curl \
|
|||||||
"tls_min_version": "tls12",
|
"tls_min_version": "tls12",
|
||||||
"upndomain": "",
|
"upndomain": "",
|
||||||
"url": "ldaps://ldap.myorg.com:636",
|
"url": "ldaps://ldap.myorg.com:636",
|
||||||
|
"username_as_alias": false,
|
||||||
"userattr": "samaccountname",
|
"userattr": "samaccountname",
|
||||||
"userdn": "ou=Users,dc=example,dc=com"
|
"userdn": "ou=Users,dc=example,dc=com"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -147,6 +147,11 @@ _Note_: When using _Authenticated Search_ for binding parameters (see above) the
|
|||||||
|
|
||||||
Use `vault path-help` for more details.
|
Use `vault path-help` for more details.
|
||||||
|
|
||||||
|
### Other
|
||||||
|
|
||||||
|
- `username_as_alias` (bool, optional) - If set to true, forces the auth method to use the username passed by the user as the alias name.
|
||||||
|
|
||||||
|
|
||||||
## Examples:
|
## Examples:
|
||||||
|
|
||||||
### Scenario 1
|
### Scenario 1
|
||||||
|
|||||||
Reference in New Issue
Block a user