make auth.salt parameter optional

Used implementation of the hasher includes salt itself, thus additional
salt is optional and can be safely (in terms of security) treat as empty
string
This commit is contained in:
2023-08-11 16:31:47 +03:00
parent 480c3a54b8
commit c863ee063c
7 changed files with 18 additions and 10 deletions

View File

@ -52,7 +52,7 @@ class Users(Handler):
if args.action == Action.Update:
user = Users.user_create(args)
# if password is left blank we are not going to require salt to be set
salt = configuration.get("auth", "salt") if user.password else ""
salt = configuration.get("auth", "salt", fallback="") if user.password else ""
database.user_update(user.hash_password(salt))
elif args.action == Action.List:
users = database.user_list(args.username, args.role)

View File

@ -46,7 +46,7 @@ class Mapping(Auth):
"""
Auth.__init__(self, configuration, provider)
self.database = database
self.salt = configuration.get("auth", "salt")
self.salt = configuration.get("auth", "salt", fallback="")
async def check_credentials(self, username: str | None, password: str | None) -> bool:
"""

View File

@ -93,9 +93,12 @@ CONFIGURATION_SCHEMA: ConfigurationSchema = {
"type": "string",
"oneof": [
{"allowed": ["disabled"]},
{"allowed": ["configuration", "mapping"], "dependencies": ["salt"]},
{"allowed": ["configuration", "mapping"]},
{"allowed": ["oauth"], "dependencies": [
"client_id", "client_secret", "oauth_provider", "oauth_scopes", "salt"
"client_id",
"client_secret",
"oauth_provider",
"oauth_scopes",
]},
],
},