Add initial version of Entra authentication sidecar#424
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new authentication provider package (microsoft-agents-authentication-entra-auth-sidecar) that delegates outbound token acquisition to the Microsoft Entra ID Agent Container (sidecar), and extends hosting-core to better support provider-agnostic configuration/routing (including MSAL and non-MSAL providers).
Changes:
- Added the Entra Auth Sidecar authentication library (client, provider, settings/models, errors) plus tests and a runnable sample.
- Introduced provider-agnostic hosting-core primitives (
ConnectionManager,ConnectionSettingsBase) and updated MSAL + connector-client factory logic to work with non-MSAL providers. - Added shared env-value coercion helpers (
coerce_bool/int/float) and updated docs/build setup to include the new package.
Reviewed changes
Copilot reviewed 39 out of 40 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/hosting_core/test_rest_channel_service_client_factory.py | Adds coverage for agentic token retrieval when providers expose configuration instead of MSAL internals. |
| tests/hosting_core/test_connection_settings_base.py | Tests new provider-agnostic ConnectionSettingsBase binding behavior. |
| tests/hosting_core/test_connection_manager.py | Tests new generic ConnectionManager routing behavior across multiple connections/map entries. |
| tests/hosting_core/test_auth_configuration.py | Adds tests for new .NET-aligned aliases and safe boolean coercion. |
| tests/authentication_entra_auth_sidecar/test_token_expiry.py | Validates JWT exp parsing and fallback lifetime logic. |
| tests/authentication_entra_auth_sidecar/test_sidecar_http_client.py | Exercises sidecar HTTP URL validation, query building, retries, and error shaping. |
| tests/authentication_entra_auth_sidecar/test_sidecar_auth.py | Validates SidecarAuth mapping and caching semantics. |
| tests/authentication_entra_auth_sidecar/test_settings.py | Validates settings normalization + env end-to-end flow into provider construction. |
| tests/authentication_entra_auth_sidecar/init.py | Test package marker for the sidecar auth tests. |
| tests/activity/test_config_coercion.py | Adds tests for shared env coercion helpers. |
| test_samples/entra_sidecar/requirements.txt | Sample dependencies for running the Entra sidecar demo. |
| test_samples/entra_sidecar/README.md | Usage/config documentation for the Entra sidecar sample. |
| test_samples/entra_sidecar/env.TEMPLATE | Template env config for the Entra sidecar sample (including token validation toggle). |
| test_samples/entra_sidecar/agent.py | Runnable aiohttp agent sample wired to SidecarAuth via generic ConnectionManager. |
| scripts/dev_setup.sh | Includes editable install for the new sidecar auth library. |
| scripts/dev_setup.ps1 | Includes editable install for the new sidecar auth library. |
| README.md | Adds the new PyPI package to the top-level package list. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/rest_channel_service_client_factory.py | Makes agentic token retrieval provider-agnostic (_msal_configuration vs configuration). |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/connection_settings_base.py | Adds base provider-agnostic connection settings model + binding helpers. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/connection_manager.py | Adds generic connection manager that dispatches to any AccessTokenProviderBase. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/auth_types.py | Adds EntraAuthSideCar auth type enum value. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/agent_auth_configuration.py | Adds alias keys, safe boolean coercion, and snake_case read-only aliases. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/authorization/init.py | Re-exports new ConnectionManager and ConnectionSettingsBase. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/init.py | Re-exports new ConnectionManager and ConnectionSettingsBase at the core package level. |
| libraries/microsoft-agents-authentication-msal/microsoft_agents/authentication/msal/msal_connection_manager.py | Refactors MSAL connection manager to a thin subclass of the new generic ConnectionManager. |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/setup.py | Packaging entrypoint for the new sidecar auth library (version + deps). |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/readme.md | Library README with mapping/config/caching documentation. |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/pyproject.toml | Project metadata for the new sidecar auth library. |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/microsoft_agents/authentication/entra_auth_sidecar/sidecar_http_client.py | Sidecar HTTP client (SSRF guard, retries, parsing, errors). |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/microsoft_agents/authentication/entra_auth_sidecar/sidecar_auth.py | Token provider implementation + caching layer that calls the sidecar. |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/microsoft_agents/authentication/entra_auth_sidecar/errors/error_resources.py | Error messages/resources and sidecar exception types. |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/microsoft_agents/authentication/entra_auth_sidecar/errors/init.py | Public error exports for the sidecar auth library. |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/microsoft_agents/authentication/entra_auth_sidecar/_token_expiry.py | Token expiry resolver (JWT exp or fallback). |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/microsoft_agents/authentication/entra_auth_sidecar/_models.py | Sidecar settings/options/result/problem-details models + coercion usage. |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/microsoft_agents/authentication/entra_auth_sidecar/init.py | Public exports for the sidecar auth library. |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/MANIFEST.in | Includes VERSION.txt in source distribution. |
| libraries/microsoft-agents-authentication-entra-auth-sidecar/LICENSE | MIT license file for the new package. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/config/_coercion.py | Adds shared coercion helpers for env-derived values (bool/int/float). |
| CLAUDE.md | Updates dev docs and library architecture list to include the new package. |
| .github/workflows/python-package.yml | Installs the newly produced wheel in CI packaging workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ce configuration binding in tests
…ent and SidecarAuth functionality
… update related tests for consistency
…iguration for anonymous access control; add tests for new behaviors
| # sidecar) expose it as ``configuration``. The only value needed here is | ||
| # the optional alternate-blueprint connection name. | ||
| configuration = getattr(connection, "_msal_configuration", None) | ||
| if configuration is None: | ||
| configuration = getattr(connection, "configuration", None) | ||
|
|
||
| alt_blueprint_id = ( | ||
| getattr(configuration, "ALT_BLUEPRINT_ID", None) if configuration else None | ||
| ) |
There was a problem hiding this comment.
I'm adding a comment here for completion. This not ideal, but this method was like that already, but this is a good reminder that this needs to be cleaned up. I will create a task for it
…support raw mapping input; improve error handling in SidecarHttpClient to redact sensitive information from URLs; add tests for new behaviors in connection management and token expiry handling.
| def _make_client(handler, **kwargs): | ||
| transport = httpx.MockTransport(handler) | ||
| http_client = httpx.AsyncClient(transport=transport) | ||
| return SidecarHttpClient("http://localhost:5178", http_client=http_client, **kwargs) |
This pull request introduces a new authentication package,
microsoft-agents-authentication-entra-auth-sidecar, which enables credential-free Entra ID Agent ID authentication via a sidecar process. The PR includes the package’s initial implementation, updates documentation to reference and describe the new package, and adds configuration and utility code to support robust environment variable handling and token expiry logic.Key changes:
New authentication package: Entra Auth Sidecar
microsoft-agents-authentication-entra-auth-sidecar, including its initial implementation, license, and manifest. This package provides credential-free Entra ID Agent ID authentication via a sidecar and exposesSidecarAuth,SidecarHttpClient, and related models and errors. [1] [2] [3] [4] [5] [6]Documentation updates
README.mdandCLAUDE.mdto document the new package, its purpose, usage, and how it fits into the SDK’s modular architecture. The documentation now includes the new package in the authentication layer and lists its features and install instructions. [1] [2] [3] [4] [5]Build and install process
.github/workflows/python-package.yml) and editable install instructions to include the new package in the build and installation steps. [1] [2]Configuration and utility enhancements
microsoft_agents/activity/config/_coercion.pythat provides robust helpers for coercing environment variable values to bool, int, and float, ensuring consistent and safe configuration parsing across the SDK.These changes collectively introduce a new authentication mechanism, ensure it is properly documented and integrated into the build system, and improve configuration handling across the SDK.