mirror of
https://github.com/reconurge/flowsint.git
synced 2026-11-08 14:35:41 -06:00
Without known_first_party, isort's own-package detection depends on which files it's given: sorted alone, a file inside flowsint_enrichers gets flowsint_enrichers imports grouped separately from flowsint_core/ flowsint_types; sorted together with the rest of the workspace (as `make lint` and CI do), they collapse into one group. lint-staged only ever passes the staged subset, so a commit could pass the pre-commit hook locally and still fail `make lint` in CI — silently, since both are "isort says it's fine," just about different file sets. Pin the four packages as known_first_party in all four pyproject.toml so grouping is the same regardless of invocation scope. The rest of the diff is isort re-normalizing ~100 files to the now-consistent order — import statements only, verified against the diff.
32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from fastapi import Depends, HTTPException, status
|
|
from fastapi.security import OAuth2PasswordBearer
|
|
from jose import JWTError, jwt
|
|
from sqlalchemy.orm import Session
|
|
|
|
from flowsint_core.core.auth import ALGORITHM, AUTH_SECRET
|
|
from flowsint_core.core.models import Profile
|
|
from flowsint_core.core.postgre_db import get_db
|
|
|
|
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
|
|
|
|
|
|
def get_current_user(
|
|
token: str = Depends(oauth2_scheme), db: Session = Depends(get_db)
|
|
) -> Profile:
|
|
credentials_exception = HTTPException(
|
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
detail="Could not validate credentials",
|
|
headers={"WWW-Authenticate": "Bearer"},
|
|
)
|
|
try:
|
|
payload = jwt.decode(token, AUTH_SECRET, algorithms=[ALGORITHM])
|
|
email: str = payload.get("sub")
|
|
if email is None:
|
|
raise credentials_exception
|
|
except JWTError:
|
|
raise credentials_exception
|
|
user = db.query(Profile).filter(Profile.email == email).first()
|
|
if user is None:
|
|
raise credentials_exception
|
|
return user
|