1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2024-11-24 08:52:25 +02:00

Ignore spaces in authorized emails list

This commit is contained in:
Stan Hu 2015-12-23 00:08:51 -08:00
parent beebf4dff9
commit dd4642813b
2 changed files with 15 additions and 1 deletions

View File

@ -53,7 +53,8 @@ func (um *UserMap) LoadAuthenticatedEmailsFile() {
}
updated := make(map[string]bool)
for _, r := range records {
updated[strings.ToLower(r[0])] = true
address := strings.ToLower(strings.TrimSpace(r[0]))
updated[address] = true
}
atomic.StorePointer(&um.m, unsafe.Pointer(&updated))
}

View File

@ -147,3 +147,16 @@ func TestValidatorComparisonsAreCaseInsensitive(t *testing.T) {
t.Error("validated domains are not lower-cased")
}
}
func TestValidatorIgnoreSpacesInAuthEmails(t *testing.T) {
vt := NewValidatorTest(t)
defer vt.TearDown()
vt.WriteEmails(t, []string{" foo.bar@example.com "})
domains := []string(nil)
validator := vt.NewValidator(domains, nil)
if !validator("foo.bar@example.com") {
t.Error("email should validate")
}
}