fix(api-clients): fallback api-key hashing without argon2; show site/module parent display names
This commit is contained in:
@@ -14,7 +14,11 @@ pwd_context = CryptContext(schemes=["argon2", "bcrypt"], deprecated="auto")
|
|||||||
|
|
||||||
|
|
||||||
def hash_api_key(plain_key: str) -> str:
|
def hash_api_key(plain_key: str) -> str:
|
||||||
|
try:
|
||||||
return pwd_context.hash(plain_key)
|
return pwd_context.hash(plain_key)
|
||||||
|
except Exception:
|
||||||
|
# Fallback for environments missing argon2 backend.
|
||||||
|
return f"sha256:{hashlib.sha256(plain_key.encode('utf-8')).hexdigest()}"
|
||||||
|
|
||||||
|
|
||||||
def _verify_api_key(plain_key: str, stored_hash: str) -> bool:
|
def _verify_api_key(plain_key: str, stored_hash: str) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user