mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 20:31:35 +00:00
improve random password generator
This commit is contained in:
@@ -7128,9 +7128,14 @@ def getUserAttributes(i, cd, updateCmd):
|
|||||||
controlflow.invalid_argument_exit(
|
controlflow.invalid_argument_exit(
|
||||||
sys.argv[i], f"gam {['create', 'update'][updateCmd]} user")
|
sys.argv[i], f"gam {['create', 'update'][updateCmd]} user")
|
||||||
if need_password:
|
if need_password:
|
||||||
|
# generate a password with unicode chars that are not allowed in
|
||||||
|
# passwords. We expect "password random nohash" to fail but no one
|
||||||
|
# should be using that. Our goal here is to purposefully block login
|
||||||
|
# with this password.
|
||||||
|
pass_chars = [chr(i) for i in range(55296)]
|
||||||
rnd = SystemRandom()
|
rnd = SystemRandom()
|
||||||
body['password'] = ''.join(
|
body['password'] = ''.join(
|
||||||
rnd.choice(PASSWORD_SAFE_CHARS) for _ in range(100))
|
rnd.choice(pass_chars) for _ in range(2000))
|
||||||
if 'password' in body and need_to_hash_password:
|
if 'password' in body and need_to_hash_password:
|
||||||
body['password'] = gen_sha512_hash(body['password'])
|
body['password'] = gen_sha512_hash(body['password'])
|
||||||
body['hashFunction'] = 'crypt'
|
body['hashFunction'] = 'crypt'
|
||||||
|
|||||||
Reference in New Issue
Block a user