microsoft-agents-authentication-msal 0.6.0.dev9__py3-none-any.whl → 0.6.0.dev10__py3-none-any.whl

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.
@@ -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("Invalid instance URL")
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(f"Failed to acquire token. {str(auth_result_payload)}")
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
- "On-behalf-of flow is not supported with Managed Identity authentication."
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(f"Failed to acquire token. {str(token)}")
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
- f"On-behalf-of flow is not supported with the current authentication type: {self._msal_auth_client.__class__.__name__}"
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("Authentication type not supported")
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("Agent application instance Id must be provided.")
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("Agent application instance Id must be provided.")
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
- f"Failed to acquire agentic instance token or agent token for agent_app_instance_id {agent_app_instance_id}"
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
- f"Failed to acquire agentic instance token or agent token for agent_app_instance_id {agent_app_instance_id}"
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(f"Failed to acquire token. {str(agentic_instance_token)}")
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
- "Agent application instance Id and agentic user Id must be provided."
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
- f"Failed to acquire instance token or agent token for agent_app_instance_id {agent_app_instance_id} and agentic_user_id {agentic_user_id}"
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.dev9
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.dev9
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,10 @@
1
+ microsoft_agents/authentication/msal/__init__.py,sha256=hjPpakL4zyqeCTEBOUCcHaRnSpG80q-L0csG5HMalYI,151
2
+ microsoft_agents/authentication/msal/msal_auth.py,sha256=iWXAFYYv0MoxK_mvuRq_cren8fJZWrBbW7hsSGmTDLQ,17057
3
+ microsoft_agents/authentication/msal/msal_connection_manager.py,sha256=v7o0ONzjId1G6Ta7IjHc1NtSeM3NWH4t7YilrwJzvYg,5713
4
+ microsoft_agents/authentication/msal/errors/__init__.py,sha256=pSwN3l4g8Hr3jFPjOVYH1P9bN_lw6X_2jZa3IGtELC0,453
5
+ microsoft_agents/authentication/msal/errors/error_resources.py,sha256=3tIkd3F2NAUVqOmg4hNy3aGhGRXclFdIqbmtC8JgmKg,2330
6
+ microsoft_agents_authentication_msal-0.6.0.dev10.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
7
+ microsoft_agents_authentication_msal-0.6.0.dev10.dist-info/METADATA,sha256=gH47ws05fHkpg643iWg3zqmCWB-voj9EjrdDOs-AWz0,8375
8
+ microsoft_agents_authentication_msal-0.6.0.dev10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
9
+ microsoft_agents_authentication_msal-0.6.0.dev10.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
10
+ microsoft_agents_authentication_msal-0.6.0.dev10.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- microsoft_agents/authentication/msal/__init__.py,sha256=hjPpakL4zyqeCTEBOUCcHaRnSpG80q-L0csG5HMalYI,151
2
- microsoft_agents/authentication/msal/msal_auth.py,sha256=ty7Bgr1RBcX89c-H7xwrcGGO7vZpQcUVMEzhfCAkVgM,16525
3
- microsoft_agents/authentication/msal/msal_connection_manager.py,sha256=v7o0ONzjId1G6Ta7IjHc1NtSeM3NWH4t7YilrwJzvYg,5713
4
- microsoft_agents_authentication_msal-0.6.0.dev9.dist-info/licenses/LICENSE,sha256=ws_MuBL-SCEBqPBFl9_FqZkaaydIJmxHrJG2parhU4M,1141
5
- microsoft_agents_authentication_msal-0.6.0.dev9.dist-info/METADATA,sha256=LeIF619IoMNrfS3Uo-GwHQni8JhXsyysswy3EgBmSFQ,8373
6
- microsoft_agents_authentication_msal-0.6.0.dev9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- microsoft_agents_authentication_msal-0.6.0.dev9.dist-info/top_level.txt,sha256=lWKcT4v6fTA_NgsuHdNvuMjSrkiBMXohn64ApY7Xi8A,17
8
- microsoft_agents_authentication_msal-0.6.0.dev9.dist-info/RECORD,,