-
Notifications
You must be signed in to change notification settings - Fork 385
MSI POP Attestation #5612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
MSI POP Attestation #5612
Changes from all commits
cf72c38
56889d7
ba29c76
595aaa8
7acfbed
f9324df
fac7299
9db5690
8f0dd8f
83aa4c4
1e24c34
90b5326
b78c476
2a50866
caf7da7
31cf11d
7a19b8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Runtime.InteropServices; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Identity.Client.ManagedIdentity; | ||
|
|
||
| namespace Microsoft.Identity.Client.KeyAttestation.Attestation | ||
| { | ||
| /// <summary> | ||
| /// Implementation of IAttestationProvider for KeyGuard attestation. | ||
| /// This provider is automatically registered when the KeyAttestation package is loaded. | ||
| /// </summary> | ||
| internal class KeyGuardAttestationProvider : IAttestationProvider | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this PR is doing too much. The existing logic just sets |
||
| { | ||
| public async Task<ManagedIdentity.AttestationResult> AttestKeyGuardAsync( | ||
| string attestationEndpoint, | ||
| SafeHandle keyHandle, | ||
| string clientId, | ||
| CancellationToken cancellationToken) | ||
| { | ||
| try | ||
| { | ||
| // Call the existing PopKeyAttestor implementation | ||
| var result = await PopKeyAttestor.AttestKeyGuardAsync( | ||
| attestationEndpoint, | ||
| keyHandle, | ||
| clientId, | ||
| cancellationToken).ConfigureAwait(false); | ||
|
|
||
| // Map the result to the MSAL interface types | ||
| return new ManagedIdentity.AttestationResult | ||
| { | ||
| Status = result.Status == AttestationStatus.Success | ||
| ? ManagedIdentity.AttestationStatus.Success | ||
| : ManagedIdentity.AttestationStatus.Failed, | ||
| Jwt = result.Jwt, | ||
| ErrorMessage = result.ErrorMessage, | ||
| NativeErrorCode = result.NativeErrorCode | ||
| }; | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| return new ManagedIdentity.AttestationResult | ||
| { | ||
| Status = ManagedIdentity.AttestationStatus.Failed, | ||
| ErrorMessage = ex.Message, | ||
| NativeErrorCode = -1 | ||
| }; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Static initializer that registers the KeyGuard attestation provider | ||
| /// when the KeyAttestation assembly is loaded. | ||
| /// </summary> | ||
| internal static class AttestationProviderInitializer | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1 file per class pls |
||
| { | ||
| static AttestationProviderInitializer() | ||
| { | ||
| // Register the provider when this type is first accessed | ||
| AttestationProviderRegistry.RegisterProvider(new KeyGuardAttestationProvider()); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Method to force static constructor execution. | ||
| /// Called from module initializer. | ||
| /// </summary> | ||
| internal static void Initialize() | ||
| { | ||
| // This method body is intentionally empty. | ||
| // Its purpose is to trigger the static constructor above. | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.