validator: add LDAP auth
This commit is contained in:
parent
a750e2d7ce
commit
23ab4264f9
2 changed files with 99 additions and 5 deletions
|
@ -12,10 +12,19 @@ var tftpDir string
|
|||
func main() {
|
||||
var studentsFile string
|
||||
|
||||
var lc loginChecker
|
||||
|
||||
var bind = flag.String("bind", ":8081", "Bind port/socket")
|
||||
flag.StringVar(&studentsFile, "students", "./students.csv", "Path to a CSV file containing students list")
|
||||
flag.StringVar(&ARPTable, "arp", ARPTable, "Path to ARP table")
|
||||
flag.StringVar(&tftpDir, "tftpdir", "/var/tftp/", "Path to TFTPd directory")
|
||||
|
||||
flag.StringVar(&lc.ldapAddr, "ldaphost", "auth.cri.epita.fr", "LDAP host")
|
||||
flag.IntVar(&lc.ldapPort, "ldapport", 636, "LDAP port")
|
||||
flag.BoolVar(&lc.ldapIsTLS, "ldaptls", false, "Is LDAP connection LDAPS?")
|
||||
flag.StringVar(&lc.ldapBase, "ldapbase", "dc=epita,dc=net", "LDAP base")
|
||||
flag.StringVar(&lc.ldapBindUsername, "ldapbindusername", "", "LDAP user to use in order to perform bind (optional if search can be made anonymously)")
|
||||
flag.StringVar(&lc.ldapBindPassword, "ldapbindpassword", "", "Password for the bind user")
|
||||
flag.Parse()
|
||||
|
||||
var err error
|
||||
|
@ -26,8 +35,7 @@ func main() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var students []Student
|
||||
students, err = readStudentsList(studentsFile)
|
||||
lc.students, err = readStudentsList(studentsFile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -35,7 +43,7 @@ func main() {
|
|||
log.Println("Registering handlers...")
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/", Index)
|
||||
mux.Handle("/login", loginChecker{students})
|
||||
mux.Handle("/login", lc)
|
||||
http.HandleFunc("/", mux.ServeHTTP)
|
||||
|
||||
log.Println("Ready, listening on port", *bind)
|
||||
|
|
Reference in a new issue