ManagedIdentityObjectId property of CertificatelessOptions should be renamed ManagedIdentityClientId
See original GitHub issueMicrosoft.Identity.Web Library
Microsoft.Identity.Web.CertificateLess
Microsoft.Identity.Web version
1.25.10
Web app
Sign-in users and call web APIs
Web API
Protected web APIs call downstream web APIs
Token cache serialization
Not Applicable
Description
The ManagedIdentityObjectId property in CertificatelessOptions should actually be named “ManagedIdentityClientId”.
It is passed in the TokenAquisition class to the managedIdentityClientId constructor parameter for ManagedIdentityClientAssertion.
builder.WithClientAssertion(new ManagedIdentityClientAssertion(mergedOptions.ClientCredentialsUsingManagedIdentity.ManagedIdentityObjectId).GetSignedAssertion);
This value is then in turn passed to the ManagedIdentityClientId property of the DefaultAzureCredentialOptions:
var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { ManagedIdentityClientId = _managedIdentityClientId });
This option required the use of the clientId for the managed identity, and not the objectId.
Reproduction steps
- Configure Certless app authentication with Managed Identity using CertificateLessOptions
- Provide the objectId of the managed identity to the AzureAd -> ClientCredentialsUsingManagedIdentity -> ManagedIdentityObjectIdentity config property
- Attempt to request a token
Error message
compute platform returns error indicating that the requested managed identity is not available,
[Error] JWT Token exception: Azure.Identity.AuthenticationFailedException: ManagedIdentityCredential authentication failed: Service request failed. Status: 400 (Bad Request)
Content: {“statusCode”:400,“message”:“Unable to load the proper Managed Identity.”,“correlationId”:“3f54e937-2426-4ac6-8b3b-e11f7ff28c02”}
Id Web logs
No response
Relevant code snippets
{
"AzureAd": {
"Instance": "https://login.windows-ppe.net/",
"ClientId": "[Client_id-of-web-app-eg-2ec40e65-ba09-4853-bcde-bcb60029e596]",
"TenantId": "common",
// To call an API
"ClientCredentialsUsingManagedIdentity": {
"IsEnabled": true,
"ManagedIdentityObjectIdentity": "2387ff05-c838-43cd-b072-63de4be15119"
},
},
"GraphBeta": {
"BaseUrl": "https://graph.microsoft-ppe.com/beta",
"Scopes": "user.read"
}
}
Regression
No response
Expected behavior
Developer would expect the system to request tokens using the provided ObjectID (as is available at the MSI Rest layer here)
As the DefaultAzureCredential dependency here does not support requesting tokens by objectId, but only by ClientId, the developer should be asked to provide the clientId instead.
Renaming this parameter with a breaking change in the next major version of the library would be appropriate.
Documentation updates pointing out the need to pass a clientId to this parameter for the current version would help prevent developer confusion.
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (1 by maintainers)
Top Related StackOverflow Question
Hi Chris This is done and should be available internally (from the Azure DevOps IDDP artifact feed) later today part of the first released version of Microsoft.Identity.Web 2.x
Regards
Jean-Marc
From: Chris Brooks @.> Sent: Sunday, December 4, 2022 13:51 To: AzureAD/microsoft-identity-web @.> Cc: Jean-Marc Prieur @.>; Comment @.> Subject: Re: [AzureAD/microsoft-identity-web] ManagedIdentityObjectId property of CertificatelessOptions should be renamed ManagedIdentityClientId (Issue #1991)
The clientId is used when referring to a specific associated User-Assigned Managed Identity. When referring to the System-Assigned identity on a resource (as shown in the image above), the default constructor (with no clientId) is used.
The clientId of a user-assigned managed identity is found on the summary page for the identity:
[image]https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F9362227%2F205517462-efeb7daa-02d0-4ddb-acf9-46a754b447f2.png&data=05|01|Jean-Marc.Prieur%40microsoft.com|8d875f8641f342fff07408dad641b1d9|72f988bf86f141af91ab2d7cd011db47|1|0|638057874904879009|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|3000|||&sdata=aEFC4c7hiyUmWaVi8uaCiC1L2Va%2FPKrzXzvRMH0iCw0%3D&reserved=0
— Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FAzureAD%2Fmicrosoft-identity-web%2Fissues%2F1991%23issuecomment-1336525889&data=05|01|Jean-Marc.Prieur%40microsoft.com|8d875f8641f342fff07408dad641b1d9|72f988bf86f141af91ab2d7cd011db47|1|0|638057874904879009|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|3000|||&sdata=SCWMpjwnkQornNBDTVT4qd%2FqdrvBNZ3ZSocxjynoXII%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FADEXN5EP6BM7BKQFRXEPNELWLUG55ANCNFSM6AAAAAASSMS2RU&data=05|01|Jean-Marc.Prieur%40microsoft.com|8d875f8641f342fff07408dad641b1d9|72f988bf86f141af91ab2d7cd011db47|1|0|638057874904879009|Unknown|TWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D|3000|||&sdata=1jNNjU14Xf%2Fi36eOavqPyy%2Bpn5MvmhnLVLzmzh4EJP4%3D&reserved=0. You are receiving this because you commented.Message ID: @.***>
Released in 2.5.0