Initial commit: Robot ökoszisztéma v2.0 - Stabilizált jármű és szerviz robotok
This commit is contained in:
32
code-server-config/data/User/History/-6f62bdcf/Krug.py
Executable file
32
code-server-config/data/User/History/-6f62bdcf/Krug.py
Executable file
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Any, Union
|
||||
from jose import jwt
|
||||
from passlib.context import CryptContext
|
||||
|
||||
# Jelszó titkosítás beállítása
|
||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
|
||||
# Környezeti változók (idővel menjenek a config.py-ba)
|
||||
SECRET_KEY = os.getenv("SECRET_KEY", "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7")
|
||||
ALGORITHM = "HS256"
|
||||
|
||||
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
||||
"""Ellenőrzi, hogy a megadott jelszó egyezik-e a hash-elt változattal."""
|
||||
return pwd_context.verify(plain_password, hashed_password)
|
||||
|
||||
def get_password_hash(password: str) -> str:
|
||||
"""Létrehozza a jelszó biztonságos hash-ét."""
|
||||
return pwd_context.hash(password)
|
||||
|
||||
def create_access_token(data: dict, expires_delta: Union[timedelta, None] = None) -> str:
|
||||
"""Létrehoz egy JWT tokent."""
|
||||
to_encode = data.copy()
|
||||
if expires_delta:
|
||||
expire = datetime.utcnow() + expires_delta
|
||||
else:
|
||||
expire = datetime.utcnow() + timedelta(minutes=1440) # 1 nap alapértelmezett
|
||||
|
||||
to_encode.update({"exp": expire})
|
||||
encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
|
||||
return encoded_jwt
|
||||
Reference in New Issue
Block a user