from sqlmodel import Session
from sfm.database import engine
from sfm.config import get_settings
from sfm.utils import verify_api_auth_token
from fastapi import Depends, HTTPException
from fastapi.security import HTTPBearer, HTTPBasicCredentials
from passlib.context import CryptContext

pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
app_settings = get_settings()
security = HTTPBearer()


def get_db():  # pragma: no cover
    db = Session(engine)
    try:
        yield db
    finally:
        db.close()


def has_access(
    credentials: HTTPBasicCredentials = Depends(security),
):  # pragma: no cover
    token = credentials.credentials
    verified = verify_api_auth_token(token)
    if verified:
        return True
    else:
        raise HTTPException(status_code=403, detail="Incorrect Credentials")

fastapi.security.HTTPBearer sfm.config.get_settings sqlmodel.Session fastapi.Depends passlib.context.CryptContext sfm.utils.verify_api_auth_token fastapi.HTTPException
[((302, 353), 'passlib.context.CryptContext', 'CryptContext', ([], {'schemes': "['bcrypt']", 'deprecated': '"""auto"""'}), "(schemes=['bcrypt'], deprecated='auto')\n", (314, 353), False, 'from passlib.context import CryptContext\n'), ((369, 383), 'sfm.config.get_settings', 'get_settings', ([], {}), '()\n', (381, 383), False, 'from sfm.config import get_settings\n'), ((395, 407), 'fastapi.security.HTTPBearer', 'HTTPBearer', ([], {}), '()\n', (405, 407), False, 'from fastapi.security import HTTPBearer, HTTPBasicCredentials\n'), ((453, 468), 'sqlmodel.Session', 'Session', (['engine'], {}), '(engine)\n', (460, 468), False, 'from sqlmodel import Session\n'), ((585, 602), 'fastapi.Depends', 'Depends', (['security'], {}), '(security)\n', (592, 602), False, 'from fastapi import Depends, HTTPException\n'), ((678, 706), 'sfm.utils.verify_api_auth_token', 'verify_api_auth_token', (['token'], {}), '(token)\n', (699, 706), False, 'from sfm.utils import verify_api_auth_token\n'), ((768, 830), 'fastapi.HTTPException', 'HTTPException', ([], {'status_code': '(403)', 'detail': '"""Incorrect Credentials"""'}), "(status_code=403, detail='Incorrect Credentials')\n", (781, 830), False, 'from fastapi import Depends, HTTPException\n')]