mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
settings: password stength...what could go wrong ?
This commit is contained in:
parent
6563ebb1ca
commit
2bf3fed6e6
1 changed files with 7 additions and 4 deletions
|
@ -25,6 +25,8 @@ import json
|
||||||
import string
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from yunohost.settings import settings_get
|
||||||
|
|
||||||
SMALL_PWD_LIST = [
|
SMALL_PWD_LIST = [
|
||||||
"yunohost",
|
"yunohost",
|
||||||
"olinuxino",
|
"olinuxino",
|
||||||
|
@ -58,7 +60,7 @@ class PasswordValidator:
|
||||||
|
|
||||||
The profile shall be either "user" or "admin"
|
The profile shall be either "user" or "admin"
|
||||||
and will correspond to a validation strength
|
and will correspond to a validation strength
|
||||||
defined via the setting "security.password.<profile>.strength"
|
defined via the setting "security.password.<profile>_strength"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.profile = profile
|
self.profile = profile
|
||||||
|
@ -67,9 +69,10 @@ class PasswordValidator:
|
||||||
# from settings.py because this file is also meant to be
|
# from settings.py because this file is also meant to be
|
||||||
# use as a script by ssowat.
|
# use as a script by ssowat.
|
||||||
# (or at least that's my understanding -- Alex)
|
# (or at least that's my understanding -- Alex)
|
||||||
settings = json.load(open("/etc/yunohost/settings.json", "r"))
|
# Meh... I'll try to use settings_get() anyway... What could go
|
||||||
setting_key = "security.password." + profile + ".strength"
|
# wrong ? And who even change password from SSOwat ? -- Tagada
|
||||||
self.validation_strength = int(settings[setting_key]["value"])
|
setting_key = "security.password." + profile + "_strength"
|
||||||
|
self.validation_strength = settings_get(setting_key)
|
||||||
except Exception:
|
except Exception:
|
||||||
# Fallback to default value if we can't fetch settings for some reason
|
# Fallback to default value if we can't fetch settings for some reason
|
||||||
self.validation_strength = 1
|
self.validation_strength = 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue