| 5 | |
| 6 | |
| 7 | class FlagsmithAuth(httpx.Auth): |
| 8 | def __init__(self, global_master_api_key: str | None = None) -> None: |
| 9 | self._global_master_api_key = global_master_api_key |
| 10 | |
| 11 | def auth_flow( |
| 12 | self, request: httpx.Request |
| 13 | ) -> Generator[httpx.Request, httpx.Response, None]: |
| 14 | if "authorization" not in request.headers: |
| 15 | # Prefer the caller's forwarded MCP `--header`; fall back to the |
| 16 | # server's own static token (the only credential under stdio). |
| 17 | forwarded = get_http_headers(include={"authorization"}) |
| 18 | if ( |
| 19 | authorization := forwarded.get("authorization") |
| 20 | or self._global_authorization_value() |
| 21 | ): |
| 22 | request.headers["authorization"] = authorization |
| 23 | yield request |
| 24 | |
| 25 | def _global_authorization_value(self) -> str | None: |
| 26 | if self._global_master_api_key: |
| 27 | return f"Api-Key {self._global_master_api_key}" |
| 28 | return None |
no outgoing calls
no test coverage detected
searching dependent graphs…