From f93371e4491fa068bc3fa34534e766a5e1a8e753 Mon Sep 17 00:00:00 2001 From: mr Date: Fri, 23 Jan 2026 10:22:14 +0100 Subject: [PATCH] ldap -> auth --- infrastructure/auth_connector/ldap.go | 9 +++------ main.go | 7 ++++--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/infrastructure/auth_connector/ldap.go b/infrastructure/auth_connector/ldap.go index 211bafd..133952b 100644 --- a/infrastructure/auth_connector/ldap.go +++ b/infrastructure/auth_connector/ldap.go @@ -87,22 +87,19 @@ func (cli *Client) Authenticate(ctx context.Context, username string, password s var cancel context.CancelFunc ctx, cancel = context.WithCancel(ctx) - + fmt.Println("Connect", ctx, username, password) cn, ok := <-cli.connect(ctx) cancel() if !ok { return false, errConnectionTimeout } defer cn.Close() - + fmt.Println("findBasicUserDetails", cn, username, password) // Find a user DN by his or her username. details, err := cli.findBasicUserDetails(cn, username, []string{"dn"}) - if err != nil { + if err != nil || details == nil { return false, err } - if details == nil { - return false, nil - } a := details["dn"] log.Println("Binding DN:", a[0], "with password:", password) if err := cn.Bind(a[0], password); err != nil { diff --git a/main.go b/main.go index 12df0f7..99a51ad 100644 --- a/main.go +++ b/main.go @@ -9,6 +9,7 @@ import ( auth_connectors "oc-auth/infrastructure/auth_connector" _ "oc-auth/routers" "os" + "runtime/debug" "strconv" "strings" "time" @@ -75,7 +76,7 @@ func main() { func generateRole() { defer func() { if r := recover(); r != nil { - fmt.Println("Recovered in f", r) + fmt.Println("Recovered in f", r, debug.Stack()) } }() // if from ldap, create roles from ldap @@ -105,7 +106,7 @@ func generateRole() { func generateSelfPeer() error { defer func() { if r := recover(); r != nil { - fmt.Println("Recovered in f", r) + fmt.Println("Recovered in f", r, debug.Stack()) } }() log := rlog.FromContext(context.Background()).Sugar() @@ -164,7 +165,7 @@ func generateSelfPeer() error { func discovery() { defer func() { if r := recover(); r != nil { - fmt.Println("Recovered in f", r) + fmt.Println("Recovered in f", r, debug.Stack()) } }() for {