Skip to content

Commit 5e48dca

Browse files
committed
Fix a logger issue when using assertions in Python 3
1 parent 7bc92d3 commit 5e48dca

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

msal/token_cache.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from .authority import canonicalize
88

99

10+
logger = logging.getLogger(__name__)
11+
1012
def is_subdict_of(small, big):
1113
return dict(big, **small) == big
1214

@@ -46,7 +48,13 @@ def add(self, event):
4648
# type: (dict) -> None
4749
# event typically contains: client_id, scope, token_endpoint,
4850
# resposne, params, data, grant_type
49-
logging.debug("event=%s", json.dumps(event, indent=4))
51+
for sensitive in ("password", "client_secret"):
52+
if sensitive in event.get("data", {}):
53+
# Hide them from accidental exposure in logging
54+
event["data"][sensitive] = "********"
55+
logger.debug("event=%s", json.dumps(event, indent=4, sort_keys=True,
56+
default=str, # A workaround when assertion is in bytes in Python 3
57+
))
5058
response = event.get("response", {})
5159
access_token = response.get("access_token", {})
5260
refresh_token = response.get("refresh_token", {})

msal/wstrust_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from .wstrust_response import parse_response
3737

3838

39-
logger = logging.getLogger(__file__)
39+
logger = logging.getLogger(__name__)
4040

4141
def send_request(
4242
username, password, cloud_audience_urn, endpoint_address, soap_action,

0 commit comments

Comments
 (0)