mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-03-28 18:52:31 +01:00
15 lines
364 B
Python
15 lines
364 B
Python
import hashlib
|
|
|
|
from fastapi import Request
|
|
|
|
from onyx.configs.constants import SESSION_KEY
|
|
|
|
|
|
def encrypt_string(s: str) -> str:
|
|
return hashlib.sha256(s.encode()).hexdigest()
|
|
|
|
|
|
def extract_hashed_cookie(request: Request) -> str | None:
|
|
session_cookie = request.cookies.get(SESSION_KEY)
|
|
return encrypt_string(session_cookie) if session_cookie else None
|