-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Use service bind for searching LDAP groups #2534
Changes from 1 commit
71fd6e8
7583c60
ab7f99c
ee62b8f
286c3b8
9ec9434
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,17 @@ func (b *backend) Login(req *logical.Request, username string, password string) | |
return nil, logical.ErrorResponse(fmt.Sprintf("LDAP bind failed: %v", err)), nil | ||
} | ||
|
||
// We re-bind to the BindDN if it's defined because we assume | ||
// the BindDN should be the one to search, not the user logging in. | ||
if cfg.DiscoverDN || (cfg.BindDN != "" && cfg.BindPassword != "") { | ||
if err := c.Bind(cfg.BindDN, cfg.BindPassword); err != nil { | ||
return nil, logical.ErrorResponse(err.Error()), nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given we are performing up to three binds per login - I think we should improve the error messages to more clearly indicate where in the process we failed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So maybe:
|
||
} | ||
if b.Logger().IsDebug() { | ||
b.Logger().Debug("auth/ldap: Re-Bound to original BindDN") | ||
} | ||
} | ||
|
||
userDN, err := b.getUserDN(cfg, c, bindDN) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Between Also note There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would make sense to me, but if we're going to go down that path, shouldn't we rename the |
||
if err != nil { | ||
return nil, logical.ErrorResponse(err.Error()), nil | ||
|
@@ -165,7 +176,7 @@ func (b *backend) Login(req *logical.Request, username string, password string) | |
policies = append(policies, group.Policies...) | ||
} | ||
} | ||
if user !=nil && user.Policies != nil { | ||
if user != nil && user.Policies != nil { | ||
policies = append(policies, user.Policies...) | ||
} | ||
// Policies from each group may overlap | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is symmetric with the logic from
getBindDN
- my only hesitation is that in cases where(cfg.DiscoverDN == true && (cfg.BindDN == "" || cfg.BindPassword == "")
- we will do an anonymous rebind after an authenticated user bind - potentially resulting in more restricted privileges.I am not sure whether that is a realistic configuration to know whether this is a valid concern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shomron, should I just get rid of
cfg.DiscoverDN
clause? And simply re-bind if the second clause is true? That makes the most sense to me.