summaryrefslogtreecommitdiffstats
path: root/authentication/utils.py
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <tom@vanderlee.io>2026-07-22 14:51:44 +0200
committerGravatar Tom van der Lee <tom@vanderlee.io>2026-07-22 14:51:44 +0200
commit498c79f434856aa68e9a883247ea69a22256fce6 (patch)
tree4561647b7f8592f783b4dc07143c60730393b4a1 /authentication/utils.py
parent7784c60c03ec277b456db6e2709383e302d9382b (diff)
downloadserver-498c79f434856aa68e9a883247ea69a22256fce6.tar.gz
server-498c79f434856aa68e9a883247ea69a22256fce6.tar.bz2
server-498c79f434856aa68e9a883247ea69a22256fce6.zip
Added auth layer
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