|
|
|
|
@ -82,6 +82,9 @@ async def get_token(request: Request):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def internal_key(request: Request):
|
|
|
|
|
token = request.headers.get("Authorization")
|
|
|
|
|
|
|
|
|
|
if not token:
|
|
|
|
|
api_key = request.headers.get("X-Internal-Key")
|
|
|
|
|
|
|
|
|
|
if api_key != config.API_KEY:
|
|
|
|
|
@ -112,6 +115,25 @@ async def internal_key(request: Request):
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
raise Exception(str(e))
|
|
|
|
|
else:
|
|
|
|
|
try:
|
|
|
|
|
response = requests.get(
|
|
|
|
|
f"{config.AUTH_SERVICE_API}/verify-token",
|
|
|
|
|
headers={"Authorization": f"{token}"},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if not response.ok:
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=403, detail="Invalid token."
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return token.split(" ")[1]
|
|
|
|
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print(f"Token verification error: {str(e)}")
|
|
|
|
|
return False, str(e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|