Compare commits

...

3 Commits

Author SHA1 Message Date
Chris F Ravenscroft 54727ce9af Merge branch 'master' into pr-470 2026-07-18 14:55:52 -07:00
Chris F Ravenscroft c8e7a7e7e6 fix: use configHandler.Bind rather than helper.Bind in test harness 2026-07-18 14:44:15 -07:00
kanywst 2e125a4a2f fix: reject disabled users on all backends in Bind
A user with disabled = true could still bind on the config backend, since
configHandler.FindUser and LDAPOpsHelper.Bind never checked Disabled while the
SQL backends drop such users at lookup. Enforce it in Bind so every backend
behaves the same.
2026-07-19 00:10:27 +09:00
+16 -3
View File
@@ -1,7 +1,6 @@
package handler
import (
"context"
"encoding/hex"
"net"
"testing"
@@ -14,9 +13,22 @@ import (
"github.com/glauth/ldap"
)
type disabledBindTestMonitor struct{}
func (disabledBindTestMonitor) SetResponseTimeMetric(map[string]string, float64) error {
return nil
}
func (disabledBindTestMonitor) SetLDAPMetric(map[string]string, float64) error {
return nil
}
func TestConfigBackendDisabledUserCannotBind(t *testing.T) {
pw := "correct horse"
raw, _ := bcrypt.GenerateFromPassword([]byte(pw), bcrypt.MinCost)
raw, err := bcrypt.GenerateFromPassword([]byte(pw), bcrypt.MinCost)
if err != nil {
t.Fatal(err)
}
hexHash := hex.EncodeToString(raw)
cfg := &config.Config{}
@@ -37,13 +49,14 @@ func TestConfigBackendDisabledUserCannotBind(t *testing.T) {
log: &logger,
cfg: cfg,
ldohelper: helper,
monitor: disabledBindTestMonitor{},
tracer: tracer,
}
_, server := net.Pipe()
defer server.Close()
bind := func(dn, pass string) ldap.LDAPResultCode {
code, _ := helper.Bind(context.Background(), h, dn, pass, server)
code, _ := h.Bind(dn, pass, server)
return code
}