This commit is contained in:
Adolfo Gómez 2013-06-26 10:14:34 +00:00
parent 0303fbf910
commit eea75c1736
5 changed files with 21 additions and 10 deletions

View File

@ -55,6 +55,7 @@ class IPAuth(Authenticator):
groupNameLabel = _('IP Range')
isExternalSource = True
blockUserOnLoginFailures = False
def initialize(self, values):
pass

View File

@ -135,6 +135,9 @@ class Authenticator(Module):
#: an already existing user.
passwordLabel = translatable('Password')
#: If this authenticators casues a temporal block of an user on repeated login failures
blockUserOnLoginFailures = True
from User import User
from Group import Group

View File

@ -735,10 +735,11 @@ class UserInterface(object):
'''
dic = {}
for k, v in self._gui.iteritems():
if v.isType(gui.InputField.EDITABLE_LIST):
if v.isType(gui.InputField.EDITABLE_LIST) or v.isType(gui.InputField.MULTI_CHOICE_TYPE):
dic[k] = gui.convertToChoices(v.value)
else:
dic[k] = v.value
logger.debug('Dict: {0}'.format(dic))
return dic
@ -755,11 +756,12 @@ class UserInterface(object):
'''
arr = []
for k, v in self._gui.iteritems():
logger.debug('serializing Key: {0}'.format(k))
logger.debug('serializing Key: {0}/{1}'.format(k, v.value))
if v.isType(gui.InputField.HIDDEN_TYPE) and v.isSerializable() is False:
logger.debug('Field {0} is not serializable'.format(k))
continue
if v.isType(gui.InputField.EDITABLE_LIST):
if v.isType(gui.InputField.EDITABLE_LIST) or v.isType(gui.InputField.MULTI_CHOICE_TYPE):
logger.debug('Serializing value {0}'.format(v.value))
val = '\001' + cPickle.dumps(v.value)
else:
val = v.value
@ -792,7 +794,7 @@ class UserInterface(object):
if self._gui.has_key(k):
try:
if v[0] == '\001':
val = cPickle.loads(v[1:])
val = cPickle.loads(v[1:].encode('utf-8'))
else:
val = v
except:
@ -820,4 +822,5 @@ class UserInterface(object):
res = []
for key, val in cls._gui.iteritems():
res.append( { 'name' : key, 'gui' : val.guiDescription(), 'value' : '' }, )
return res

View File

@ -96,7 +96,7 @@ def login(request, smallName=None):
tries = cache.get(cacheKey)
if tries is None:
tries = 0
if tries >= GlobalConfig.MAX_LOGIN_TRIES.getInt():
if authenticator.getInstance().blockUserOnLoginFailures is True and tries >= GlobalConfig.MAX_LOGIN_TRIES.getInt():
form.add_form_error('Too many authentication errors. User temporarily blocked.')
authLogLogin(request, authenticator, userName, java, os, 'Temporarily blocked')
else:

View File

@ -114,11 +114,15 @@ def getServiceGui(credentials, idParent, type):
'''
Returns the description of an gui for the specified service provider
'''
logger.debug('getServiceGui parameters: {0}, {1}'.format(idParent, type))
provider = Provider.objects.get(id=idParent).getInstance()
serviceType = provider.getServiceByType(type)
service = serviceType( Environment.getTempEnv(), provider) # Instantiate it so it has the opportunity to alter gui description based on parent
return service.guiDescription(service)
try:
logger.debug('getServiceGui parameters: {0}, {1}'.format(idParent, type))
provider = Provider.objects.get(id=idParent).getInstance()
serviceType = provider.getServiceByType(type)
service = serviceType( Environment.getTempEnv(), provider) # Instantiate it so it has the opportunity to alter gui description based on parent
return service.guiDescription(service)
except:
logger.exception('Exception at getServiceGui')
raise
@needs_credentials
def getService(credentials, id):