Skip to content

Commit

Permalink
enh: next escalation step against spam registration (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Nov 28, 2021
1 parent d394cf0 commit d64f193
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.17.1
- enh: next escalation step against spam registration (#14)
0.17.0
- fix: disallow bulk menu for making datasets private (#23)
- enh: don't show package editing options to users who don't
Expand Down
16 changes: 15 additions & 1 deletion ckanext/dcor_schemas/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from email.utils import parseaddr
import re

from ckan.common import asbool, config
from ckan import logic
Expand Down Expand Up @@ -332,6 +333,19 @@ def user_create(context, data_dict=None):
if data_dict is None:
data_dict = {}

for name in ["fullname", "name", "display_name", "email"]:
if data_dict.get(name, "").lower().count("xx"):
# script kiddies
return {'success': False,
'msg': f'SPAM registration detected!'}

if "image_url" in data_dict:
imgu = data_dict.get("image_url", "").lower()
if imgu:
if not re.search(r"\.(png|jpg|jpeg)$", imgu):
return {'success': False,
'msg': f'SPAM registration detected!'}

if "email" in data_dict:
# somebody is attempting to create a user
email = data_dict.get("email", "").strip()
Expand All @@ -349,6 +363,6 @@ def user_create(context, data_dict=None):
domain = email.split("@")[1]
if domain in ["gmail.com"]:
return {'success': False,
'msg': f'Domain not allowed due to spam: {domain}!'}
'msg': f'SPAM registration detected!'}

return {'success': True}

0 comments on commit d64f193

Please sign in to comment.