25 lines
683 B
Python
25 lines
683 B
Python
|
import os
|
||
|
|
||
|
from fastapi.security import OAuth2PasswordBearer
|
||
|
from passlib.context import CryptContext
|
||
|
|
||
|
from dotenv import load_dotenv
|
||
|
load_dotenv()
|
||
|
|
||
|
ACCESS_TOKEN_EXPIRE_MINUTES = 60 * 24 * 7 # 7 days
|
||
|
SECRET_KEY = os.getenv("SECRET_KEY")
|
||
|
USERNAME = os.getenv("USERNAME")
|
||
|
PASS_HASH = os.getenv("PASS_HASH")
|
||
|
ALGORITHM = os.getenv("ALGORITHM")
|
||
|
|
||
|
def get_fake_users_db():
|
||
|
return {
|
||
|
os.getenv("USERNAME"): {
|
||
|
"username": os.getenv("USERNAME"),
|
||
|
"hashed_password": os.getenv("PASS_HASH"),
|
||
|
"disabled": False,
|
||
|
}
|
||
|
}
|
||
|
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
||
|
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|