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

Supplying blacklist / whitelist domains from array vs yml file? #222

Open
scouttyg opened this issue Oct 4, 2023 · 2 comments
Open

Supplying blacklist / whitelist domains from array vs yml file? #222

scouttyg opened this issue Oct 4, 2023 · 2 comments

Comments

@scouttyg
Copy link

scouttyg commented Oct 4, 2023

Hey there,

I've used this library quite a few times in the past, and even initially suggested the MX spam lookup trick (#95)

It's now a few years later, and I have a new suggestion -- allowing the blacklist / whitelist option to take an array vs a boolean.

E.g. right now we can do:

validates :email, 'valid_email_2/email': { blacklist: true } # This is the default behavior

But it would be really cool if we could do:

validates :email, 'valid_email_2/email': { blacklist: ["cool.com", "fun.com", etc...] }

This could then be used to support things like AR models, e.g.

validates :email, 'valid_email_2/email': { blacklist: proc { EmailPermissions.where(blacklist: true).pluck(:domain) } }

The benefit here is that with large websites, spammers target you quite often, and so if you need to commit and push an updated config/blacklisted_email_domains.yml every time, it's going to be quite painful. By having the default be the same, but being able to override the default to be more dynamic, you can have perhaps have the best of both worlds.

@scouttyg
Copy link
Author

@micke Just a poke here, let me know what you think on this.

@micke
Copy link
Owner

micke commented Nov 4, 2023

Great idea!
What do you think about letting the proc take the models domain as an argument and not only return a enumurable of blocked domains but also return true or false.
Then you can let the database do the heavy lifting instead of loading a huge list into the applications memory.

I'll gladly accept a PR!

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

No branches or pull requests

2 participants