Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Domain matching should be case insensitive #332

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ func ValidateDomains(email string, domains CommaSeparatedList) bool {
if len(parts) < 2 {
return false
}
emailDomain := strings.ToLower(parts[1])
for _, domain := range domains {
if domain == parts[1] {
if domain == emailDomain {
return true
}
}
Expand Down
5 changes: 5 additions & 0 deletions internal/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func TestAuthValidateEmail(t *testing.T) {
v = ValidateEmail("[email protected]", "default")
assert.True(v, "should allow user from allowed domain")

// Should match regardless of domain case
config.Domains = []string{"test.com"}
v = ValidateEmail("[email protected]", "default")
assert.True(v, "should allow user from allowed domain, regardless of case")

// Should allow matching whitelisted email address
config.Domains = []string{}
config.Whitelist = []string{"[email protected]"}
Expand Down