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

Allow blocking some email domains from registering an account #14667

Merged
merged 7 commits into from
Feb 14, 2021
Merged

Allow blocking some email domains from registering an account #14667

merged 7 commits into from
Feb 14, 2021

Conversation

gouttegd
Copy link
Contributor

@gouttegd gouttegd commented Feb 13, 2021

Gitea allows to whitelist email domains so that only email addresses from certain domains are allowed to register an account, but does not currently allows to do the opposite: blacklisting email domains so that addresses from certain domains are forbidden to register an account.

The idea has been briefly mentioned in the discussion about issue #6350, but never implemented. This PR does that.

The rationale is that, in my experience of running a Gitea instance, a single email domain is responsible for most of the spam accounts, and for all of the spam accounts that manage to get past the email confirmation step. So on top of the other spam mitigation measures already available (email confirmation, CAPTCHA, etc.), having the option to block a particularly annoying domain would be helpful.

close #13628

Add a new configuration setting EMAIL_DOMAIN_BLACKLIST, which
accepts a comma-separated lsit of email domains that should not
be allowed to register an account on the instance.

Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
Document the EMAIL_DOMAIN_BLACKLIST setting in the configuration
cheat sheet and the sample configuration file. Also mention it
in the FAQ as one of the ways to mitigate spam accounts.

Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 13, 2021
custom/conf/app.example.ini Outdated Show resolved Hide resolved
modules/forms/user_form.go Outdated Show resolved Hide resolved
@6543 6543 added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Feb 13, 2021
@6543 6543 added this to the 1.15.0 milestone Feb 13, 2021
gouttegd and others added 4 commits February 13, 2021 15:40
Rename the EMAIL_DOMAIN_BLACKLIST setting to EMAIL_DOMAIN_BLOCKLIST.
Change all references in the code and docs accordingly.

Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
Avoid code duplication by using a helper function to check
whether an email domain is in a given list.

Rename IsEmailDomainWhitelisted to IsEmailDomainAllowed, to
better reflect the new semantics of that method which is now
checking against either a whitelist or a blocklist.

Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
Add a test fixture for the new email domain blocklist setting.

Signed-off-by: Damien Goutte-Gattat <dgouttegattat@incenp.org>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 14, 2021
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 14, 2021
@lafriks lafriks modified the milestones: 1.15.0, 1.14.0 Feb 14, 2021
@6543
Copy link
Member

6543 commented Feb 14, 2021

🚀

@6543 6543 merged commit fc4a8c2 into go-gitea:master Feb 14, 2021
@gouttegd gouttegd deleted the email-domain-blacklist branch February 15, 2021 11:25
@go-gitea go-gitea locked and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] block-/allow-list for emails
4 participants