-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Support wildcards in email domain whitelisting #20257
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
Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
b69dda0
added code to match on asterisk wildcard
KingBain 2d358ee
updated test to validate wildcard
KingBain 4bc90fb
updated change to use glob for pattern matching
KingBain d85cdd2
should resolve issue with liniting
KingBain 4488d97
Update services/forms/user_form.go
KingBain 8063c65
made changes to use an array of compiled globs
KingBain f413f48
Merge branch 'main' into main
KingBain b47326d
Merge branch 'main' into main
KingBain 5cba7be
Moved BuildEmailGlobs to service.go
KingBain 3778a30
called BuildEmailGlobs from settings pkg
KingBain cc023a4
Merge branch 'main' into main
KingBain e4135bc
Merge branch 'go-gitea:main' into main
KingBain 55b21a7
included capturing glob compile erro catching.
KingBain dbafa36
space added to import statements, local variable name made lowercase.
KingBain 7752c87
updaed message to show glob will be skipped
KingBain 404685a
added space to import statements
KingBain 8887b15
Merge branch 'go-gitea:main' into main
KingBain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ import ( | |
func TestRegisterForm_IsDomainAllowed_Empty(t *testing.T) { | ||
_ = setting.Service | ||
|
||
setting.Service.EmailDomainWhitelist = []string{} | ||
setting.Service.EmailDomainWhitelist = setting.BuildEmailGlobs([]string{}) | ||
|
||
form := RegisterForm{} | ||
|
||
|
@@ -25,7 +25,7 @@ func TestRegisterForm_IsDomainAllowed_Empty(t *testing.T) { | |
func TestRegisterForm_IsDomainAllowed_InvalidEmail(t *testing.T) { | ||
_ = setting.Service | ||
|
||
setting.Service.EmailDomainWhitelist = []string{"gitea.io"} | ||
setting.Service.EmailDomainWhitelist = setting.BuildEmailGlobs([]string{"gitea.io"}) | ||
|
||
tt := []struct { | ||
email string | ||
|
@@ -44,7 +44,7 @@ func TestRegisterForm_IsDomainAllowed_InvalidEmail(t *testing.T) { | |
func TestRegisterForm_IsDomainAllowed_WhitelistedEmail(t *testing.T) { | ||
_ = setting.Service | ||
|
||
setting.Service.EmailDomainWhitelist = []string{"gitea.io"} | ||
setting.Service.EmailDomainWhitelist = setting.BuildEmailGlobs([]string{"gitea.io", "*.gc.ca"}) | ||
|
||
tt := []struct { | ||
email string | ||
|
@@ -54,6 +54,7 @@ func TestRegisterForm_IsDomainAllowed_WhitelistedEmail(t *testing.T) { | |
{"[email protected]", true}, | ||
{"hdudhdd", false}, | ||
{"[email protected]", false}, | ||
{"[email protected]", true}, | ||
} | ||
|
||
for _, v := range tt { | ||
|
@@ -66,8 +67,8 @@ func TestRegisterForm_IsDomainAllowed_WhitelistedEmail(t *testing.T) { | |
func TestRegisterForm_IsDomainAllowed_BlocklistedEmail(t *testing.T) { | ||
_ = setting.Service | ||
|
||
setting.Service.EmailDomainWhitelist = []string{} | ||
setting.Service.EmailDomainBlocklist = []string{"gitea.io"} | ||
setting.Service.EmailDomainWhitelist = setting.BuildEmailGlobs([]string{}) | ||
setting.Service.EmailDomainBlocklist = setting.BuildEmailGlobs([]string{"gitea.io", "*.gov"}) | ||
|
||
tt := []struct { | ||
email string | ||
|
@@ -76,6 +77,7 @@ func TestRegisterForm_IsDomainAllowed_BlocklistedEmail(t *testing.T) { | |
{"[email protected]", false}, | ||
{"[email protected]", true}, | ||
{"hdudhdd", true}, | ||
{"[email protected]", false}, | ||
} | ||
|
||
for _, v := range tt { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.