Skip to content

Commit 45c4aa1

Browse files
melangerc00kiemon5ter
authored andcommitted
fix: convert strings to booleans in Apple backend
1 parent 2e3a782 commit 45c4aa1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/satosa/backends/apple.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
logger = logging.getLogger(__name__)
1515

16+
1617
# https://developer.okta.com/blog/2019/06/04/what-the-heck-is-sign-in-with-apple
1718
class AppleBackend(OpenIDConnectBackend):
1819
"""Sign in with Apple backend"""
@@ -109,6 +110,12 @@ def response_endpoint(self, context, *args):
109110
raise SATOSAAuthenticationError(context.state, "No user info available.")
110111

111112
all_user_claims = dict(list(userinfo.items()) + list(id_token_claims.items()))
113+
114+
# convert "string or Boolean" claims to actual booleans
115+
for bool_claim_name in ["email_verified", "is_private_email"]:
116+
if type(userinfo.get(bool_claim_name)) == str:
117+
userinfo[bool_claim_name] = userinfo[bool_claim_name] == "true"
118+
112119
msg = "UserInfo: {}".format(all_user_claims)
113120
logline = lu.LOG_FMT.format(id=lu.get_session_id(context.state), message=msg)
114121
logger.debug(logline)

0 commit comments

Comments
 (0)