feat: initial commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
from .password_utils import hash_password, verify_password
|
||||
from .constants import JWT_SECRET, JWT_ALGORITHM, JWT_EXPIRE_MINUTES
|
||||
|
||||
__all__ = [
|
||||
"hash_password",
|
||||
"verify_password",
|
||||
"JWT_SECRET",
|
||||
"JWT_ALGORITHM",
|
||||
"JWT_EXPIRE_MINUTES",
|
||||
]
|
||||
@@ -0,0 +1,14 @@
|
||||
import dotenv
|
||||
import os
|
||||
dotenv.load_dotenv()
|
||||
|
||||
DEFAULT_SKIP = 0
|
||||
DEFAULT_PAGE = 1
|
||||
DEFAULT_LIMIT = 10
|
||||
DEFAULT_ORDER_BY = "id"
|
||||
DEFAULT_ORDER = "desc"
|
||||
|
||||
# jwt
|
||||
JWT_ALGORITHM = os.getenv("JWT_ALGORITHM")
|
||||
JWT_SECRET = os.getenv("JWT_SECRET")
|
||||
JWT_EXPIRE_MINUTES = os.getenv("JWT_EXPIRE_MINUTES")
|
||||
@@ -0,0 +1,16 @@
|
||||
from passlib.context import CryptContext
|
||||
|
||||
# Create a password context for hashing and verifying
|
||||
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||||
|
||||
def hash_password(password: str) -> str:
|
||||
"""
|
||||
Hash a password using bcrypt
|
||||
"""
|
||||
return pwd_context.hash(password)
|
||||
|
||||
def verify_password(plain_password: str, hashed_password: str) -> bool:
|
||||
"""
|
||||
Verify a password against a hash
|
||||
"""
|
||||
return pwd_context.verify(plain_password, hashed_password)
|
||||
Reference in New Issue
Block a user