Skip to content

[Feature] Introduce sender-blacklists (on both global/admin and user level)#2694

Open
chrisblech wants to merge 17 commits intosimple-login:masterfrom
chrisblech:feature/user-blacklists
Open

[Feature] Introduce sender-blacklists (on both global/admin and user level)#2694
chrisblech wants to merge 17 commits intosimple-login:masterfrom
chrisblech:feature/user-blacklists

Conversation

@chrisblech
Copy link
Copy Markdown
Contributor

While using a self-hosted instance für some months now with a throughput of more than 5000 mails/month and consequently manually disabling spam-sender (on contact level), simplelogin blocks about 600 SPAM mails per month.
When looking at the remaining 350 spam mails that are still forwarded to my inbox (and get caught by GMails SPAM sensor), I realize that a significant amount of them belongs to "spammer-domains" or at least follow the same pattern.

This PR adds two levels of sender blacklists to SimpleLogin: Admin and Users can use this to block sender addresses (or whole domains / TLDs) by regex pattern.

  • New DB table global_sender_blacklist (pattern regex + enabled + comment)
  • Admin UI (Flask-Admin) and User UI (Settings) to manage patterns
  • Inbound SMTP handling: unknown senders matching the blacklist create a Contact that is disabled. The following (untouched) mail handling logic will using the pre-existing behavior as a blocked Contact (2xx vs 5xx depending on user.block_behaviour)
  • Users can override the global logic, by (re-)enabling a disabled Contact.

Migration and tests are included.

[Bonus/Example] My personal blacklist patterns:

  • @novastek\.homes$
  • @devalser\.hair$
  • @tabot\.com\.tr$
  • @casang\.vip$
  • ^[a-z]+[0-9]{5}@[a-z]+\.[a-z]+\.shop$
  • @juntadeandalucia\.es$
  • @resend\.dev$

@acasajus
Copy link
Copy Markdown
Collaborator

Please move the management of the ForbiddenEnvelopeSender into a separate file that can be tested and called from other places instead of adding more code to the settings page.

@acasajus
Copy link
Copy Markdown
Collaborator

Also there are no tests for per-user entry, regex validation on entry or deletion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants