-
Notifications
You must be signed in to change notification settings - Fork 253
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
adding option to specify client_id for MSI #748
Conversation
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 makes sense. I see that there are several optional query params:
https://docs.microsoft.com/en-us/azure/app-service/overview-managed-identity?tabs=portal%2Cdotnet#rest-endpoint-reference
Could you please model the optional query params with Option<String>
?
Thanks, I have added the other query parameters and switched to |
sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs
Outdated
Show resolved
Hide resolved
sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs
Outdated
Show resolved
Hide resolved
The API spec for IMDS and the managed identity reference has the optional params This aligns with the managed identity documentation here: https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token?msclkid=1dd0c2a2cfa211ecac474657926cfda6 |
sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs
Outdated
Show resolved
Hide resolved
Yes, I think the link form AppService/AzureFunctions I posted on the description has |
I dug into this more, as the Note, I opened a work item to address the document typo here, with references to multiple SDKs and the REST API spec: https://github.com/MicrosoftDocs/azure-docs/issues/92662 |
sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs
Outdated
Show resolved
Hide resolved
sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs
Outdated
Show resolved
Hide resolved
sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs
Outdated
Show resolved
Hide resolved
sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs
Outdated
Show resolved
Hide resolved
sdk/identity/src/token_credentials/imds_managed_identity_credentials.rs
Outdated
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.
Assuming the changes regarding msi_res_id are checked in, I'm fine with this PR.
Thank you for the investigation, I've been convinced and replaced |
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 is looking much better.
My team recently ran into an error when using an MSI to get a token from an AKS cluster. The agent pool for this particular cluster had two MSIs, the one we created and another one that came from AzSecPack. Other clusters with our same application were fine, but only had the single MSI we were expecting to be there.
We spun up an ubuntu container and ran some curl commands
curl 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource={ourResource}' -H Metadata:true
resulted in
{ "error":"invalid_request", "error_description":"Multiple user assigned identities exist, please specify the clientId / resourceId of the identity in the token request" }
and
curl 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource={ourResource}&client_id={ourClientId}' -H Metadata:true
resulted in a good response.
Looking at https://docs.microsoft.com/en-us/azure/app-service/overview-managed-identity?tabs=portal%2Cdotnet#rest-protocol-examples I saw that one can specify the
client_id
as a query parameter on the URL to fetch the token, so that is what I am trying to do in this pull request.