Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /pbylicki_rfhub2 /rfhub2 /api /utils /auth.py
| from fastapi import Depends, HTTPException | |
| from fastapi.security import HTTPBasic, HTTPBasicCredentials | |
| from starlette.status import HTTP_401_UNAUTHORIZED | |
| from rfhub2 import config | |
| security = HTTPBasic() | |
| def authenticated_user( | |
| user: HTTPBasicCredentials = Depends(security) | |
| ) -> HTTPBasicCredentials: | |
| if ( | |
| user.username == config.BASIC_AUTH_USER | |
| and user.password == config.BASIC_AUTH_PASSWORD | |
| ): | |
| return user | |
| else: | |
| raise HTTPException( | |
| status_code=HTTP_401_UNAUTHORIZED, | |
| detail="Unauthorized to perform this action", | |
| headers={"WWW-Authenticate": "Basic"}, | |
| ) | |
| def is_authenticated(user: HTTPBasicCredentials = Depends(security)) -> bool: | |
| return authenticated_user(user) is not None | |
Xet Storage Details
- Size:
- 783 Bytes
- Xet hash:
- 501b155126b93ecbe66439b685678fbd974d375e9d228e69b170ae01ae88e5c4
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.