Schemas updated
This commit is contained in:
0
ApiServices/AuthService/middlewares/__init__.py
Normal file
0
ApiServices/AuthService/middlewares/__init__.py
Normal file
17
ApiServices/AuthService/middlewares/token_middleware.py
Normal file
17
ApiServices/AuthService/middlewares/token_middleware.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from fastapi import Request, Response
|
||||
from ApiServices.TemplateService.endpoints.routes import get_safe_endpoint_urls
|
||||
|
||||
|
||||
async def token_middleware(request: Request, call_next):
|
||||
|
||||
base_url = "/".join(request.url.path.split("/")[:3])
|
||||
safe_endpoints = [_[0] for _ in get_safe_endpoint_urls()]
|
||||
if base_url in safe_endpoints:
|
||||
return await call_next(request)
|
||||
|
||||
token = request.headers.get("Authorization")
|
||||
if not token:
|
||||
return Response(content="Missing token", status_code=400)
|
||||
|
||||
response = await call_next(request)
|
||||
return response
|
||||
Reference in New Issue
Block a user