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 #2

Merged
merged 3 commits into from
Nov 5, 2022
Merged
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(user 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 TestAuthValidateUser(t *testing.T) {
v = ValidateUser("test@test.com", "default")
assert.True(v, "should allow user from allowed domain")

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

// Should block non whitelisted email address
config.Domains = []string{}
config.Whitelist = []string{"test@test.com"}
Expand Down