Development
This commit is contained in:
parent
8a8e947fcf
commit
450c0081f7
9 changed files with 59 additions and 28 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import sqlite3
|
||||
import time
|
||||
|
||||
import bcrypt
|
||||
from cryptography.fernet import Fernet
|
||||
from flask import Blueprint, request, redirect, flash
|
||||
import auth
|
||||
|
|
@ -19,12 +18,12 @@ USER_TYPE_CAPTIVE = 0
|
|||
USER_TYPE_SUPPLICANT = 1
|
||||
|
||||
DIGEST_CYPHERTEXT_FERNET = 0
|
||||
DIGEST_HASH_BCRYPT = 2
|
||||
DIGEST_HASH_SCRYPT = 2
|
||||
|
||||
VALID_USER_TYPES = {USER_TYPE_CAPTIVE, USER_TYPE_SUPPLICANT}
|
||||
|
||||
HASH_FOR_USER_TYPE = {
|
||||
USER_TYPE_CAPTIVE: DIGEST_HASH_BCRYPT,
|
||||
USER_TYPE_CAPTIVE: DIGEST_HASH_SCRYPT,
|
||||
USER_TYPE_SUPPLICANT: DIGEST_CYPHERTEXT_FERNET,
|
||||
}
|
||||
|
||||
|
|
@ -99,8 +98,8 @@ def _get_by_index(conn, row_index):
|
|||
def _hash_password(plaintext, digest_type):
|
||||
if digest_type == DIGEST_CYPHERTEXT_FERNET:
|
||||
return encrypt_password(plaintext)
|
||||
if digest_type == DIGEST_HASH_BCRYPT:
|
||||
return bcrypt.hashpw(plaintext.encode(), bcrypt.gensalt()).decode()
|
||||
if digest_type == DIGEST_HASH_SCRYPT:
|
||||
return settings.hash_password(plaintext)
|
||||
raise ValueError(f"Unknown digest_type: {digest_type}")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue