token
This commit is contained in:
0
app/middlewares/__init__.py
Normal file
0
app/middlewares/__init__.py
Normal file
13
app/middlewares/check_token.py
Normal file
13
app/middlewares/check_token.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import fastapi
|
||||
import os
|
||||
|
||||
|
||||
QUEUES_TOKEN = os.getenv('QUEUES_TOKEN')
|
||||
|
||||
class CheckToken:
|
||||
async def __call__(self, request: fastapi.Request, call_next):
|
||||
if QUEUES_TOKEN:
|
||||
token = request.headers.get('X-Queues-Token')
|
||||
if not token or token != QUEUES_TOKEN:
|
||||
raise fastapi.HTTPException(403)
|
||||
return await call_next(request)
|
||||
Reference in New Issue
Block a user