Backport FAS patch 168
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
This commit is contained in:
parent
010732969e
commit
656f72948c
2 changed files with 21 additions and 1 deletions
|
@ -88,7 +88,7 @@ from fas.auth import (
|
||||||
from fas.util import available_languages
|
from fas.util import available_languages
|
||||||
from fas.validators import KnownUser, PasswordStrength, ValidGPGKeyID, \
|
from fas.validators import KnownUser, PasswordStrength, ValidGPGKeyID, \
|
||||||
ValidSSHKey, NonFedoraEmail, ValidLanguage, UnknownUser, ValidUsername, \
|
ValidSSHKey, NonFedoraEmail, ValidLanguage, UnknownUser, ValidUsername, \
|
||||||
ValidHumanWithOverride, MaybeFloat, EVEmail
|
ValidHumanWithOverride, MaybeFloat, EVEmail, NonBlockedEmail
|
||||||
from fas import _
|
from fas import _
|
||||||
|
|
||||||
#ADMIN_GROUP = config.get('admingroup', 'accounts')
|
#ADMIN_GROUP = config.get('admingroup', 'accounts')
|
||||||
|
@ -113,6 +113,7 @@ class UserCreate(validators.Schema):
|
||||||
validators.Email(not_empty=True, strip=True),
|
validators.Email(not_empty=True, strip=True),
|
||||||
NonFedoraEmail(not_empty=True, strip=True),
|
NonFedoraEmail(not_empty=True, strip=True),
|
||||||
EVEmail(not_empty=True, strip=True),
|
EVEmail(not_empty=True, strip=True),
|
||||||
|
NonBlockedEmail(not_empty=True, strip=True),
|
||||||
)
|
)
|
||||||
verify_email = validators.All(
|
verify_email = validators.All(
|
||||||
validators.Email(not_empty=True, strip=True),
|
validators.Email(not_empty=True, strip=True),
|
||||||
|
|
|
@ -274,6 +274,25 @@ class ValidUsername(validators.FancyValidator):
|
||||||
raise validators.Invalid(self.message('blacklist', state, username=value),
|
raise validators.Invalid(self.message('blacklist', state, username=value),
|
||||||
value, state)
|
value, state)
|
||||||
|
|
||||||
|
|
||||||
|
class NonBlockedEmail(validators.FancyValidator):
|
||||||
|
'''Make sure that a username isn't blacklisted'''
|
||||||
|
email_blacklist = config.get('email_domain_blacklist').split(',')
|
||||||
|
|
||||||
|
messages = {'blacklist': _("'%(email)s' is a blacklisted email.")}
|
||||||
|
|
||||||
|
def _to_python(self, value, state):
|
||||||
|
# pylint: disable-msg=C0111,W0613
|
||||||
|
return value.strip()
|
||||||
|
|
||||||
|
def validate_python(self, value, state):
|
||||||
|
# pylint: disable-msg=C0111
|
||||||
|
for blocked in self.email_blacklist:
|
||||||
|
if value.endswith(blocked):
|
||||||
|
raise validators.Invalid(self.message('blacklist', state, email=value),
|
||||||
|
value, state)
|
||||||
|
|
||||||
|
|
||||||
class ValidLanguage(validators.FancyValidator):
|
class ValidLanguage(validators.FancyValidator):
|
||||||
'''Make sure that a username isn't blacklisted'''
|
'''Make sure that a username isn't blacklisted'''
|
||||||
messages = {'not_available': _("The language '%(lang)s' is not available.")}
|
messages = {'not_available': _("The language '%(lang)s' is not available.")}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue