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