Spaces:
Sleeping
Sleeping
Delete core
Browse files- core/config.py +0 -9
- core/security.py +0 -18
core/config.py
DELETED
|
@@ -1,9 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
|
| 3 |
-
SECRET_KEY = os.getenv("SECRET_KEY", "your-secret-key")
|
| 4 |
-
ALGORITHM = "HS256"
|
| 5 |
-
ACCESS_TOKEN_EXPIRE_MINUTES = 30
|
| 6 |
-
MONGO_URI = os.getenv("MONGO_URI")
|
| 7 |
-
|
| 8 |
-
if not MONGO_URI:
|
| 9 |
-
raise RuntimeError("MONGO_URI not set!")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
core/security.py
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
from datetime import datetime, timedelta
|
| 2 |
-
from passlib.context import CryptContext
|
| 3 |
-
from jose import jwt
|
| 4 |
-
from app.core.config import SECRET_KEY, ALGORITHM, ACCESS_TOKEN_EXPIRE_MINUTES
|
| 5 |
-
|
| 6 |
-
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
| 7 |
-
|
| 8 |
-
def hash_password(password: str) -> str:
|
| 9 |
-
return pwd_context.hash(password)
|
| 10 |
-
|
| 11 |
-
def verify_password(plain: str, hashed: str) -> bool:
|
| 12 |
-
return pwd_context.verify(plain, hashed)
|
| 13 |
-
|
| 14 |
-
def create_access_token(data: dict, expires_delta: timedelta = None):
|
| 15 |
-
to_encode = data.copy()
|
| 16 |
-
expire = datetime.utcnow() + (expires_delta or timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES))
|
| 17 |
-
to_encode.update({"exp": expire})
|
| 18 |
-
return jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|