From 498c79f434856aa68e9a883247ea69a22256fce6 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Wed, 22 Jul 2026 14:51:44 +0200 Subject: Added auth layer --- authentication/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'authentication/utils.py') 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 @@ import base64 import hashlib +from urllib.parse import urlencode + import bcrypt +from fastapi import FastAPI def bcrypt_sha256_hash(password: str) -> str: @@ -13,3 +16,10 @@ def bcrypt_sha256_verify(password: str, hashed: str) -> bool: digest = hashlib.sha256(password.encode("utf-8")).digest() encoded = base64.b64encode(digest) return bcrypt.checkpw(encoded, hashed.encode('utf-8')) + + +def get_url_path_with_query(app: FastAPI, name: str, params: dict | None = None, /, **path_params: str): + base = app.url_path_for(name, **path_params) + return base + '?' + urlencode(params) if params is not None else base + + -- cgit v1.2.3