Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

return invalid credentials when user was not found #30

Merged
merged 1 commit into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-bind-when-not-found.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: return invalid credentials when user was not found

We were relying on an error code of the ListAccounts call when the username and password was wrong. But the list will be empty if no user with the given login was found. So we also need to check if the list of accounts is empty.

https://github.com/owncloud/ocis-glauth/pull/30
4 changes: 2 additions & 2 deletions pkg/server/glauth/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ func (h ocisHandler) Bind(bindDN, bindSimplePw string, conn net.Conn) (ldap.LDAP
userName := strings.TrimPrefix(parts[0], "cn=")

// check password
_, err := h.as.ListAccounts(context.TODO(), &accounts.ListAccountsRequest{
res, err := h.as.ListAccounts(context.TODO(), &accounts.ListAccountsRequest{
//Query: fmt.Sprintf("username eq '%s'", username),
// TODO this allows lookung up users when you know the username using basic auth
// adding the password to the query is an option but sending the sover the wira a la scim seems ugly
// but to set passwords our accounts need it anyway
Query: fmt.Sprintf("login eq '%s' and password eq '%s'", userName, bindSimplePw),
})
if err != nil {
if err != nil || len(res.Accounts) == 0 {
h.log.Error().
Str("username", userName).
Str("binddn", bindDN).
Expand Down