-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Account autocreation from LDAP after reverse proxy authentication #12960
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bd8361d
Account autocreation from LDAP after reverse proxy authentication
pboguslawski 3df7fb6
Inital language setting on reverse proxy login
pboguslawski 0149559
Fixed user session initialization on login with reverse proxy header
pboguslawski 41ddcd0
Fixed user session initialization on login with reverse proxy header
pboguslawski 53a9b26
Fixed user session initialization on login with reverse proxy header
pboguslawski 22441d9
Fixed user session initialization on login with reverse proxy header
pboguslawski 46304f2
Fixed user session initialization on login with reverse proxy header
pboguslawski cb48990
Fixed user session initialization on login with reverse proxy header
pboguslawski 6bba0ba
Fixed user session initialization on login with reverse proxy header
pboguslawski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -230,12 +230,22 @@ func checkRestricted(l *ldap.Conn, ls *Source, userDN string) bool { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// SearchEntry : search an LDAP source if an entry (name, passwd) is valid and in the specific filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResult { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (ls *Source) SearchEntry(name, passwd string, directBind bool, alreadyAuthenticated bool) *SearchResult { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// See https://tools.ietf.org/search/rfc4513#section-5.1.2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if len(passwd) == 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if len(passwd) == 0 && !alreadyAuthenticated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.Debug("Auth. failed for %s, password cannot be empty", name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if directBind && alreadyAuthenticated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.Debug("Cannot bind using user %s credentials - user already authenticated. BindDN must be used.", name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if !ls.AttributesInBind && alreadyAuthenticated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.Debug("Cannot get attributes using user %s credentials - user already authenticated; --attributes-in-bind must be used.", name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+235
to
+248
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.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
l, err := dial(ls) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
log.Error("LDAP Connect error, %s:%v", ls.Host, err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -393,8 +403,8 @@ func (ls *Source) SearchEntry(name, passwd string, directBind bool) *SearchResul | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
isRestricted = checkRestricted(l, ls, userDN) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if !directBind && ls.AttributesInBind { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// binds user (checking password) after looking-up attributes in BindDN context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if !directBind && ls.AttributesInBind && !alreadyAuthenticated { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// binds user (checking password) after looking-up attributes in BindDN context if not already authenticated | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
err = bindUser(l, userDN, passwd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I guess one thing I don't really like about this is that the user has already signed in - we're just abusing this function to lookup the user in the external source - and only in one place (at least so far). Maybe we should be doing a ExternalUserLookup or something like that.
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.
Further if the user is in the db then this alreadyAuthenticated path fails.
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 mod works ok for us in scenario with LDAP user backend + reverse proxy auth using HTTP header. No problems with initial account creation nor logging in/updating existing accounts from LDAP. If you see any bug please describe how to reproduce.
This mod was created for our needs with minimal changes in upstream code. Feel free to enhance it.