Skip to content

Commit 67269a5

Browse files
gladjohnCopilot
andcommitted
Fix Azure Arc resource-id UAMI to forward msi_res_id (not mi_res_id)
Live testing against the Azure Connected Machine agent (1.67, user-assigned preview) showed the Arc token endpoint only honors the IMDS 'msi_res_id' spelling for the resource-id selector; 'mi_res_id' is silently ignored and returns the system-assigned identity, so a resource-id UAMI never resolved. Forward 'msi_res_id' on the Arc request (matching the VM/IMDS source). Update the unit test accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5ad57850-7d1f-4b9a-bf9f-723d69a9687c
1 parent e49fb76 commit 67269a5

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

msal/managed_identity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ def _obtain_token_on_arc(http_client, endpoint, resource, managed_identity=None)
645645
if managed_identity:
646646
_adjust_param(params, managed_identity, types_mapping={
647647
ManagedIdentity.CLIENT_ID: "client_id",
648-
ManagedIdentity.RESOURCE_ID: "mi_res_id",
648+
ManagedIdentity.RESOURCE_ID: "msi_res_id", # Azure Arc honors the IMDS msi_res_id spelling; mi_res_id is ignored and returns the system-assigned identity
649649
ManagedIdentity.OBJECT_ID: "object_id",
650650
})
651651
resp = http_client.get(

tests/test_mi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ def test_arc_user_assigned_client_id_should_be_forwarded(self, mocked_stat):
507507
"client-id",
508508
)
509509

510-
def test_arc_user_assigned_resource_id_should_be_forwarded_as_mi_res_id(self, mocked_stat):
510+
def test_arc_user_assigned_resource_id_should_be_forwarded_as_msi_res_id(self, mocked_stat):
511511
self._assert_user_assigned_selector(
512512
UserAssignedManagedIdentity(resource_id="resource-id"),
513-
"mi_res_id",
513+
"msi_res_id",
514514
"resource-id",
515515
)
516516

0 commit comments

Comments
 (0)