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

1# -*- coding: utf-8 -*- 

2"""Shared OAuth helpers and sensitive-key definitions.""" 

3 

4# Standard 

5from typing import Any 

6 

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) 

20 

21 

22def is_sensitive_oauth_key(key: Any) -> bool: 

23 """Return whether an oauth_config key should be treated as secret. 

24 

25 Args: 

26 key: Candidate oauth_config key. 

27 

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