microsoft-agents-authentication-msal 0.6.0.dev9__tar.gz → 0.6.0.dev10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/PKG-INFO +2 -2
- microsoft_agents_authentication_msal-0.6.0.dev10/microsoft_agents/authentication/msal/errors/__init__.py +15 -0
- microsoft_agents_authentication_msal-0.6.0.dev10/microsoft_agents/authentication/msal/errors/error_resources.py +76 -0
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/microsoft_agents/authentication/msal/msal_auth.py +38 -13
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/microsoft_agents_authentication_msal.egg-info/PKG-INFO +2 -2
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/microsoft_agents_authentication_msal.egg-info/SOURCES.txt +2 -0
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/microsoft_agents_authentication_msal.egg-info/requires.txt +1 -1
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/LICENSE +0 -0
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/microsoft_agents/authentication/msal/__init__.py +0 -0
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/microsoft_agents/authentication/msal/msal_connection_manager.py +0 -0
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/microsoft_agents_authentication_msal.egg-info/dependency_links.txt +0 -0
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/microsoft_agents_authentication_msal.egg-info/top_level.txt +0 -0
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/pyproject.toml +0 -0
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/readme.md +0 -0
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/setup.cfg +0 -0
- {microsoft_agents_authentication_msal-0.6.0.dev9 → microsoft_agents_authentication_msal-0.6.0.dev10}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: microsoft-agents-authentication-msal
|
|
3
|
-
Version: 0.6.0.
|
|
3
|
+
Version: 0.6.0.dev10
|
|
4
4
|
Summary: A msal-based authentication library for Microsoft Agents
|
|
5
5
|
Author: Microsoft Corporation
|
|
6
6
|
License-Expression: MIT
|
|
@@ -15,7 +15,7 @@ Classifier: Operating System :: OS Independent
|
|
|
15
15
|
Requires-Python: >=3.10
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: microsoft-agents-hosting-core==0.6.0.
|
|
18
|
+
Requires-Dist: microsoft-agents-hosting-core==0.6.0.dev10
|
|
19
19
|
Requires-Dist: msal>=1.31.1
|
|
20
20
|
Requires-Dist: requests>=2.32.3
|
|
21
21
|
Requires-Dist: cryptography>=44.0.0
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Error resources for Microsoft Agents Authentication MSAL package.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from microsoft_agents.hosting.core.errors import ErrorMessage
|
|
9
|
+
|
|
10
|
+
from .error_resources import AuthenticationErrorResources
|
|
11
|
+
|
|
12
|
+
# Singleton instance
|
|
13
|
+
authentication_errors = AuthenticationErrorResources()
|
|
14
|
+
|
|
15
|
+
__all__ = ["ErrorMessage", "AuthenticationErrorResources", "authentication_errors"]
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Authentication error resources for Microsoft Agents SDK.
|
|
6
|
+
|
|
7
|
+
Error codes are in the range -60000 to -60999.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from microsoft_agents.hosting.core.errors import ErrorMessage
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class AuthenticationErrorResources:
|
|
14
|
+
"""
|
|
15
|
+
Error messages for authentication operations.
|
|
16
|
+
|
|
17
|
+
Error codes are organized in the range -60000 to -60999.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
FailedToAcquireToken = ErrorMessage(
|
|
21
|
+
"Failed to acquire token. {0}",
|
|
22
|
+
-60012,
|
|
23
|
+
"agentic-identity-with-the-m365-agents-sdk",
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
InvalidInstanceUrl = ErrorMessage(
|
|
27
|
+
"Invalid instance URL",
|
|
28
|
+
-60013,
|
|
29
|
+
"agentic-identity-with-the-m365-agents-sdk",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
OnBehalfOfFlowNotSupportedManagedIdentity = ErrorMessage(
|
|
33
|
+
"On-behalf-of flow is not supported with Managed Identity authentication.",
|
|
34
|
+
-60014,
|
|
35
|
+
"agentic-identity-with-the-m365-agents-sdk",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
OnBehalfOfFlowNotSupportedAuthType = ErrorMessage(
|
|
39
|
+
"On-behalf-of flow is not supported with the current authentication type: {0}",
|
|
40
|
+
-60015,
|
|
41
|
+
"agentic-identity-with-the-m365-agents-sdk",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
AuthenticationTypeNotSupported = ErrorMessage(
|
|
45
|
+
"Authentication type not supported",
|
|
46
|
+
-60016,
|
|
47
|
+
"agentic-identity-with-the-m365-agents-sdk",
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
AgentApplicationInstanceIdRequired = ErrorMessage(
|
|
51
|
+
"Agent application instance Id must be provided.",
|
|
52
|
+
-60017,
|
|
53
|
+
"agentic-identity-with-the-m365-agents-sdk",
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
FailedToAcquireAgenticInstanceToken = ErrorMessage(
|
|
57
|
+
"Failed to acquire agentic instance token or agent token for agent_app_instance_id {0}",
|
|
58
|
+
-60018,
|
|
59
|
+
"agentic-identity-with-the-m365-agents-sdk",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
AgentApplicationInstanceIdAndUserIdRequired = ErrorMessage(
|
|
63
|
+
"Agent application instance Id and agentic user Id must be provided.",
|
|
64
|
+
-60019,
|
|
65
|
+
"agentic-identity-with-the-m365-agents-sdk",
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
FailedToAcquireInstanceOrAgentToken = ErrorMessage(
|
|
69
|
+
"Failed to acquire instance token or agent token for agent_app_instance_id {0} and agentic_user_id {1}",
|
|
70
|
+
-60020,
|
|
71
|
+
"agentic-identity-with-the-m365-agents-sdk",
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
def __init__(self):
|
|
75
|
+
"""Initialize AuthenticationErrorResources."""
|
|
76
|
+
pass
|
|
@@ -26,6 +26,7 @@ from microsoft_agents.hosting.core import (
|
|
|
26
26
|
AccessTokenProviderBase,
|
|
27
27
|
AgentAuthConfiguration,
|
|
28
28
|
)
|
|
29
|
+
from microsoft_agents.authentication.msal.errors import authentication_errors
|
|
29
30
|
|
|
30
31
|
logger = logging.getLogger(__name__)
|
|
31
32
|
|
|
@@ -65,7 +66,7 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
65
66
|
)
|
|
66
67
|
valid_uri, instance_uri = self._uri_validator(resource_url)
|
|
67
68
|
if not valid_uri:
|
|
68
|
-
raise ValueError(
|
|
69
|
+
raise ValueError(str(authentication_errors.InvalidInstanceUrl))
|
|
69
70
|
|
|
70
71
|
local_scopes = self._resolve_scopes_list(instance_uri, scopes)
|
|
71
72
|
self._create_client_application()
|
|
@@ -86,7 +87,11 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
86
87
|
res = auth_result_payload.get("access_token") if auth_result_payload else None
|
|
87
88
|
if not res:
|
|
88
89
|
logger.error("Failed to acquire token for resource %s", auth_result_payload)
|
|
89
|
-
raise ValueError(
|
|
90
|
+
raise ValueError(
|
|
91
|
+
authentication_errors.FailedToAcquireToken.format(
|
|
92
|
+
str(auth_result_payload)
|
|
93
|
+
)
|
|
94
|
+
)
|
|
90
95
|
|
|
91
96
|
return res
|
|
92
97
|
|
|
@@ -106,7 +111,7 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
106
111
|
"Attempted on-behalf-of flow with Managed Identity authentication."
|
|
107
112
|
)
|
|
108
113
|
raise NotImplementedError(
|
|
109
|
-
|
|
114
|
+
str(authentication_errors.OnBehalfOfFlowNotSupportedManagedIdentity)
|
|
110
115
|
)
|
|
111
116
|
elif isinstance(self._msal_auth_client, ConfidentialClientApplication):
|
|
112
117
|
# TODO: Handling token error / acquisition failed
|
|
@@ -123,7 +128,9 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
123
128
|
logger.error(
|
|
124
129
|
f"Failed to acquire token on behalf of user: {user_assertion}"
|
|
125
130
|
)
|
|
126
|
-
raise ValueError(
|
|
131
|
+
raise ValueError(
|
|
132
|
+
authentication_errors.FailedToAcquireToken.format(str(token))
|
|
133
|
+
)
|
|
127
134
|
|
|
128
135
|
return token["access_token"]
|
|
129
136
|
|
|
@@ -131,7 +138,9 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
131
138
|
f"On-behalf-of flow is not supported with the current authentication type: {self._msal_auth_client.__class__.__name__}"
|
|
132
139
|
)
|
|
133
140
|
raise NotImplementedError(
|
|
134
|
-
|
|
141
|
+
authentication_errors.OnBehalfOfFlowNotSupportedAuthType.format(
|
|
142
|
+
self._msal_auth_client.__class__.__name__
|
|
143
|
+
)
|
|
135
144
|
)
|
|
136
145
|
|
|
137
146
|
def _create_client_application(self) -> None:
|
|
@@ -187,7 +196,9 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
187
196
|
logger.error(
|
|
188
197
|
f"Unsupported authentication type: {self._msal_configuration.AUTH_TYPE}"
|
|
189
198
|
)
|
|
190
|
-
raise NotImplementedError(
|
|
199
|
+
raise NotImplementedError(
|
|
200
|
+
str(authentication_errors.AuthenticationTypeNotSupported)
|
|
201
|
+
)
|
|
191
202
|
|
|
192
203
|
self._msal_auth_client = ConfidentialClientApplication(
|
|
193
204
|
client_id=self._msal_configuration.CLIENT_ID,
|
|
@@ -233,7 +244,9 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
233
244
|
"""
|
|
234
245
|
|
|
235
246
|
if not agent_app_instance_id:
|
|
236
|
-
raise ValueError(
|
|
247
|
+
raise ValueError(
|
|
248
|
+
str(authentication_errors.AgentApplicationInstanceIdRequired)
|
|
249
|
+
)
|
|
237
250
|
|
|
238
251
|
logger.info(
|
|
239
252
|
"Attempting to get agentic application token from agent_app_instance_id %s",
|
|
@@ -267,7 +280,9 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
267
280
|
"""
|
|
268
281
|
|
|
269
282
|
if not agent_app_instance_id:
|
|
270
|
-
raise ValueError(
|
|
283
|
+
raise ValueError(
|
|
284
|
+
str(authentication_errors.AgentApplicationInstanceIdRequired)
|
|
285
|
+
)
|
|
271
286
|
|
|
272
287
|
logger.info(
|
|
273
288
|
"Attempting to get agentic instance token from agent_app_instance_id %s",
|
|
@@ -283,7 +298,9 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
283
298
|
agent_app_instance_id,
|
|
284
299
|
)
|
|
285
300
|
raise Exception(
|
|
286
|
-
|
|
301
|
+
authentication_errors.FailedToAcquireAgenticInstanceToken.format(
|
|
302
|
+
agent_app_instance_id
|
|
303
|
+
)
|
|
287
304
|
)
|
|
288
305
|
|
|
289
306
|
authority = (
|
|
@@ -306,7 +323,9 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
306
323
|
agent_app_instance_id,
|
|
307
324
|
)
|
|
308
325
|
raise Exception(
|
|
309
|
-
|
|
326
|
+
authentication_errors.FailedToAcquireAgenticInstanceToken.format(
|
|
327
|
+
agent_app_instance_id
|
|
328
|
+
)
|
|
310
329
|
)
|
|
311
330
|
|
|
312
331
|
# future scenario where we don't know the blueprint id upfront
|
|
@@ -316,7 +335,11 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
316
335
|
logger.error(
|
|
317
336
|
"Failed to acquire agentic instance token, %s", agentic_instance_token
|
|
318
337
|
)
|
|
319
|
-
raise ValueError(
|
|
338
|
+
raise ValueError(
|
|
339
|
+
authentication_errors.FailedToAcquireToken.format(
|
|
340
|
+
str(agentic_instance_token)
|
|
341
|
+
)
|
|
342
|
+
)
|
|
320
343
|
|
|
321
344
|
logger.debug(
|
|
322
345
|
"Agentic blueprint id: %s",
|
|
@@ -345,7 +368,7 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
345
368
|
"""
|
|
346
369
|
if not agent_app_instance_id or not agentic_user_id:
|
|
347
370
|
raise ValueError(
|
|
348
|
-
|
|
371
|
+
str(authentication_errors.AgentApplicationInstanceIdAndUserIdRequired)
|
|
349
372
|
)
|
|
350
373
|
|
|
351
374
|
logger.info(
|
|
@@ -364,7 +387,9 @@ class MsalAuth(AccessTokenProviderBase):
|
|
|
364
387
|
agentic_user_id,
|
|
365
388
|
)
|
|
366
389
|
raise Exception(
|
|
367
|
-
|
|
390
|
+
authentication_errors.FailedToAcquireInstanceOrAgentToken.format(
|
|
391
|
+
agent_app_instance_id, agentic_user_id
|
|
392
|
+
)
|
|
368
393
|
)
|
|
369
394
|
|
|
370
395
|
authority = (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: microsoft-agents-authentication-msal
|
|
3
|
-
Version: 0.6.0.
|
|
3
|
+
Version: 0.6.0.dev10
|
|
4
4
|
Summary: A msal-based authentication library for Microsoft Agents
|
|
5
5
|
Author: Microsoft Corporation
|
|
6
6
|
License-Expression: MIT
|
|
@@ -15,7 +15,7 @@ Classifier: Operating System :: OS Independent
|
|
|
15
15
|
Requires-Python: >=3.10
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
17
17
|
License-File: LICENSE
|
|
18
|
-
Requires-Dist: microsoft-agents-hosting-core==0.6.0.
|
|
18
|
+
Requires-Dist: microsoft-agents-hosting-core==0.6.0.dev10
|
|
19
19
|
Requires-Dist: msal>=1.31.1
|
|
20
20
|
Requires-Dist: requests>=2.32.3
|
|
21
21
|
Requires-Dist: cryptography>=44.0.0
|
|
@@ -5,6 +5,8 @@ setup.py
|
|
|
5
5
|
microsoft_agents/authentication/msal/__init__.py
|
|
6
6
|
microsoft_agents/authentication/msal/msal_auth.py
|
|
7
7
|
microsoft_agents/authentication/msal/msal_connection_manager.py
|
|
8
|
+
microsoft_agents/authentication/msal/errors/__init__.py
|
|
9
|
+
microsoft_agents/authentication/msal/errors/error_resources.py
|
|
8
10
|
microsoft_agents_authentication_msal.egg-info/PKG-INFO
|
|
9
11
|
microsoft_agents_authentication_msal.egg-info/SOURCES.txt
|
|
10
12
|
microsoft_agents_authentication_msal.egg-info/dependency_links.txt
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|