Validate the security token. Raises 403 if invalid.
(token: str, request: Request = None)
| 184 | |
| 185 | |
| 186 | def validate_token(token: str, request: Request = None) -> None: |
| 187 | """Validate the security token. Raises 403 if invalid.""" |
| 188 | # Only validate if a token is actually enforced on the server (AUTH FIX) |
| 189 | if SECURITY_TOKEN and token != SECURITY_TOKEN: |
| 190 | # Log failed attempt with client IP |
| 191 | client_ip = "unknown" |
| 192 | if request: |
| 193 | client_ip = request.client.host if request.client else "unknown" |
| 194 | logger.warning(f"Authentication failed from IP: {client_ip}") |
| 195 | raise HTTPException(status_code=403, detail="Invalid security token") |
| 196 | |
| 197 | |
| 198 | def detect_display_server() -> Literal["wayland", "x11", "unknown"]: |
no outgoing calls
no test coverage detected