Skip to content

Commit c0e1da9

Browse files
authored
Merge pull request #336 from AzureAD/saml-utf8
Saml token should use utf-8 encoding
2 parents 42b9fc1 + afd5963 commit c0e1da9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

msal/wstrust_response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,7 @@ def parse_token_by_re(raw_response): # Returns the saml:assertion
8888
token_types = findall_content(rstr, "TokenType")
8989
tokens = findall_content(rstr, "RequestedSecurityToken")
9090
if token_types and tokens:
91-
return {"token": tokens[0].encode('us-ascii'), "type": token_types[0]}
91+
# Historically, we use "us-ascii" encoding, but it should be "utf-8"
92+
# https://stackoverflow.com/questions/36658000/what-is-encoding-used-for-saml-conversations
93+
return {"token": tokens[0].encode('utf-8'), "type": token_types[0]}
9294

0 commit comments

Comments
 (0)