Allow override of automatically assigned delegated domain
This commit is contained in:
parent
54a3fe9192
commit
c4da666a1e
3 changed files with 29 additions and 4 deletions
|
|
@ -30,6 +30,15 @@ func init() {
|
|||
}
|
||||
|
||||
func validateAuthToken(s *adlin.Student, _ httprouter.Params, _ []byte) (interface{}, error) {
|
||||
if s.DelegatedDomain != nil {
|
||||
for _, ddomain := range adlin.DelegatedDomainSuffixes {
|
||||
if strings.HasSuffix(*s.DelegatedDomain, ddomain) {
|
||||
s.DelegatedDomain = nil
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,14 @@ func init() {
|
|||
return true, nil
|
||||
} else {
|
||||
ns := dns.Fqdn(ue.NS)
|
||||
|
||||
// Ensure ns doesn't belong to one of our domain
|
||||
for _, ddomain := range adlin.DelegatedDomainSuffixes {
|
||||
if strings.HasSuffix(ns, ddomain) {
|
||||
return nil, fmt.Errorf("Vous ne pouvez pas vous créer une délégation vers ce sous-domaine: interdit par l'administrateur.")
|
||||
}
|
||||
}
|
||||
|
||||
student.DelegatedDomain = &ns
|
||||
|
||||
if _, err := student.Update(); err != nil {
|
||||
|
|
|
|||
Reference in a new issue