-
Notifications
You must be signed in to change notification settings - Fork 348
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
[MSI V2 Feature] Adding IMDSV2 probe logic #5135
base: msiv2-feature
Are you sure you want to change the base?
Conversation
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
/// <exception cref="ArgumentNullException"></exception> | ||
public static async Task<ManagedIdentitySource> GetManagedIdentitySourceAsync( |
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.
nit: be consistent with visibility modifiers. Use internal
everywhere
/// <exception cref="ArgumentNullException"></exception> | ||
public static async Task<ManagedIdentitySource> GetManagedIdentitySourceAsync( | ||
IServiceBundle serviceBundle, | ||
CancellationToken cancellationToken = default) |
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.
nit; don't use default params in internal code. it leads other developers to use the simpler versions without thinking too much.
@@ -45,6 +46,7 @@ public static void ResetInternalStaticCaches() | |||
OidcRetrieverWithCache.ResetCacheForTest(); | |||
AuthorityManager.ClearValidationCache(); | |||
SingletonThrottlingManager.GetInstance().ResetCache(); | |||
ManagedIdentityClient.ResetManagedIdentitySourceCache(); |
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.
Doesn't the method ResetInternalStaticCaches
need to be exposed in public API for Azure SDK ? Probably experimental extensiblity PR. Can be as a separate PR, just making sure it's on your radar.
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.
I will track it as part of #5136
} | ||
catch (Exception ex) | ||
{ | ||
_logger.Info($"[Credential Probe] Exception during probe: {ex.Message}"); |
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.
Should be _logger.Error
.
{ | ||
if (response == null) | ||
{ | ||
_logger.Info("[Credential Probe] No response received from the server."); |
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.
Should this also be logger.error like on line 80?
} | ||
} | ||
|
||
private void LogResponseDetails(HttpResponse response) |
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.
Actually, it looks like this method can be merged into the EvaluateProbeResponse
method. they are perfroming the same check on the response and printing the same messages
internal class ImdsV2ManagedIdentitySource : AbstractManagedIdentity | ||
{ | ||
/// <summary> | ||
/// Factory method to create an instance of `CredentialManagedIdentitySource`. |
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 factory method doesnt seem to have much logic in it besides the log message. Can the constructor be used to instantiate this instead? it returns a AbstractManagedIdentity but it looks like the type will always be ImdsV2ManagedIdentitySource anyway?
Fixes #5115
Please refer to the above task for more details. This is PR is part of a feature branch.
This pull request introduces several changes to the
Microsoft.Identity.Client
library, focusing on enhancing managed identity support, particularly with the addition of a newImdsV2
managed identity source. The changes include creating new classes, updating existing methods, and adding new methods to support asynchronous operations.Key changes include:
Enhancements to Managed Identity Support:
ImdsV2ManagedIdentitySource
class to handle the newImdsV2
managed identity source. (src/client/Microsoft.Identity.Client/ManagedIdentity/ImdsV2ManagedIdentitySource.cs
)ImdsCredentialProbeManager
class to probe the IMDS credential endpoint and determine its support. (src/client/Microsoft.Identity.Client/ManagedIdentity/ImdsCredentialProbeManager.cs
)ManagedIdentitySource
enum to include the newImdsV2
value. (src/client/Microsoft.Identity.Client/ManagedIdentity/ManagedIdentitySource.cs
)Asynchronous Method Updates:
ManagedIdentityClient
to use asynchronous methods for creating instances and selecting managed identity sources. (src/client/Microsoft.Identity.Client/ManagedIdentity/ManagedIdentityClient.cs
) [1] [2]SendTokenRequestForManagedIdentityAsync
method to use the new asynchronousCreateAsync
method forManagedIdentityClient
. (src/client/Microsoft.Identity.Client/Internal/Requests/ManagedIdentityAuthRequest.cs
)Public API Updates:
GetManagedIdentitySource
method and introduced an asynchronousGetManagedIdentitySourceAsync
method inManagedIdentityApplication
. (src/client/Microsoft.Identity.Client/ManagedIdentityApplication.cs
)ImdsV2
managed identity source and the asynchronous method in variousPublicAPI.Unshipped.txt
files. (src/client/Microsoft.Identity.Client/PublicApi/net462/PublicAPI.Unshipped.txt
,src/client/Microsoft.Identity.Client/PublicApi/net472/PublicAPI.Unshipped.txt
,src/client/Microsoft.Identity.Client/PublicApi/net8.0-android/PublicAPI.Unshipped.txt
)