login-validator: Refactor, search csv in /data dir

This commit is contained in:
nemunaire 2023-02-25 14:42:40 +01:00
parent 679668e2c2
commit 50ad1f0712
4 changed files with 16 additions and 12 deletions

View File

@ -18,4 +18,6 @@ COPY --from=gobuild /go/src/login-validator/login-validator /bin/login-validator
ENTRYPOINT ["/bin/login-validator", "-bind=:8081"]
WORKDIR /data
LABEL org.mobyproject.config='{"capabilities": ["CAP_NET_BIND_SERVICE"]}'

View File

@ -52,7 +52,7 @@ func main() {
log.Fatal(err)
}
var lc loginChecker
lc := &loginChecker{}
if auth != nil && *auth == "ldap" {
log.Printf("Auth method: LDAP(%s@%s:%d?%s)", *ldapbindusername, *ldapAddr, *ldapPort, *ldapbase)
@ -87,6 +87,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
log.Printf("%d students loaded", len(lc.students))
// Prepare graceful shutdown
interrupt := make(chan os.Signal, 1)
@ -100,7 +101,7 @@ func main() {
log.Println("Registering handlers...")
mux := http.NewServeMux()
mux.Handle("/login", &lc)
mux.Handle("/login", lc)
mux.HandleFunc("/logout", logout)
mux.HandleFunc("/passwd", passwd)
http.HandleFunc("/", mux.ServeHTTP)

View File

@ -26,15 +26,13 @@ func readStudentsList(studentsFile string) (stds []Student, err error) {
return nil, err
} else {
for _, i := range list {
var s Student
s.Lastname = i[0]
s.Firstname = i[1]
s.Login = i[2]
s.EMail = i[3]
s.Phone = i[4]
stds = append(stds, s)
stds = append(stds, Student{
Lastname: i[0],
Firstname: i[1],
Login: i[2],
EMail: i[3],
Phone: i[4],
})
}
return stds, nil

View File

@ -162,13 +162,16 @@ services:
net: /run/netns/login
binds:
- /etc/resolv.conf:/etc/resolv.conf:ro
- /var/lib/adlin/students.csv:/students.csv:ro
- /var/lib/adlin/students:/data/:ro
- /var/lib/adlin/pxelinux.cfg:/var/tftp/pxelinux.cfg
- /var/lib/adlin/shadows:/var/tftp/shadows
- /srv/solver.sh:/var/solver.sh:ro
- /srv/tftp/challenge-initrd.img:/var/tftp/challenge-initrd.img:ro
- /etc/ssl/certs:/etc/ssl/certs:ro
- /usr/share/ca-certificates:/usr/share/ca-certificates:ro
runtime:
mkdir:
- /var/lib/adlin/students
- name: nginx-login
image: nginx:stable-alpine
capabilities: