ldap -> auth

This commit is contained in:
mr
2026-01-23 10:22:14 +01:00
parent 013c6969c5
commit f93371e449
2 changed files with 7 additions and 9 deletions

View File

@@ -87,22 +87,19 @@ func (cli *Client) Authenticate(ctx context.Context, username string, password s
var cancel context.CancelFunc var cancel context.CancelFunc
ctx, cancel = context.WithCancel(ctx) ctx, cancel = context.WithCancel(ctx)
fmt.Println("Connect", ctx, username, password)
cn, ok := <-cli.connect(ctx) cn, ok := <-cli.connect(ctx)
cancel() cancel()
if !ok { if !ok {
return false, errConnectionTimeout return false, errConnectionTimeout
} }
defer cn.Close() defer cn.Close()
fmt.Println("findBasicUserDetails", cn, username, password)
// Find a user DN by his or her username. // Find a user DN by his or her username.
details, err := cli.findBasicUserDetails(cn, username, []string{"dn"}) details, err := cli.findBasicUserDetails(cn, username, []string{"dn"})
if err != nil { if err != nil || details == nil {
return false, err return false, err
} }
if details == nil {
return false, nil
}
a := details["dn"] a := details["dn"]
log.Println("Binding DN:", a[0], "with password:", password) log.Println("Binding DN:", a[0], "with password:", password)
if err := cn.Bind(a[0], password); err != nil { if err := cn.Bind(a[0], password); err != nil {

View File

@@ -9,6 +9,7 @@ import (
auth_connectors "oc-auth/infrastructure/auth_connector" auth_connectors "oc-auth/infrastructure/auth_connector"
_ "oc-auth/routers" _ "oc-auth/routers"
"os" "os"
"runtime/debug"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@@ -75,7 +76,7 @@ func main() {
func generateRole() { func generateRole() {
defer func() { defer func() {
if r := recover(); r != nil { 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 // if from ldap, create roles from ldap
@@ -105,7 +106,7 @@ func generateRole() {
func generateSelfPeer() error { func generateSelfPeer() error {
defer func() { defer func() {
if r := recover(); r != nil { 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() log := rlog.FromContext(context.Background()).Sugar()
@@ -164,7 +165,7 @@ func generateSelfPeer() error {
func discovery() { func discovery() {
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
fmt.Println("Recovered in f", r) fmt.Println("Recovered in f", r, debug.Stack())
} }
}() }()
for { for {