Modify whitelist implementation + expand docs

Closes #4
This commit is contained in:
Thom Seddon
2018-11-06 14:01:06 +00:00
parent eaad0a9054
commit 1832672f5e
2 changed files with 20 additions and 15 deletions

View File

@ -88,7 +88,13 @@ func (f *ForwardAuth) ValidateCookie(r *http.Request, c *http.Cookie) (bool, str
// Validate email
func (f *ForwardAuth) ValidateEmail(email string) bool {
found := false
if len(f.Domain) > 0 {
if len(f.Whitelist) > 0 {
for _, whitelist := range f.Whitelist {
if email == whitelist {
found = true
}
}
} else if len(f.Domain) > 0 {
parts := strings.Split(email, "@")
if len(parts) < 2 {
return false
@ -98,21 +104,11 @@ func (f *ForwardAuth) ValidateEmail(email string) bool {
found = true
}
}
if !found {
return false
}
} else if len(f.Whitelist) > 0 {
for _, wlEmail := range f.Whitelist {
if wlEmail == email {
found = true
}
}
if !found {
return false
}
} else {
return true
}
return true
return found
}