mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Propagate interface changes everywhere the assertion is used
This commit is contained in:
parent
167df05f56
commit
914088954d
4 changed files with 17 additions and 12 deletions
|
@ -2252,8 +2252,8 @@ def _parse_action_args_in_yunohost_format(args, action_args, auth=None):
|
|||
m18n.n('app_argument_choice_invalid',
|
||||
name=arg_name, choices='yes, no, y, n, 1, 0'))
|
||||
elif arg_type == 'password':
|
||||
from yunohost.utils.password import LoggerPasswordValidator
|
||||
LoggerPasswordValidator('user').validate(arg_value)
|
||||
from yunohost.utils.password import assert_password_is_strong_enough
|
||||
assert_password_is_strong_enough('user', arg_value)
|
||||
args_dict[arg_name] = arg_value
|
||||
|
||||
# END loop over action_args...
|
||||
|
|
|
@ -129,9 +129,10 @@ def tools_adminpw(auth, new_password):
|
|||
|
||||
"""
|
||||
from yunohost.user import _hash_user_password
|
||||
from yunohost.utils.password import LoggerPasswordValidator
|
||||
from yunohost.utils.password import assert_password_is_strong_enough
|
||||
|
||||
assert_password_is_strong_enough("admin", new_password)
|
||||
|
||||
LoggerPasswordValidator('admin').validate(new_password)
|
||||
try:
|
||||
auth.update("cn=admin", {
|
||||
"userPassword": _hash_user_password(new_password),
|
||||
|
@ -152,8 +153,9 @@ def tools_validatepw(password):
|
|||
password
|
||||
|
||||
"""
|
||||
from yunohost.utils.password import LoggerPasswordValidator
|
||||
LoggerPasswordValidator('user').validate(password)
|
||||
|
||||
from yunohost.utils.password import assert_password_is_strong_enough
|
||||
assert_password_is_strong_enough("user", password)
|
||||
|
||||
|
||||
@is_unit_operation()
|
||||
|
@ -279,6 +281,8 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
|
|||
password -- YunoHost admin password
|
||||
|
||||
"""
|
||||
from yunohost.utils.password import assert_password_is_strong_enough
|
||||
|
||||
dyndns_provider = "dyndns.yunohost.org"
|
||||
|
||||
# Do some checks at first
|
||||
|
@ -288,8 +292,7 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
|
|||
|
||||
# Check password
|
||||
if not force_password:
|
||||
from yunohost.utils.password import LoggerPasswordValidator
|
||||
LoggerPasswordValidator('admin').validate(password)
|
||||
assert_password_is_strong_enough("admin", password)
|
||||
|
||||
if not ignore_dyndns:
|
||||
# Check if yunohost dyndns can handle the given domain
|
||||
|
|
|
@ -117,10 +117,10 @@ def user_create(operation_logger, auth, username, firstname, lastname, mail, pas
|
|||
from yunohost.domain import domain_list, _get_maindomain
|
||||
from yunohost.hook import hook_callback
|
||||
from yunohost.app import app_ssowatconf
|
||||
from yunohost.utils.password import assert_password_is_strong_enough
|
||||
|
||||
# Ensure sufficiently complex password
|
||||
from yunohost.utils.password import LoggerPasswordValidator
|
||||
LoggerPasswordValidator('user').validate(password)
|
||||
assert_password_is_strong_enough("user", password)
|
||||
|
||||
# Validate uniqueness of username and mail in LDAP
|
||||
auth.validate_uniqueness({
|
||||
|
@ -284,6 +284,7 @@ def user_update(operation_logger, auth, username, firstname=None, lastname=None,
|
|||
"""
|
||||
from yunohost.domain import domain_list
|
||||
from yunohost.app import app_ssowatconf
|
||||
from yunohost.utils.password import assert_password_is_strong_enough
|
||||
|
||||
attrs_to_fetch = ['givenName', 'sn', 'mail', 'maildrop']
|
||||
new_attr_dict = {}
|
||||
|
@ -309,8 +310,7 @@ def user_update(operation_logger, auth, username, firstname=None, lastname=None,
|
|||
|
||||
if change_password:
|
||||
# Ensure sufficiently complex password
|
||||
from yunohost.utils.password import LoggerPasswordValidator
|
||||
LoggerPasswordValidator('user').validate(change_password)
|
||||
assert_password_is_strong_enough("user", password)
|
||||
|
||||
new_attr_dict['userPassword'] = _hash_user_password(change_password)
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ STRENGTH_LEVELS = [
|
|||
(12, 1, 1, 1, 1),
|
||||
]
|
||||
|
||||
def assert_password_is_strong_enough(profile, password):
|
||||
PasswordValidator(profile).validate(password)
|
||||
|
||||
class PasswordValidator(object):
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue