Skip to content

Conversation

gladjohn
Copy link
Contributor

@gladjohn gladjohn commented Aug 20, 2025

Fixes - adds the key management logic for MSI flows or aka CSK (Client side keys)

This will not be merged as is. Instead will go into the MSI v2 feature branch.

This pull request introduces a new abstraction for Managed Identity key management, allowing for improved flexibility and security in how authentication keys are created and sourced. The main changes include the addition of provider classes for key creation (with platform-specific logic for Windows), a new interface for key providers, and integration of this abstraction into the authentication request flow. The implementation prioritizes secure hardware-backed keys and falls back to in-memory keys as needed.

Managed Identity Key Provider Abstraction

  • Introduced the IManagedIdentityKeyProvider interface (src/client/Microsoft.Identity.Client/ManagedIdentity/IManagedIdentityKeyProvider.cs) and the ManagedIdentityKeyInfo class to encapsulate key details and provider messages. [1] [2]

Platform-Specific Key Providers

  • Added InMemoryManagedIdentityKeyProvider, which generates and caches an RSA key in memory for authentication scenarios.
  • Added WindowsManagedIdentityKeyProvider, which attempts to source keys from KeyGuard (VBS isolation), hardware TPM/KSP, or falls back to in-memory keys, with detailed logging and error handling.
  • Added supporting helpers for Windows key operations, including KeyGuard and hardware-backed key creation (WindowsCngKeyOperations, KeyGuardHelper). [1] [2]

Integration with Authentication Flow

  • Updated ManagedIdentityAuthRequest to use the new key provider abstraction, retrieving the best available key for authentication. [1] [2]

Dependency Management

  • Adjusted Directory.Packages.props to ensure System.Security.Cryptography.Cng is included as a private asset for key provider functionality. [1] [2]

@gladjohn gladjohn changed the title draft - msi v2 client side keys MSI V2 client side keys Aug 25, 2025
@gladjohn gladjohn marked this pull request as ready for review August 25, 2025 17:30
@gladjohn gladjohn requested a review from a team as a code owner August 25, 2025 17:30
@gladjohn gladjohn force-pushed the gladjohn/msi_vs_keys branch from 292436c to c813ed0 Compare August 27, 2025 23:03
@gladjohn gladjohn force-pushed the gladjohn/msi_vs_keys branch 3 times, most recently from 2b237ff to 6578b06 Compare September 2, 2025 00:41
@gladjohn gladjohn force-pushed the gladjohn/msi_vs_keys branch from 6578b06 to df59d37 Compare September 4, 2025 13:26
Copy link
Contributor

@MZOLN MZOLN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General feedback

@Robbie-Microsoft Robbie-Microsoft changed the base branch from main to rginsburg/msiv2_feature_branch September 17, 2025 14:07
@Robbie-Microsoft Robbie-Microsoft merged commit 774e01e into rginsburg/msiv2_feature_branch Sep 19, 2025
3 checks passed
@Robbie-Microsoft Robbie-Microsoft deleted the gladjohn/msi_vs_keys branch September 19, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants