Repository navigation
Add Windows Managed Identity v2 mTLS PoP and bearer integration - #985
Closed
Gladwin Johnson VR (gladjohn) wants to merge 8 commits into
Closed
Gladwin Johnson VR (gladjohn) wants to merge 8 commits into
Gladwin Johnson VR (gladjohn) wants to merge 8 commits into
Conversation
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
Permit secure delayed TLS client authentication under the existing I/O deadline. Preserve key and signing configuration during null-key context reuse. Bound RSA encodings before conversion and zeroize transient URI/name copies. Add Windows/CNG regressions, with 67 Rust tests per Debug/Release configuration and the complete native matrix passing. 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
Gladwin Johnson VR (gladjohn)
changed the base branch from
feature/native-primitives
to
dev
November 13, 2026 12:45
Gladwin Johnson VR (gladjohn)
marked this pull request as ready for review
November 13, 2026 12:45
Gladwin Johnson VR (gladjohn)
requested a review
from a team
as a code owner
November 13, 2026 12:45
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Malformed SDK-tagged store entries with non-string fields can trigger an uncaught AttributeError and abort token acquisition; string validation and regression tests are needed.
1 open issue
What changed in this PR
Adds a Windows Managed Identity v2 development candidate on top of the Rust foundation in #982. Explicit protected acquisition uses optional native packages, while ordinary managed identity remains independent of them. Live platform validation and release/security review remain outstanding.
Changes:
- Adds protected mTLS PoP and bearer acquisition, certificate persistence, and generation-bound synchronous and asynchronous resource transports.
- Includes the Rust CNG/OpenSSL foundation, protected-key ABI, and independent Windows wheel packaging.
- Adds samples, documentation, native CI, and an opt-in installed-candidate live validation stage.
| File | Description |
|---|---|
tools/prepare_mi_attestation.ps1 |
Downloads and verifies the pinned attestation DLL. |
tools/build_mi_native_wheels.ps1 |
Stages verified artifacts and builds optional wheels. |
tests/test_mi_v2_e2e.py |
Adds opt-in installed-candidate live tests. |
sample/managed_identity_v2.py |
Demonstrates PoP, async PoP, and bearer requests. |
README.md |
Introduces the native project. |
packages/msal-native-primitives/setup.py |
Defines the Windows native wheel. |
packages/msal-native-primitives/msal_native_primitives/__init__.py |
Declares optional native package metadata. |
packages/msal-key-attestation/setup.py |
Defines the independent attestation wheel. |
packages/msal-key-attestation/msal_key_attestation/__init__.py |
Declares attestation package metadata. |
native/vcpkg.json |
Pins the native OpenSSL dependency baseline. |
native/THIRD-PARTY-NOTICES.md |
Documents dependency notice obligations. |
native/tests/native/support/cng_key.h |
Declares CNG test-support interfaces. |
native/SUPPORT.md |
Defines pre-release support scope. |
native/SECURITY.md |
Documents vulnerability reporting and sensitive areas. |
native/scripts/test.ps1 |
Runs Debug/Release validation and key cleanup checks. |
native/scripts/loc.ps1 |
Reports a production Rust line count. |
native/scripts/build.ps1 |
Builds native artifacts and integrity manifests. |
native/rustfmt.toml |
Configures Rust formatting. |
native/README.md |
Describes native architecture, setup, and usage. |
native/LICENSE |
Supplies the native project's MIT license. |
native/include/microsoft_identity_native_primitives.h |
Declares transport and protected-key C APIs. |
native/include/cng_provider_params.h |
Defines provider parameters and URI limits. |
native/examples/c/mtls_request.c |
Demonstrates a native certificate-bound request. |
native/docs/versioning.md |
Defines product, ABI, and dependency versioning. |
native/docs/security-review.md |
Specifies security review requirements. |
native/docs/security-model.md |
Documents trust boundaries and enforced properties. |
native/docs/releasing.md |
Defines native release gates. |
native/docs/development.md |
Documents native development practices. |
native/docs/building-and-testing.md |
Explains build, test, and OpenSSL servicing plans. |
native/docs/architecture.md |
Describes crate responsibilities and request flow. |
native/docs/abi.md |
Documents ABI ownership and protected-key contracts. |
native/deny.toml |
Configures dependency and license policy checks. |
native/crates/rust-tests/tests/key_creation_race.rs |
Tests cross-process key creation convergence. |
native/crates/rust-tests/src/lib.rs |
Adds an ABI smoke test. |
native/crates/rust-tests/src/bin/key-race-helper.rs |
Supports concurrent key creation tests. |
native/crates/rust-tests/src/bin/key-audit.rs |
Detects leftover project test keys. |
native/crates/rust-tests/Cargo.toml |
Configures cross-crate test dependencies. |
native/crates/openssl-provider-sys/Cargo.toml |
Configures the OpenSSL FFI crate. |
native/crates/mtls-bridge/src/lib.rs |
Implements request execution and response ownership. |
native/crates/mtls-bridge/src/abi.rs |
Defines ABI layouts, bounds, and structured errors. |
native/crates/mtls-bridge/Cargo.toml |
Configures the transport library and dependencies. |
native/crates/cng-provider/src/uri.rs |
Parses bounded CNG key URIs. |
native/crates/cng-provider/src/store.rs |
Implements OpenSSL STORE loading and ownership. |
native/crates/cng-provider/src/params.rs |
Handles typed OpenSSL parameters. |
native/crates/cng-provider/src/lib.rs |
Registers provider algorithms and callbacks. |
native/crates/cng-provider/src/error.rs |
Produces bounded provider diagnostics. |
native/crates/cng-provider/src/allocation.rs |
Adds fallible allocation and cleanup test helpers. |
native/crates/cng-provider/Cargo.toml |
Configures the CNG provider library. |
native/crates/cng-core/Cargo.toml |
Configures Windows key primitive dependencies. |
native/CONTRIBUTING.md |
Defines native contribution and validation requirements. |
native/CMakeLists.txt |
Builds external C tests and the example. |
native/CHANGELOG.md |
Records native additions and hardening changes. |
native/Cargo.toml |
Defines workspace dependencies and lint settings. |
native/Cargo.lock |
Records resolved Rust dependencies. |
native/AGENTS.md |
Documents native-specific development guidance. |
native/.gitignore |
Excludes generated native artifacts. |
native/.gitattributes |
Defines line endings and binary handling. |
native/.editorconfig |
Defines native file formatting conventions. |
msal/token_cache.py |
Redacts the v2 claims cache parameter. |
msal/managed_identity.py |
Adds discovery, protected modes, and refresh options. |
msal/_native_attestation.py |
Wraps optional native attestation with explicit ownership. |
msal/_managed_identity_store.py |
Persists and restores public certificate bindings. |
msal/_managed_identity_binding.py |
Adds generation-bound sync and async transports. |
docs/managed-identity-v2.rst |
Documents installation, contracts, and validation profiles. |
docs/index.rst |
Links the Managed Identity v2 guide. |
.Pipelines/template-pipeline-stages.yml |
Adds the opt-in installed-candidate live stage. |
.Pipelines/CI-AND-RELEASE-PIPELINES.md |
Documents stacked integration CI coverage. |
.gitignore |
Excludes optional wheel staging outputs. |
.github/workflows/python-package.yml |
Adds stacked-branch Python unit test coverage. |
.github/workflows/native-primitives.yml |
Adds Windows native and Python integration CI. |
.github/dependabot.yml |
Adds native Cargo dependency monitoring. |
Review effort: Balanced
Comment on lines
+151
to
+153
| client = metadata["client_id"] | ||
| uuid.UUID(client) | ||
| endpoint = _endpoint(metadata["token_endpoint"], stage="binding") |
Contributor
Author
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

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.
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.