feat: complete AuraTrade Titan world-class institutional quant workstation with multi-asset radar, economic calendar, 4-tab cockpit dock, and multi-tier profit targets
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import hmac
|
||||
from fastapi import HTTPException, Security, status
|
||||
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
|
||||
from app.core.config import settings
|
||||
|
||||
security = HTTPBearer(auto_error=False)
|
||||
|
||||
def verify_admin_token(credentials: HTTPAuthorizationCredentials = Security(security)):
|
||||
"""Enforces Bearer authentication on sensitive trading and execution endpoints."""
|
||||
if not credentials or not credentials.credentials:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Restricted Endpoint: Valid Master Bearer Token required to execute orders.",
|
||||
headers={"WWW-Authenticate": "Bearer"},
|
||||
)
|
||||
|
||||
# Constant-time comparison to prevent timing attacks
|
||||
if not hmac.compare_digest(credentials.credentials, settings.ADMIN_TOKEN):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Forbidden: Invalid Master Token. Unauthorized access attempt logged.",
|
||||
)
|
||||
return credentials.credentials
|
||||
Reference in New Issue
Block a user