Compare commits

...

3 Commits

Author SHA1 Message Date
Yohann D'ANELLO 34652f8f3e
I am an idiot, don't let only people with the *wrong* password stream 2021-01-08 23:05:01 +01:00
Yohann D'ANELLO 79f52ed880
Log the LDAP connection 2021-01-08 22:56:19 +01:00
Yohann D'ANELLO ee16bf9e21
Alias is not properly replaced 2021-01-08 22:46:14 +01:00
2 changed files with 5 additions and 1 deletions

View File

@ -42,6 +42,7 @@ func (a LDAP) Login(username string, password string) (bool, string, error) {
for _, username := range potentialUsernames {
// Try to bind as user
bindDn := "cn=" + username + "," + a.Cfg.UserDn
log.Printf("[LDAP] Logging to %s...", bindDn)
err = a.Conn.Bind(bindDn, password)
if err == nil {
// Login succeeded if no error
@ -49,6 +50,7 @@ func (a LDAP) Login(username string, password string) (bool, string, error) {
}
}
log.Printf("[LDAP] Logging failed: %s", err)
// Unable to log in
return err == nil, "", err
}

View File

@ -82,11 +82,13 @@ func Serve(streams *messaging.Streams, authBackend auth.Backend, cfg *Options) {
name, password := split[0], split[1]
if authBackend != nil {
// check password
if ok, name, err := authBackend.Login(name, password); !ok || err != nil {
ok, username, err := authBackend.Login(name, password)
if !ok || err != nil {
log.Printf("Failed to authenticate for stream %s", name)
s.Close()
continue
}
name = username
}
go handleStreamer(s, streams, name)