summaryrefslogtreecommitdiffstats
path: root/authentication/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'authentication/utils.py')
-rw-r--r--authentication/utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/authentication/utils.py b/authentication/utils.py
index f383969..4f19bc3 100644
--- a/authentication/utils.py
+++ b/authentication/utils.py
@@ -1,6 +1,9 @@
1import base64 1import base64
2import hashlib 2import hashlib
3from urllib.parse import urlencode
4
3import bcrypt 5import bcrypt
6from fastapi import FastAPI
4 7
5 8
6def bcrypt_sha256_hash(password: str) -> str: 9def bcrypt_sha256_hash(password: str) -> str:
@@ -13,3 +16,10 @@ def bcrypt_sha256_verify(password: str, hashed: str) -> bool:
13 digest = hashlib.sha256(password.encode("utf-8")).digest() 16 digest = hashlib.sha256(password.encode("utf-8")).digest()
14 encoded = base64.b64encode(digest) 17 encoded = base64.b64encode(digest)
15 return bcrypt.checkpw(encoded, hashed.encode('utf-8')) 18 return bcrypt.checkpw(encoded, hashed.encode('utf-8'))
19
20
21def get_url_path_with_query(app: FastAPI, name: str, params: dict | None = None, /, **path_params: str):
22 base = app.url_path_for(name, **path_params)
23 return base + '?' + urlencode(params) if params is not None else base
24
25