Skip to content
Prev Previous commit
Next Next commit
Changing home account id to sub from idtoken claims
  • Loading branch information
abhidnya13 committed Jul 30, 2019
commit 25472a3e4ecabf0ec41d8041c49671309f6be880
9 changes: 6 additions & 3 deletions msal/token_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,16 @@ def add(self, event, now=None):
client_info = {}
if "client_info" in response: # We asked for it, and AAD will provide it
client_info = json.loads(base64decode(response["client_info"]))
home_account_id = (
# It would remain None in client_credentials flow
"{uid}.{utid}".format(**client_info) if client_info else None)
elif id_token_claims: # This would be an end user on ADFS-direct scenario
client_info = {
"uid": id_token_claims.get("sub"),
"utid": realm, # which, in ADFS scenario, would typically be "adfs"
}
home_account_id = ( # It would remain None in client_credentials flow
"{uid}.{utid}".format(**client_info) if client_info else None)
home_account_id = (
"{uid}".format(**client_info))

target = ' '.join(event.get("scope", [])) # Per schema, we don't sort it

with self._lock:
Expand Down