Create auth.py
Browse files- api/auth.py +10 -0
api/auth.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import Depends, HTTPException
|
| 2 |
+
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
| 3 |
+
from api.config import APP_SECRET
|
| 4 |
+
|
| 5 |
+
security = HTTPBearer()
|
| 6 |
+
|
| 7 |
+
def verify_app_secret(credentials: HTTPAuthorizationCredentials = Depends(security)):
|
| 8 |
+
if credentials.credentials != APP_SECRET:
|
| 9 |
+
raise HTTPException(status_code=403, detail="Invalid APP_SECRET")
|
| 10 |
+
return credentials.credentials
|