Skip to content

Commit c4bd8b6

Browse files
committed
removing uidProperty since we use the distinguished name and it is not a part of the ldap object
1 parent cb5ad61 commit c4bd8b6

File tree

4 files changed

+5
-18
lines changed

4 files changed

+5
-18
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99
### Server
1010
#### Added
11-
- User UID and username properties mapping with ldap can now be set with specific parameters or environment variable.
11+
- User username properties mapping with ldap can now be set with specific parameters or environment variable.
1212

1313
#### Changed
1414
- Parameter `--member-of-property` is now `--memberof-property` (style consistency change)

cmd/server.go

-8
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@ func getServerCmd() *cli.Command {
7575
EnvVars: []string{"LDAP_USER_USERNAMEPROPERTY"},
7676
Usage: "The `PROPERTY` that will be used as username in the TokenReview.",
7777
},
78-
&cli.StringFlag{
79-
Name: "uid-property",
80-
Value: "dn",
81-
EnvVars: []string{"LDAP_USER_UIDPROPERTY"},
82-
Usage: "The `PROPERTY` that will be used as uid in the TokenReview.",
83-
},
8478
&cli.StringSliceFlag{
8579
Name: "extra-attributes",
8680
EnvVars: []string{"LDAP_USER_EXTRAATTR"},
@@ -125,7 +119,6 @@ func getServerCmd() *cli.Command {
125119
searchAttributes = c.StringSlice("search-attributes")
126120
memberofProperty = c.String("memberof-property")
127121
usernameProperty = c.String("username-property")
128-
uidProperty = c.String("uid-property")
129122

130123
privateKeyFile = c.String("private-key-file")
131124
publicKeyFile = c.String("public-key-file")
@@ -145,7 +138,6 @@ func getServerCmd() *cli.Command {
145138
searchFilter,
146139
memberofProperty,
147140
usernameProperty,
148-
uidProperty,
149141
searchAttributes,
150142
),
151143
server.WithAccessLogs(),

ldap/ldap.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ type Ldap struct {
1919
searchFilter string
2020
memberofProperty string
2121
usernameProperty string
22-
uidProperty string
2322
extraAttributes []string
2423
searchAttributes []string
2524
}
@@ -42,8 +41,7 @@ func NewInstance(
4241
searchScope,
4342
searchFilter,
4443
memberofProperty,
45-
usernameProperty,
46-
uidProperty string,
44+
usernameProperty string,
4745
extraAttributes,
4846
searchAttributes []string,
4947
) *Ldap {
@@ -56,7 +54,6 @@ func NewInstance(
5654
searchFilter: searchFilter,
5755
memberofProperty: memberofProperty,
5856
usernameProperty: usernameProperty,
59-
uidProperty: uidProperty,
6057
extraAttributes: extraAttributes,
6158
searchAttributes: searchAttributes,
6259
}
@@ -124,7 +121,7 @@ func (s *Ldap) Search(username string) (*auth.UserInfo, error) {
124121
}
125122

126123
user := &auth.UserInfo{
127-
UID: strings.ToLower(result.Entries[0].GetAttributeValue(s.uidProperty)),
124+
UID: strings.ToLower(result.Entries[0].DN),
128125
Username: strings.ToLower(result.Entries[0].GetAttributeValue(s.usernameProperty)),
129126
Groups: sanitize(result.Entries[0].GetAttributeValues(s.memberofProperty)),
130127
Extra: extra,

server/options.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ func WithLdap(
2323
searchScope,
2424
searchFilter,
2525
memberofProperty,
26-
usernameProperty,
27-
uidProperty string,
26+
usernameProperty string,
2827
extraAttributes []string) Option {
2928
return func(i *Instance) error {
3029
i.l = ldap.NewInstance(
@@ -36,9 +35,8 @@ func WithLdap(
3635
searchFilter,
3736
memberofProperty,
3837
usernameProperty,
39-
uidProperty,
4038
extraAttributes,
41-
append(extraAttributes, memberofProperty, usernameProperty, uidProperty),
39+
append(extraAttributes, memberofProperty, usernameProperty),
4240
)
4341

4442
return nil

0 commit comments

Comments
 (0)