dex icon indicating copy to clipboard operation
dex copied to clipboard

Add a config option to normalize LDAP groups case

Open rci-kmccolm opened this issue 1 year ago • 0 comments

Preflight Checklist

  • [X] I agree to follow the Code of Conduct that this project adheres to.
  • [X] I have searched the issue tracker for an issue that matches the one I want to file, without success.

Problem Description

We are using Pinniped with Dex in Kubernetes for authenticating Kubernetes users against AD. When LDAP groups are presented to Pinniped for the purpose of assigning group memberships, if the LDAP group case does not match then the group memberships are not matched and the authentication fails.

Proposed Solution

In my understanding, in most LDAP environments, attribute values are considered case-insensitive. Therefore I believe it would be beneficial to have an option in Dex to normalize case for LDAP group IDs (and perhaps user IDs as well) when Dex retrieves them from the directory to avoid this problem. Example code below,

In connector/ldap/ldap.go:

// Config holds configuration options for LDAP logins.
type Config struct {
[...]
		// If set to true, convert all group names to lower case
		NormalizeGroups bool `json:"normalizeGroups"` // Defaults to false
[...]
func (c *ldapConnector) groups(ctx context.Context, user ldap.Entry) ([]string, error) {
[...]
		// Convert group name to lower case if config value normalizeGroups is true
		if c.GroupSearch.NormalizeGroups {
			name = strings.ToLower(name)
		}

Alternatives Considered

No response

Additional Information

If the community is happy with this approach, I can submit a PR, but first I wanted to float the idea and see if it is welcomed.

rci-kmccolm avatar Feb 09 '24 17:02 rci-kmccolm