Skip to content

Commit 4e933c2

Browse files
Change the resource id param for IMDS (#5238)
1 parent b1c2157 commit 4e933c2

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/client/Microsoft.Identity.Client/Internal/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ internal static class Constants
4545
public const string ManagedIdentityClientId2017 = "clientid";
4646
public const string ManagedIdentityObjectId = "object_id";
4747
public const string ManagedIdentityResourceId = "mi_res_id";
48+
public const string ManagedIdentityResourceIdImds = "msi_res_id";
4849
public const string ManagedIdentityDefaultClientId = "system_assigned_managed_identity";
4950
public const string ManagedIdentityDefaultTenant = "managed_identity";
5051
public const string CiamAuthorityHostSuffix = ".ciamlogin.com";

src/client/Microsoft.Identity.Client/ManagedIdentity/ImdsManagedIdentitySource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected override ManagedIdentityRequest CreateRequest(string resource)
7373

7474
case AppConfig.ManagedIdentityIdType.ResourceId:
7575
_requestContext.Logger.Info("[Managed Identity] Adding user assigned resource id to the request.");
76-
request.QueryParameters[Constants.ManagedIdentityResourceId] = _requestContext.ServiceBundle.Config.ManagedIdentityId.UserAssignedId;
76+
request.QueryParameters[Constants.ManagedIdentityResourceIdImds] = _requestContext.ServiceBundle.Config.ManagedIdentityId.UserAssignedId;
7777
break;
7878

7979
case AppConfig.ManagedIdentityIdType.ObjectId:

tests/Microsoft.Identity.Test.Common/Core/Mocks/MockHttpManagerExtensions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,10 @@ public static void AddManagedIdentityMockHandler(
392392

393393
if (userAssignedIdentityId == UserAssignedIdentityId.ResourceId)
394394
{
395-
httpMessageHandler.ExpectedQueryParams.Add(Constants.ManagedIdentityResourceId, userAssignedId);
395+
httpMessageHandler.ExpectedQueryParams.Add(
396+
managedIdentitySourceType == ManagedIdentitySource.Imds ?
397+
Constants.ManagedIdentityResourceIdImds : Constants.ManagedIdentityResourceId,
398+
userAssignedId);
396399
}
397400

398401
if (userAssignedIdentityId == UserAssignedIdentityId.ObjectId)

0 commit comments

Comments
 (0)