(authorization: str)
| 80 | |
| 81 | |
| 82 | def _require_admin_payload(authorization: str) -> dict: |
| 83 | token = _extract_bearer_token(authorization) |
| 84 | try: |
| 85 | payload = verify_token(token) |
| 86 | except ValueError as e: |
| 87 | raise HTTPException(status_code=401, detail=str(e)) |
| 88 | if not payload.get("is_admin", False): |
| 89 | raise HTTPException(status_code=401, detail="未授权或授权校验失败") |
| 90 | return payload |
| 91 | |
| 92 | |
| 93 | def get_admin_session(authorization: str = Header(default=None)) -> dict: |
no test coverage detected