microsoft-agents-hosting-aiohttp 1.3.0__tar.gz → 1.4.0.dev13__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.
Files changed (22) hide show
  1. {microsoft_agents_hosting_aiohttp-1.3.0/microsoft_agents_hosting_aiohttp.egg-info → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/PKG-INFO +2 -2
  2. microsoft_agents_hosting_aiohttp-1.4.0.dev13/VERSION.txt +1 -0
  3. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/microsoft_agents/hosting/aiohttp/cloud_adapter.py +6 -1
  4. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/microsoft_agents/hosting/aiohttp/jwt_authorization_middleware.py +32 -1
  5. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13/microsoft_agents_hosting_aiohttp.egg-info}/PKG-INFO +2 -2
  6. microsoft_agents_hosting_aiohttp-1.4.0.dev13/microsoft_agents_hosting_aiohttp.egg-info/requires.txt +2 -0
  7. microsoft_agents_hosting_aiohttp-1.3.0/VERSION.txt +0 -1
  8. microsoft_agents_hosting_aiohttp-1.3.0/microsoft_agents_hosting_aiohttp.egg-info/requires.txt +0 -2
  9. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/LICENSE +0 -0
  10. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/MANIFEST.in +0 -0
  11. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/microsoft_agents/hosting/aiohttp/__init__.py +0 -0
  12. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/microsoft_agents/hosting/aiohttp/_aiohttp_request_adapter.py +0 -0
  13. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/microsoft_agents/hosting/aiohttp/_start_agent_process.py +0 -0
  14. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/microsoft_agents/hosting/aiohttp/agent_http_adapter.py +0 -0
  15. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/microsoft_agents/hosting/aiohttp/channel_service_route_table.py +0 -0
  16. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/microsoft_agents_hosting_aiohttp.egg-info/SOURCES.txt +0 -0
  17. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/microsoft_agents_hosting_aiohttp.egg-info/dependency_links.txt +0 -0
  18. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/microsoft_agents_hosting_aiohttp.egg-info/top_level.txt +0 -0
  19. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/pyproject.toml +0 -0
  20. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/readme.md +0 -0
  21. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/setup.cfg +0 -0
  22. {microsoft_agents_hosting_aiohttp-1.3.0 → microsoft_agents_hosting_aiohttp-1.4.0.dev13}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: microsoft-agents-hosting-aiohttp
3
- Version: 1.3.0
3
+ Version: 1.4.0.dev13
4
4
  Summary: Integration library for Microsoft Agents with aiohttp
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==1.3.0
18
+ Requires-Dist: microsoft-agents-hosting-core==1.4.0.dev13
19
19
  Requires-Dist: aiohttp>=3.11.11
20
20
  Dynamic: license-file
21
21
  Dynamic: requires-dist
@@ -0,0 +1 @@
1
+ 1.4.0.dev13
@@ -24,16 +24,20 @@ class CloudAdapter(HttpAdapterBase, AgentHttpAdapter):
24
24
  *,
25
25
  connection_manager: Connections | None = None,
26
26
  channel_service_client_factory: ChannelServiceClientFactoryBase | None = None,
27
+ channel_service_client_factory_options: dict | None = None,
27
28
  ):
28
29
  """
29
30
  Initializes a new instance of the CloudAdapter class.
30
31
 
31
32
  :param connection_manager: Optional connection manager for OAuth.
32
- :param channel_service_client_factory: The factory to use to create the channel service client.
33
+ :param channel_service_client_factory: Factory for creating channel service clients.
34
+ :param channel_service_client_factory_options: Optional dictionary of options to pass to the channel service client factory
35
+ This is only used if channel_service_client_factory is not provided and connection_manager is provided.
33
36
  """
34
37
  super().__init__(
35
38
  connection_manager=connection_manager,
36
39
  channel_service_client_factory=channel_service_client_factory,
40
+ channel_service_client_factory_options=channel_service_client_factory_options,
37
41
  )
38
42
 
39
43
  async def process(self, request: Request, agent: Agent) -> Optional[Response]:
@@ -68,4 +72,5 @@ class CloudAdapter(HttpAdapterBase, AgentHttpAdapter):
68
72
  return Response(
69
73
  status=http_response.status_code,
70
74
  headers=http_response.headers,
75
+ content_type=http_response.content_type,
71
76
  )
@@ -2,7 +2,7 @@
2
2
  # Licensed under the MIT License.
3
3
 
4
4
  import functools
5
-
5
+ import logging
6
6
  from typing import cast
7
7
 
8
8
  from aiohttp.web import Request, middleware, json_response
@@ -11,6 +11,25 @@ from microsoft_agents.hosting.core.authorization import AgentAuthConfiguration
11
11
  from microsoft_agents.hosting.core.authorization.jwt import _authorize_request
12
12
  from microsoft_agents.hosting.core.http import HttpResponse
13
13
 
14
+ logger = logging.getLogger(__name__)
15
+
16
+ _GENERIC_AUTH_ERROR = {"error": "Invalid token or authentication failed."}
17
+
18
+
19
+ def _extract_bearer_token(auth_header: str) -> str | None:
20
+ """Extracts the bearer token from a raw Authorization header value.
21
+
22
+ Surrounding whitespace on the token is ignored for backward compatibility.
23
+ Returns None for anything malformed so callers can respond with a
24
+ consistent 401 instead of raising.
25
+ """
26
+ parts = auth_header.split(maxsplit=1)
27
+ if len(parts) != 2 or parts[0].lower() != "bearer":
28
+ return None
29
+
30
+ token = parts[1].strip()
31
+ return token if token and not any(char.isspace() for char in token) else None
32
+
14
33
 
15
34
  async def _jwt_authorization_middleware(request: Request, handler):
16
35
  """
@@ -21,6 +40,18 @@ async def _jwt_authorization_middleware(request: Request, handler):
21
40
  )
22
41
 
23
42
  auth_header = request.headers.get("Authorization")
43
+ if auth_header is not None:
44
+ # aiohttp-specific tolerance: trailing whitespace (spaces/tabs) after
45
+ # the bearer token is ignored for backward compatibility, but internal
46
+ # or extra non-whitespace content is rejected. Normalizing here keeps
47
+ # the shared `_authorize_request` parsing (used identically by the
48
+ # FastAPI adapter) strict and unchanged.
49
+ token = _extract_bearer_token(auth_header)
50
+ if token is None:
51
+ logger.warning("Malformed authorization header.")
52
+ return json_response(_GENERIC_AUTH_ERROR, status=401)
53
+ auth_header = f"Bearer {token}"
54
+
24
55
  res = await _authorize_request(auth_header, auth_config)
25
56
 
26
57
  if isinstance(res, HttpResponse):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: microsoft-agents-hosting-aiohttp
3
- Version: 1.3.0
3
+ Version: 1.4.0.dev13
4
4
  Summary: Integration library for Microsoft Agents with aiohttp
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==1.3.0
18
+ Requires-Dist: microsoft-agents-hosting-core==1.4.0.dev13
19
19
  Requires-Dist: aiohttp>=3.11.11
20
20
  Dynamic: license-file
21
21
  Dynamic: requires-dist
@@ -0,0 +1,2 @@
1
+ microsoft-agents-hosting-core==1.4.0.dev13
2
+ aiohttp>=3.11.11
@@ -1 +0,0 @@
1
- 1.3.0
@@ -1,2 +0,0 @@
1
- microsoft-agents-hosting-core==1.3.0
2
- aiohttp>=3.11.11