mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-22 09:24:21 +01:00
implementing ppolicy handling and a simple ppolicy module
This commit is contained in:
parent
e964c5151e
commit
0d045576b2
@ -171,6 +171,14 @@ class LdapCherry(object):
|
||||
except:
|
||||
raise BackendModuleInitFail(module)
|
||||
|
||||
def _init_ppolicy(self, config):
|
||||
module = self._get_param('ppolicy', 'ppolicy.module', config, 'ldapcherry.ppolicy')
|
||||
try:
|
||||
pp = __import__(module, globals(), locals(), ['PPolicy'], -1)
|
||||
except:
|
||||
raise BackendModuleLoadingFail(module)
|
||||
self.ppolicy = pp.PPolicy(config['ppolicy'], cherrypy.log)
|
||||
|
||||
def _init_auth(self, config):
|
||||
""" Init authentication
|
||||
@dict: configuration of ldapcherry
|
||||
@ -378,7 +386,8 @@ class LdapCherry(object):
|
||||
severity = logging.INFO
|
||||
)
|
||||
|
||||
self.ppolicy = None
|
||||
# loading the ppolicy
|
||||
self._init_ppolicy(config)
|
||||
|
||||
except Exception as e:
|
||||
self._handle_exception(e)
|
||||
@ -683,9 +692,6 @@ class LdapCherry(object):
|
||||
)
|
||||
|
||||
def _checkppolicy(self, password):
|
||||
if self.ppolicy is None:
|
||||
ret = { 'match': True, 'reason': 'No password Policy'}
|
||||
else:
|
||||
ret = self.ppolicy.check(password)
|
||||
return ret
|
||||
|
||||
|
@ -12,9 +12,9 @@ class PPolicy(ldapcherry.ppolicy.PPolicy):
|
||||
|
||||
def __init__(self, config, logger):
|
||||
self.config = config
|
||||
self.min_length = get_param('min_length')
|
||||
self.min_upper = get_param('min_upper')
|
||||
self.min_digit = get_param('min_digit')
|
||||
self.min_length = self.get_param('min_length')
|
||||
self.min_upper = self.get_param('min_upper')
|
||||
self.min_digit = self.get_param('min_digit')
|
||||
|
||||
def check(self, password):
|
||||
if len(password) < self.min_length:
|
||||
@ -31,6 +31,6 @@ class PPolicy(ldapcherry.ppolicy.PPolicy):
|
||||
* Minimum number of uppercase characters: %(upper)n\n\
|
||||
* Minimum number of digits: %(digit)n" % { 'upper': self.min_upper,
|
||||
'len': self.min_length,
|
||||
'digit' self.min_digit,
|
||||
'digit': self.min_digit,
|
||||
}
|
||||
|
||||
|
2
setup.py
2
setup.py
@ -90,7 +90,7 @@ setup(
|
||||
version = '0.0.1',
|
||||
author = 'Pierre-Francois Carpentier',
|
||||
author_email = 'carpentier.pf@gmail.com',
|
||||
packages = ['ldapcherry', 'ldapcherry.backend'],
|
||||
packages = ['ldapcherry', 'ldapcherry.backend', 'ldapcherry.ppolicy'],
|
||||
data_files = resources_files,
|
||||
scripts = ['scripts/ldapcherryd'],
|
||||
url = 'https://github.com/kakwa/ldapcherry',
|
||||
|
Loading…
Reference in New Issue
Block a user