mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2025-02-13 22:01:16 +00:00
Compare commits
3 Commits
1520e78bad
...
34652f8f3e
Author | SHA1 | Date | |
---|---|---|---|
|
34652f8f3e | ||
|
79f52ed880 | ||
|
ee16bf9e21 |
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user