Add logging, including the json one
get infos from I've been pwned and the API on install.dm.gg/vpn-log.php and send mail if there is anything strange
This commit is contained in:
11
ldap.go
11
ldap.go
@@ -111,8 +111,7 @@ func (conf *ldapConfig) Auth(logins []string, pass string) (e error, userOk, pas
|
||||
return err, false, false, nil
|
||||
}
|
||||
if len(sr.Entries) != 1 {
|
||||
log.Println("User does not exist or too many entries returned")
|
||||
return nil, false, false, nil
|
||||
return errors.New("User does not exist or too many entries returned"), false, false, nil
|
||||
}
|
||||
|
||||
// check the attributes requested in the search
|
||||
@@ -128,12 +127,12 @@ func (conf *ldapConfig) Auth(logins []string, pass string) (e error, userOk, pas
|
||||
|
||||
// user must have both primary and secondary attributes
|
||||
if len(primary) == 0 {
|
||||
log.Printf("User has no %s attribute", conf.primaryAttribute)
|
||||
log.Printf("User %s has no %s attribute", logins[0], conf.primaryAttribute)
|
||||
return nil, false, false, nil
|
||||
}
|
||||
|
||||
if len(secondary) == 0 {
|
||||
log.Printf("User has no %s attribute", conf.secondaryAttribute)
|
||||
log.Printf("User %s has no %s attribute", logins[0], conf.secondaryAttribute)
|
||||
return nil, false, false, nil
|
||||
}
|
||||
|
||||
@@ -150,7 +149,7 @@ func (conf *ldapConfig) Auth(logins []string, pass string) (e error, userOk, pas
|
||||
attributes = secondary
|
||||
}
|
||||
|
||||
log.Printf("User has a valid account on %s", s)
|
||||
log.Printf("User %s has a valid account on %s", logins[0], s)
|
||||
|
||||
userdn := sr.Entries[0].DN
|
||||
|
||||
@@ -165,7 +164,7 @@ func (conf *ldapConfig) Auth(logins []string, pass string) (e error, userOk, pas
|
||||
}
|
||||
|
||||
// everything is fine,
|
||||
log.Printf("User has a valid password on %s", s)
|
||||
log.Printf("User %s has a valid password on %s", logins[0], s)
|
||||
return nil, true, true, attributes
|
||||
}
|
||||
// if we are here, no server is responding, rejectif auth
|
||||
|
||||
Reference in New Issue
Block a user