Skip to content

Commit a6d3be3

Browse files
committed
updated cache key excluded
1 parent 7a0b5a1 commit a6d3be3

File tree

1 file changed

+38
-15
lines changed

1 file changed

+38
-15
lines changed

msal/token_cache.py

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,52 @@
1919
# body parameters going on the wire and must differentiate cached tokens.
2020
#
2121
# Excluded fields and reasons:
22-
# - "key_id" : Already handled as a separate cache lookup field
23-
# - "token_type" : Used for SSH-cert/POP detection; AT entry stores it separately
24-
# - "req_cnf" : Ephemeral proof-of-possession nonce, changes per request
25-
# - "claims" : Handled separately; its presence forces a token refresh
26-
# - "scope" : Already represented as "target" in the AT cache key;
27-
# also added to data only at wire-time, not at cache-lookup time
28-
# - "username" : Standard ROPC grant parameter, not an extra body parameter
29-
# - "password" : Standard ROPC grant parameter, not an extra body parameter
22+
# - "client_id" : Standard OAuth2 client identifier, same for every request
23+
# - "grant_type" : Standard OAuth2 grant type (e.g. jwt-bearer, refresh_token)
24+
# - "scope" : Already represented as "target" in the AT cache key
25+
# - "claims" : Handled separately; its presence forces a token refresh
26+
# - "username" : Standard ROPC grant parameter
27+
# - "password" : Standard ROPC grant parameter
28+
# - "refresh_token" : Standard refresh grant parameter
29+
# - "code" : Standard authorization code grant parameter
30+
# - "redirect_uri" : Standard authorization code grant parameter
31+
# - "code_verifier" : Standard PKCE parameter
32+
# - "device_code" : Standard device flow parameter
33+
# - "assertion" : Standard OBO/SAML assertion (RFC 7521)
34+
# - "requested_token_use" : OBO indicator ("on_behalf_of"), not an extra param
35+
# - "client_assertion" : Client authentication credential (RFC 7521 §4.2)
36+
# - "client_assertion_type" : Client authentication type (RFC 7521 §4.2)
37+
# - "client_secret" : Client authentication secret
38+
# - "token_type" : Used for SSH-cert/POP detection; AT entry stores separately
39+
# - "req_cnf" : Ephemeral proof-of-possession nonce, changes per request
40+
# - "key_id" : Already handled as a separate cache lookup field
3041
#
3142
# Included fields (examples — anything NOT in this set is included):
32-
# - "fmi_path" : Federated Managed Identity credential path
33-
# - any future extra body parameter that should isolate cache entries
43+
# - "fmi_path" : Federated Managed Identity credential path
44+
# - any future non-standard body parameter that should isolate cache entries
3445
_EXT_CACHE_KEY_EXCLUDED_FIELDS = frozenset({
35-
"key_id",
36-
"token_type",
37-
"req_cnf",
38-
"claims",
46+
# Standard OAuth2 body parameters — these appear in every token request
47+
# and must NOT influence the extended cache key.
48+
# Only non-standard fields (e.g. fmi_path) should contribute to the hash.
49+
"client_id",
50+
"grant_type",
3951
"scope",
52+
"claims",
4053
"username",
4154
"password",
55+
"refresh_token",
56+
"code",
57+
"redirect_uri",
58+
"code_verifier",
59+
"device_code",
60+
"assertion",
61+
"requested_token_use",
4262
"client_assertion",
4363
"client_assertion_type",
44-
"assertion",
64+
"client_secret",
65+
"token_type",
66+
"req_cnf",
67+
"key_id",
4568
})
4669

4770

0 commit comments

Comments
 (0)