You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Windows Managed Identity v2 mTLS PoP and bearer integration - #987
Repository-owned head:AzureAD/microsoft-authentication-library-for-python:feature/managed-identity-v2.
Replaces the fork-based #985 with the identical implementation commit e339f16aca840a4c048ca8445374482c1124df7a. The bridge dependency on #982 remains.
Summary
Implement a Windows Managed Identity v2 development candidate using the Rust foundation in #982:
Explicit mtls_proof_of_possession, request_over_mtls, attestation opt-in, minimum strength and force-refresh options on ManagedIdentityClient.
IMDS platform metadata and credential issuance, protected-key PKCS#10 signing, independent KeyGuard attestation, and canonical OAuth client-credentials exchange over native mTLS.
Separate ordinary bearer, bearer-over-mTLS and full-leaf-bound PoP token caches; exact-generation synchronous and bounded worker-backed asynchronous resource transports.
V2-first capability discovery, deadline-isolated concurrent callers, certificate renewal/rejection recovery, and best-effort Windows certificate-store reattachment.
Independent optional Windows wheels, public examples, documentation, collected live tests and an opt-in installed-candidate CI stage.
Ordinary managed identity remains independent of the optional native packages. Explicit protected acquisition does not fall back to a software key.
Stacking and immutable references
Depends on #982. This PR targets dev and includes the #982 bridge commits
followed by the Python integration. It is ready for review so the normal dev OneBranch Python gate can trigger. Until #982 merges, the diff includes
both the native foundation and the integration; once #982 lands in dev, the
diff narrows to the integration. This is not a request to merge before the
dependency or outstanding acceptance requirements are satisfied.
Published sources compared: msal4j:1.26.1-preview1 (215 Java files) and msal4j-key-attestation:1.0.0-preview1 (17 Java files); no differences from the pinned Java reference after line-ending normalization.
Review fixes included
The local deep correctness review found six actionable issues, all addressed with focused regressions:
Failed certificate-store deletion could let another client restore a rejected binding. Invalidation is now shared across clients and remains until a replacement is successfully persisted, including after memory-cache eviction.
Token-cache DEBUG logging exposed the new claims pseudo-parameter. It is now redacted without changing partitioning.
Ordinary forced refresh skipped lookup of a challenged token. The refresh request now retains its SHA-256 reference.
A short discovery owner's deadline prematurely failed longer-budget waiters. Eligible waiters now restart within their own remaining budget.
Accepted HTTP retry configuration did not apply to native ESTS requests. Transient status retries now use the adapter's method/status/delay policy, independently bounded to three retries and a total budget, without certificate reminting.
IMDS errors discarded service codes. Trusted, bounded service codes are preserved without including response bodies or descriptions.
Regression mapping
All Python paths below are in this PR. Reference PR numbers in this table refer to MSAL.NET unless identified otherwise.
Platform differences: Python uses OpenSSL alert categories / Windows reset 10054, not Schannel exceptions; PoP partitioning uses SHA-256 of the entire leaf DER, not a certificate serial number. The async adapter is bounded worker-backed, not an aiohttp SSL-context integration. The audience is not a wildcard for arbitrary resource origins.
CI and PR targeting
The original draft targeted feature/native-primitives and initially ran only
the package build: native Actions filtered for dev, and OneBranch targets dev and excludes drafts. Credential-free checks were added for that stacked
base and have now passed remotely at e339f16aca840a4c048ca8445374482c1124df7a:
The existing Build workflow runs unit tests on Python 3.9 through 3.14 for
PRs targeting feature/native-primitives, including drafts.
Native Windows CI accepts that stacked base and relevant Python integration
paths. Its existing complete Debug/Release native matrix and dependency checks
are retained, followed by Python 3.12 native integration tests.
Both workflows upload JUnit artifacts. Existing OneBranch branch/draft rules,
SDL checks and live-test restrictions are unchanged.
All six Python matrix jobs, Windows native/Python integration and dependency
policy checks passed. The PR now targets dev and is ready for review, retaining
the bridge in its head history so the normal OneBranch gate can run as well.
Those completed runs were on the earlier fork PR #985. This replacement uses a
branch in the AzureAD repository to avoid fork restrictions on trusted CI;
new run status is shown in this PR's checks.
The workflow changes passed pinned actionlint validation. The exact Windows
Python test command passed locally: 117 tests and 121 subtests. Remote CI results
are reported in the PR checks; the local results below are not remote-CI claims.
Local test evidence
Tests were run on Windows x64 with Python 3.12.10:
The automated baseline excluded existing live integration files and the interactive Windows broker sign-in test (which timed out waiting for user interaction). Two existing latest-cryptography policy tests were deselected. The 513-test result is a baseline, not a post-fix full-suite claim. The installed unittest run reports implicit temporary-directory cleanup ResourceWarnings from fixtures.
All seven relevant installed Python modules, including token_cache, matched checkout hashes. The live-profile SDK fingerprint is 668df0f7f2e8d6eafeb04f7d8b7098e5ad40bec78cbfbbca7543d50daf8b3aac.
Outstanding acceptance evidence
This is not a release-ready or positively attested implementation claim.
Ten live cases are collected but were not executed. Actual VBS/KeyGuard creation/liveness/recreation, MAA, IMDSv2, ESTS and strict Key Vault binding/negative controls remain outstanding.
Actual supported-host representation of the CNG Virtual Iso property remains to be verified; software-CNG fixtures are not VBS evidence.
Cross-process/live rotation and remaining historical parity mapping require follow-through.
Maintainer/security release review and production signing are still required. Development integrity manifests do not authenticate a publisher.
Optional wheels remain development versions. No compiled native libraries, downloaded packages, credentials or private keys are included in this PR.
See docs/managed-identity-v2.rst for build/install instructions, supported transport constraints, samples and the full installed live-validation profile.
Host the native workspace separately from Python runtime and packaging.
Clarify compatible dependency ranges without changing the lockfile.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6fe4a5cf-79f6-48f9-aa71-bd8af58c504b
Duplicate selected public material when no private material exists.
Add an external OpenSSL regression and correct the example DLL path.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6fe4a5cf-79f6-48f9-aa71-bd8af58c504b
Reject retained explicit MGF1 mismatches before signature state updates.
Account for IPv6 brackets before reserving the plaintext request buffer.
Add sequential-update and exact wire-limit regressions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6fe4a5cf-79f6-48f9-aa71-bd8af58c504b
Move CMake/vcpkg setup ahead of the first quick-start build and reuse
the quick-start configuration steps from the build/test section.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6fe4a5cf-79f6-48f9-aa71-bd8af58c504b
Guard sensitive copies before validation can fail. Accept HTTP token field names and surrounding Content-Length whitespace while preserving strict framing. Add allocation-observer and protocol regressions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6fe4a5cf-79f6-48f9-aa71-bd8af58c504b
Connect the Rust native foundation to explicit PoP and bearer-over-mTLS managed identity acquisition, attestation, generation-bound transports, persistence, packaging and regression coverage.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6fe4a5cf-79f6-48f9-aa71-bd8af58c504b
Keep the feature/native-primitives stack and existing OneBranch policies. Add credential-free Python matrix checks for stacked drafts and enable Windows native/Python integration coverage on the stacked base.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6fe4a5cf-79f6-48f9-aa71-bd8af58c504b
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The installed-candidate fingerprint omits the changed msal.token_cache module, allowing a wheel with stale token-cache code to pass source identity checks.
No open issues 🎉
What changed in this PR
Adds a Windows Managed Identity v2 development candidate on the Rust foundation from #982. It connects MSAL Python to optional protected-key mTLS and attestation packages while keeping ordinary managed identity independent of them. Live KeyGuard and service acceptance evidence remains outstanding.
Changes:
Adds explicit PoP and bearer-over-mTLS acquisition, certificate persistence, and generation-bound synchronous and asynchronous resource transports.
Includes the standalone Rust CNG/OpenSSL foundation, native ABI, conformance tests, and development guidance.
Adds optional Windows wheel tooling, public examples, live validation profiles, and CI integration.
File
Description
tools/prepare_mi_attestation.ps1
Downloads and verifies the pinned attestation DLL.
tools/build_mi_native_wheels.ps1
Verifies artifacts and builds optional Windows wheels.
tests/test_mi_v2_e2e.py
Adds installed-candidate live acquisition and binding checks.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Malformed cache metadata and case-sensitive header removal can break credential acquisition and request dispatch, while the installation fingerprint can miss an outdated token-cache module with the claims-logging defect.
Build candidate wheels automatically and use the shared SAMI Key Vault fixture. Retain the full manual profile and allow an explicit MSAL_SKIP_MI_V2 opt-out.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 30f6db0b-e29c-474d-8fba-b560bd96f1bf
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The line-count script truncates files at the first #[cfg(test)], omitting subsequent production code and undercounting files such as crates/cng-provider/src/allocation.rs.
Exclude test-gated items without dropping later production code
native/scripts/loc.ps1:14
Stopping at the first #[cfg(test)] drops production code that follows a test-only item. For example, crates/cng-provider/src/allocation.rs is counted as only three lines, omitting the production allocators starting at line 86. Exclude individual test-gated items rather than discarding the rest of each file.
Keep the C++ toolchain off the managed-identity runner. Build the candidate on windows-2022 and download its same-run artifact for live tests.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 30f6db0b-e29c-474d-8fba-b560bd96f1bf
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Converting headers to a plain dict makes Content-Length handling case-sensitive, causing valid POST requests with lowercase content-length headers to be rejected by the native transport’s allowlist.
Explicitly publish the candidate artifact from the custom hosted build job before the managed-identity job downloads it.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 30f6db0b-e29c-474d-8fba-b560bd96f1bf
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Converting prepared headers to a plain dict makes Content-Length removal case-sensitive, leaving lowercase variants to be rejected by the native header allowlist and causing valid GET requests to fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repository-owned head:
AzureAD/microsoft-authentication-library-for-python:feature/managed-identity-v2.Replaces the fork-based #985 with the identical implementation commit
e339f16aca840a4c048ca8445374482c1124df7a. The bridge dependency on #982 remains.Summary
Implement a Windows Managed Identity v2 development candidate using the Rust foundation in #982:
mtls_proof_of_possession,request_over_mtls, attestation opt-in, minimum strength and force-refresh options onManagedIdentityClient.Ordinary managed identity remains independent of the optional native packages. Explicit protected acquisition does not fall back to a software key.
Stacking and immutable references
Depends on #982. This PR targets
devand includes the #982 bridge commitsfollowed by the Python integration. It is ready for review so the normal
devOneBranch Python gate can trigger. Until #982 merges, the diff includesboth the native foundation and the integration; once #982 lands in
dev, thediff narrows to the integration. This is not a request to merge before the
dependency or outstanding acceptance requirements are satisfied.
10b146ad937ad823b2b5cd2da4e66df3b942f5c2dev, already includedc53d5ea47f7713d8fbc8e3d9832436fd1028b5c140039615ab4edad6f12e65206f0f7c5e09fa3442438f351a33a18494bb0938e4209e3413f4716584ea0148534593acbc58d700bffe8419b076a9dd37bc8f196579ed16b79a679849282e43e79d5a001bPublished sources compared:
msal4j:1.26.1-preview1(215 Java files) andmsal4j-key-attestation:1.0.0-preview1(17 Java files); no differences from the pinned Java reference after line-ending normalization.Review fixes included
The local deep correctness review found six actionable issues, all addressed with focused regressions:
Regression mapping
All Python paths below are in this PR. Reference PR numbers in this table refer to MSAL.NET unless identified otherwise.
GetManagedIdentityCapabilities_TimedOutWaiter_DoesNotCancelLockOwnerAsync; kill-switch/minimum-strength behavior_managed_identity_v2._CapabilityDiscovery;ManagedIdentityClienttests/test_managed_identity_v2.py::CapabilityDiscoveryTests;PublicProtectedFlowTests::test_disabled_or_invalid_modes_do_no_http_or_native_work;test_keyguard_failure_preserves_required_strength_and_native_category_ImdsClient,_MaaTokenCache,_NativeAttestationImdsV2ProtocolTests;MaaCacheTests;NativeAttestationOwnershipTests;PublicProtectedFlowTests::test_attestation_denial_prevents_credential_issuanceintests/test_managed_identity_v2.pymTLSPop_ForceRefresh_RemintsCachedCert_PostsCanonicalClientId_AndReusesCachedAttestation; rejected-binding recovery_V2Client,_is_binding_rejectionPublicProtectedFlowTests::test_force_refresh_remints_leaf_but_reuses_fresh_attestation_generation;test_wrapped_binding_reset_retries_once_but_unrelated_oauth_failure_does_not;test_native_certificate_alerts_recover_once_and_nested_trust_failure_never_retriesRead_Boundary_Exactly24h_IsRejected; persistent-cache binding restoration_CertificateStore,_V2ClientWindowsCertificateStoreTests;PublicProtectedFlowTests::test_restart_reattaches_persisted_leaf_before_returning_serialized_pop_token;test_failed_invalidation_is_shared_with_another_client_V2Client.acquire: resolve binding before lookup; update partition after recoveryPublicProtectedFlowTests::test_invalid_client_remints_once_but_wrong_token_types_never_enter_cache; force-refresh and restart testsImdsV2Tests.TestCsrGeneration_VmIdAndVmssId/OnlyVmId; JavaPkcs10BuilderTestsubject, CUID and DER tests_create_csrtests/test_native_mtls.py::NativeKeyOwnershipTests::test_csr_preserves_platform_identity_cuid_der_and_pss_parameters;test_csr_omits_absent_cuid_fields_NativeRuntime, additive native protected-key exportstests/test_native_mtls.py::NativeOwnershipTests;WindowsRustOAuthTests::test_real_oauth_form_posts_present_the_opaque_cng_key_in_both_modes; native Debug/Release matrixPlatform differences: Python uses OpenSSL alert categories / Windows reset 10054, not Schannel exceptions; PoP partitioning uses SHA-256 of the entire leaf DER, not a certificate serial number. The async adapter is bounded worker-backed, not an aiohttp SSL-context integration. The audience is not a wildcard for arbitrary resource origins.
CI and PR targeting
The original draft targeted
feature/native-primitivesand initially ran onlythe package build: native Actions filtered for
dev, and OneBranch targetsdevand excludes drafts. Credential-free checks were added for that stackedbase and have now passed remotely at
e339f16aca840a4c048ca8445374482c1124df7a:PRs targeting
feature/native-primitives, including drafts.paths. Its existing complete Debug/Release native matrix and dependency checks
are retained, followed by Python 3.12 native integration tests.
SDL checks and live-test restrictions are unchanged.
All six Python matrix jobs, Windows native/Python integration and dependency
policy checks passed. The PR now targets
devand is ready for review, retainingthe bridge in its head history so the normal OneBranch gate can run as well.
Those completed runs were on the earlier fork PR #985. This replacement uses a
branch in the AzureAD repository to avoid fork restrictions on trusted CI;
new run status is shown in this PR's checks.
The workflow changes passed pinned
actionlintvalidation. The exact WindowsPython test command passed locally: 117 tests and 121 subtests. Remote CI results
are reported in the PR checks; the local results below are not remote-CI claims.
Local test evidence
Tests were run on Windows x64 with Python 3.12.10:
Focused source commands:
Clean-installed command, using copied test modules outside the checkout:
The automated baseline excluded existing live integration files and the interactive Windows broker sign-in test (which timed out waiting for user interaction). Two existing latest-cryptography policy tests were deselected. The 513-test result is a baseline, not a post-fix full-suite claim. The installed unittest run reports implicit temporary-directory cleanup ResourceWarnings from fixtures.
All seven relevant installed Python modules, including
token_cache, matched checkout hashes. The live-profile SDK fingerprint is668df0f7f2e8d6eafeb04f7d8b7098e5ad40bec78cbfbbca7543d50daf8b3aac.Outstanding acceptance evidence
This is not a release-ready or positively attested implementation claim.
See
docs/managed-identity-v2.rstfor build/install instructions, supported transport constraints, samples and the full installed live-validation profile.