21
21
22
22
23
23
# The __init__.py will import this. Not the other way around.
24
- __version__ = "1.5.0 "
24
+ __version__ = "1.5.1 "
25
25
26
26
logger = logging .getLogger (__name__ )
27
27
@@ -193,6 +193,18 @@ def __init__(
193
193
Default value is None, means it will not be passed to Microsoft.
194
194
:param list[str] client_capabilities: (optional)
195
195
Allows configuration of one or more client capabilities, e.g. ["CP1"].
196
+
197
+ Client capability is meant to inform the Microsoft identity platform
198
+ (STS) what this client is capable for,
199
+ so STS can decide to turn on certain features.
200
+ For example, if client is capable to handle *claims challenge*,
201
+ STS can then issue CAE access tokens to resources
202
+ knowing when the resource emits *claims challenge*
203
+ the client will be capable to handle.
204
+
205
+ Implementation details:
206
+ Client capability is implemented using "claims" parameter on the wire,
207
+ for now.
196
208
MSAL will combine them into
197
209
`claims parameter <https://openid.net/specs/openid-connect-core-1_0-final.html#ClaimsParameter`_
198
210
which you will later provide via one of the acquire-token request.
@@ -264,7 +276,8 @@ def _build_client(self, client_credential, authority):
264
276
default_body = default_body ,
265
277
client_assertion = client_assertion ,
266
278
client_assertion_type = client_assertion_type ,
267
- on_obtaining_tokens = self .token_cache .add ,
279
+ on_obtaining_tokens = lambda event : self .token_cache .add (dict (
280
+ event , environment = authority .instance )),
268
281
on_removing_rt = self .token_cache .remove_rt ,
269
282
on_updating_rt = self .token_cache .update_rt )
270
283
@@ -275,7 +288,7 @@ def get_authorization_request_url(
275
288
login_hint = None , # type: Optional[str]
276
289
state = None , # Recommended by OAuth2 for CSRF protection
277
290
redirect_uri = None ,
278
- response_type = "code" , # Can be "token" if you use Implicit Grant
291
+ response_type = "code" , # Could be "token" if you use Implicit Grant
279
292
prompt = None ,
280
293
nonce = None ,
281
294
domain_hint = None , # type: Optional[str]
@@ -292,7 +305,11 @@ def get_authorization_request_url(
292
305
Address to return to upon receiving a response from the authority.
293
306
:param str response_type:
294
307
Default value is "code" for an OAuth2 Authorization Code grant.
295
- You can use other content such as "id_token".
308
+
309
+ You could use other content such as "id_token" or "token",
310
+ which would trigger an Implicit Grant, but that is
311
+ `not recommended <https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-implicit-grant-flow#is-the-implicit-grant-suitable-for-my-app>`_.
312
+
296
313
:param str prompt:
297
314
By default, no prompt value will be sent, not even "none".
298
315
You will have to specify a value explicitly.
@@ -735,6 +752,11 @@ def _acquire_token_silent_by_finding_specific_refresh_token(
735
752
response = client .obtain_token_by_refresh_token (
736
753
entry , rt_getter = lambda token_item : token_item ["secret" ],
737
754
on_removing_rt = rt_remover or self .token_cache .remove_rt ,
755
+ on_obtaining_tokens = lambda event : self .token_cache .add (dict (
756
+ event ,
757
+ environment = authority .instance ,
758
+ skip_account_creation = True , # To honor a concurrent remove_account()
759
+ )),
738
760
scope = scopes ,
739
761
headers = {
740
762
CLIENT_REQUEST_ID : correlation_id or _get_new_correlation_id (),
@@ -936,7 +958,8 @@ def _acquire_token_by_username_password_federated(
936
958
"https://github.com/AzureAD/microsoft-authentication-library-for-python/wiki/Username-Password-Authentication" )
937
959
logger .debug ("wstrust_endpoint = %s" , wstrust_endpoint )
938
960
wstrust_result = wst_send_request (
939
- username , password , user_realm_result .get ("cloud_audience_urn" ),
961
+ username , password ,
962
+ user_realm_result .get ("cloud_audience_urn" , "urn:federation:MicrosoftOnline" ),
940
963
wstrust_endpoint .get ("address" ,
941
964
# Fallback to an AAD supplied endpoint
942
965
user_realm_result .get ("federation_active_auth_url" )),
0 commit comments