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',
|
m18n.n('app_argument_choice_invalid',
|
||||||
name=arg_name, choices='yes, no, y, n, 1, 0'))
|
name=arg_name, choices='yes, no, y, n, 1, 0'))
|
||||||
elif arg_type == 'password':
|
elif arg_type == 'password':
|
||||||
from yunohost.utils.password import LoggerPasswordValidator
|
from yunohost.utils.password import assert_password_is_strong_enough
|
||||||
LoggerPasswordValidator('user').validate(arg_value)
|
assert_password_is_strong_enough('user', arg_value)
|
||||||
args_dict[arg_name] = arg_value
|
args_dict[arg_name] = arg_value
|
||||||
|
|
||||||
# END loop over action_args...
|
# END loop over action_args...
|
||||||
|
|
|
@ -129,9 +129,10 @@ def tools_adminpw(auth, new_password):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.user import _hash_user_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:
|
try:
|
||||||
auth.update("cn=admin", {
|
auth.update("cn=admin", {
|
||||||
"userPassword": _hash_user_password(new_password),
|
"userPassword": _hash_user_password(new_password),
|
||||||
|
@ -152,8 +153,9 @@ def tools_validatepw(password):
|
||||||
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()
|
@is_unit_operation()
|
||||||
|
@ -279,6 +281,8 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
|
||||||
password -- YunoHost admin password
|
password -- YunoHost admin password
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from yunohost.utils.password import assert_password_is_strong_enough
|
||||||
|
|
||||||
dyndns_provider = "dyndns.yunohost.org"
|
dyndns_provider = "dyndns.yunohost.org"
|
||||||
|
|
||||||
# Do some checks at first
|
# Do some checks at first
|
||||||
|
@ -288,8 +292,7 @@ def tools_postinstall(operation_logger, domain, password, ignore_dyndns=False,
|
||||||
|
|
||||||
# Check password
|
# Check password
|
||||||
if not force_password:
|
if not force_password:
|
||||||
from yunohost.utils.password import LoggerPasswordValidator
|
assert_password_is_strong_enough("admin", password)
|
||||||
LoggerPasswordValidator('admin').validate(password)
|
|
||||||
|
|
||||||
if not ignore_dyndns:
|
if not ignore_dyndns:
|
||||||
# Check if yunohost dyndns can handle the given domain
|
# 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.domain import domain_list, _get_maindomain
|
||||||
from yunohost.hook import hook_callback
|
from yunohost.hook import hook_callback
|
||||||
from yunohost.app import app_ssowatconf
|
from yunohost.app import app_ssowatconf
|
||||||
|
from yunohost.utils.password import assert_password_is_strong_enough
|
||||||
|
|
||||||
# Ensure sufficiently complex password
|
# Ensure sufficiently complex password
|
||||||
from yunohost.utils.password import LoggerPasswordValidator
|
assert_password_is_strong_enough("user", password)
|
||||||
LoggerPasswordValidator('user').validate(password)
|
|
||||||
|
|
||||||
# Validate uniqueness of username and mail in LDAP
|
# Validate uniqueness of username and mail in LDAP
|
||||||
auth.validate_uniqueness({
|
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.domain import domain_list
|
||||||
from yunohost.app import app_ssowatconf
|
from yunohost.app import app_ssowatconf
|
||||||
|
from yunohost.utils.password import assert_password_is_strong_enough
|
||||||
|
|
||||||
attrs_to_fetch = ['givenName', 'sn', 'mail', 'maildrop']
|
attrs_to_fetch = ['givenName', 'sn', 'mail', 'maildrop']
|
||||||
new_attr_dict = {}
|
new_attr_dict = {}
|
||||||
|
@ -309,8 +310,7 @@ def user_update(operation_logger, auth, username, firstname=None, lastname=None,
|
||||||
|
|
||||||
if change_password:
|
if change_password:
|
||||||
# Ensure sufficiently complex password
|
# Ensure sufficiently complex password
|
||||||
from yunohost.utils.password import LoggerPasswordValidator
|
assert_password_is_strong_enough("user", password)
|
||||||
LoggerPasswordValidator('user').validate(change_password)
|
|
||||||
|
|
||||||
new_attr_dict['userPassword'] = _hash_user_password(change_password)
|
new_attr_dict['userPassword'] = _hash_user_password(change_password)
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@ STRENGTH_LEVELS = [
|
||||||
(12, 1, 1, 1, 1),
|
(12, 1, 1, 1, 1),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def assert_password_is_strong_enough(profile, password):
|
||||||
|
PasswordValidator(profile).validate(password)
|
||||||
|
|
||||||
class PasswordValidator(object):
|
class PasswordValidator(object):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue