-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add MSI token revocation support for legacy sources #5139
base: main
Are you sure you want to change the base?
Conversation
4ac538d
to
579b189
Compare
src/client/Microsoft.Identity.Client/ManagedIdentity/AbstractManagedIdentity.cs
Outdated
Show resolved
Hide resolved
src/client/Microsoft.Identity.Client/ManagedIdentity/AbstractManagedIdentity.cs
Outdated
Show resolved
Hide resolved
{ | ||
ManagedIdentityRequest request = new(System.Net.Http.HttpMethod.Get, _endpoint); | ||
|
||
request.Headers.Add(SecretHeaderName, _secret); | ||
request.QueryParameters["api-version"] = AppServiceMsiApiVersion; | ||
request.QueryParameters["resource"] = resource; | ||
|
||
ApplyClaimsAndCapabilities(request, parameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have AppService folks sing-off on a spec?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will remove bypass_cache
and pass the bad token hash for all MSI v1 sources, based on the sign off from APP Service today
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion
Even though App Service signed off this, they are not yet actively working on this, are they? I would suggest we add this new xms_cc
and token_sha256_to_refresh
behaviors for only Service Fabric in this PR.
Other MIv1 providers, when they are ready, can approach us in the future, and then we will be able to add support for them by this one-liner here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As part of the spec sign off, they (app service) also agreed on a deliverable. We need to get this out for them to actively work on this.
src/client/Microsoft.Identity.Client/ManagedIdentity/AzureArcManagedIdentitySource.cs
Outdated
Show resolved
Hide resolved
src/client/Microsoft.Identity.Client/ManagedIdentity/CloudShellManagedIdentitySource.cs
Outdated
Show resolved
Hide resolved
src/client/Microsoft.Identity.Client/ManagedIdentity/ImdsManagedIdentitySource.cs
Outdated
Show resolved
Hide resolved
src/client/Microsoft.Identity.Client/ManagedIdentity/MachineLearningManagedIdentitySource.cs
Outdated
Show resolved
Hide resolved
src/client/Microsoft.Identity.Client/ManagedIdentity/ServiceFabricManagedIdentitySource.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
src/client/Microsoft.Identity.Client/Internal/Requests/ManagedIdentityAuthRequest.cs
Show resolved
Hide resolved
src/client/Microsoft.Identity.Client/ManagedIdentity/AbstractManagedIdentity.cs
Show resolved
Hide resolved
src/client/Microsoft.Identity.Client/ManagedIdentity/ImdsManagedIdentitySource.cs
Outdated
Show resolved
Hide resolved
src/client/Microsoft.Identity.Client/ManagedIdentity/ImdsManagedIdentitySource.cs
Show resolved
Hide resolved
@@ -13,7 +15,7 @@ namespace Microsoft.Identity.Client.ManagedIdentity | |||
internal class AppServiceManagedIdentitySource : AbstractManagedIdentity | |||
{ | |||
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity | |||
private const string AppServiceMsiApiVersion = "2019-08-01"; | |||
private const string AppServiceMsiApiVersion = "2025-03-30"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to new api-version, we cannot merge this PR until App Service api-version has been updated globally. Marked the PR as do not merge. Also do not close this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail the integration test as there is no new API-VERSION in APP Service, yet. This failure is expected.
@@ -13,7 +15,7 @@ namespace Microsoft.Identity.Client.ManagedIdentity | |||
internal class AppServiceManagedIdentitySource : AbstractManagedIdentity | |||
{ | |||
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity | |||
private const string AppServiceMsiApiVersion = "2019-08-01"; | |||
private const string AppServiceMsiApiVersion = "2025-03-30"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this version of app service endpoint the equivalent to MITS endpoint mentioned in the spec?
Fixes #5138
Spec: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/main/docs/msiv1_token_revocation.md
This pull request includes significant changes to the
Microsoft.Identity.Client
library, focusing on enhancing the handling of managed identity authentication requests. The key changes involve adding support for claims and capabilities, improving token handling logic, and refactoring various classes to accommodate these new features.Enhancements to Managed Identity Authentication:
src/client/Microsoft.Identity.Client/ApiConfig/Parameters/AcquireTokenForManagedIdentityParameters.cs
: Added new propertiesClaims
andBadTokenHash
to support claims and token hashing.src/client/Microsoft.Identity.Client/Internal/Requests/ManagedIdentityAuthRequest.cs
: IntroducedICryptographyManager
to compute token hashes and updated theExecuteAsync
method to handle claims and token caching more effectively. [1] [2] [3]Refactoring for Claims and Capabilities:
src/client/Microsoft.Identity.Client/ManagedIdentity/AbstractManagedIdentity.cs
: Refactored methods to include claims and capabilities in the managed identity request, including the newApplyClaimsAndCapabilities
method. [1] [2]Updates to Managed Identity Sources:
AppServiceManagedIdentitySource
,AzureArcManagedIdentitySource
,CloudShellManagedIdentitySource
,ImdsManagedIdentitySource
,MachineLearningManagedIdentitySource
,ServiceFabricManagedIdentitySource
) to use the newCreateRequest
method signature that includesAcquireTokenForManagedIdentityParameters
. [1] [2] [3] [4] [5] [6] [7]These changes collectively improve the robustness and flexibility of managed identity authentication in the
Microsoft.Identity.Client
library.Testing
unit tests
Performance impact
none
Documentation