mirror of
https://codeberg.org/Mo8it/AdvLabDB.git
synced 2025-04-14 20:57:46 +00:00
Harden password generation
This commit is contained in:
parent
6f9b2984ba
commit
8cffd88ae1
1 changed files with 6 additions and 4 deletions
|
@ -1,19 +1,21 @@
|
|||
# Functions not dependent on advlabdb.models
|
||||
|
||||
from random import choice
|
||||
import secrets
|
||||
from string import ascii_letters, digits
|
||||
|
||||
from sqlalchemy import func, select
|
||||
|
||||
from . import app, db
|
||||
|
||||
PASSWORD_CHARS: str = ascii_letters + digits + "!%*+=?"
|
||||
|
||||
def randomPassword():
|
||||
|
||||
def randomPassword() -> str:
|
||||
password_length = app.config["SECURITY_PASSWORD_LENGTH_MIN"]
|
||||
return "".join(choice(ascii_letters + digits) for i in range(password_length))
|
||||
return "".join(secrets.choice(PASSWORD_CHARS) for i in range(password_length))
|
||||
|
||||
|
||||
def reportBadAttempt(message):
|
||||
def reportBadAttempt(message: str) -> None:
|
||||
print("BAD ATTEMPT:", message) # TODO: Log
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue