Coverage for mcpgateway / common / oauth.py: 100%
4 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 03:05 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-09 03:05 +0000
1# -*- coding: utf-8 -*-
2"""Shared OAuth helpers and sensitive-key definitions."""
4# Standard
5from typing import Any
7# OAuth config keys that should always be treated as secret material.
8OAUTH_SENSITIVE_KEYS: frozenset[str] = frozenset(
9 {
10 "client_secret",
11 "password",
12 "refresh_token",
13 "access_token",
14 "id_token",
15 "token",
16 "secret",
17 "private_key",
18 }
19)
22def is_sensitive_oauth_key(key: Any) -> bool:
23 """Return whether an oauth_config key should be treated as secret.
25 Args:
26 key: Candidate oauth_config key.
28 Returns:
29 bool: True when key maps to sensitive OAuth material.
30 """
31 return isinstance(key, str) and key.lower() in OAUTH_SENSITIVE_KEYS