[Identity] Azure Arc, Fabric and ManagedIdentityCredential refactoring#11976
Conversation
|
@sadasant - this definitely feels complete enough to move to being a full PR and to pull in folks who have worked on Arc on other languages for their feedback. Thanks for taking the time to work on the refactor. The code felt readable and I was able to track where this new functionality was being added and could see where it was related to existing functionality. |
| "sinon": "^9.0.2", | ||
| "@types/sinon": "^9.0.4" | ||
| "@types/sinon": "^9.0.4", | ||
| "fs-mock": "~1.2.1" |
sophiajt
left a comment
There was a problem hiding this comment.
Left some comments, but this looks pretty good
laiapat
left a comment
There was a problem hiding this comment.
Looking really good so far! This is a lot of great work 👍
all wonderful suggestions by McCoy! Co-authored-by: McCoy Patiño <39780829+mccoyp@users.noreply.github.com>
|
This pull request is protected by Check Enforcer. What is Check Enforcer?Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass. Why am I getting this message?You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged. What should I do now?If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows: What if I am onboarding a new service?Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment: |
laiapat
left a comment
There was a problem hiding this comment.
Service Fabric side looks good! 🎉
| return this.cachedMSI; | ||
| } | ||
|
|
||
| const MSIs = [fabricMsi, appServiceMsi2017, cloudShellMsi, arcMsi, imdsMsi]; |
| // If we received any response, the endpoint is available | ||
| logger.info(`IMDS endpoint is available`); | ||
|
|
||
| // IMDS MSI available! |
There was a problem hiding this comment.
Well, the endpoint is available. If it has no assigned identity, it will respond 400 to a token request. Looks like getToken would throw CredentialUnavailable in that case?
There was a problem hiding this comment.
If getToken raises a 400 error, it will bubble up to this point: #11807 (comment)
Where we throw CredentialUnavailable!
How does that sound?
There was a problem hiding this comment.
I'm asking more information about this through Teams. In any case, the changes related to any retry policy will happen through a separate issue and PR.
| if (response.status !== 401) { | ||
| throw new AuthenticationError( | ||
| response.status, | ||
| "To authenticate with Azure Arc MSI, status code 401 is expected on the first request." |
There was a problem hiding this comment.
It might be helpful to users to return some info from the response from the service in the error. I'm wondering if it could have some useful information, for instance something like a malformed request or missing parameter.
There was a problem hiding this comment.
I'll do that! thank you!
catalinaperalta
left a comment
There was a problem hiding this comment.
The Arc MSI support looks good to me!
|
Hello @sadasant! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
This PR does the following:
Simplifies the workflow of ManagedIdentityCredential
This is now how we pick what MSI credential is available:
Shows the order of verification more clearly. Reduces the complexity of the credential.
Implements caching on the managed credential
The managed credential was verifying the availability of the MSIs on each request - except for the IMDS one, which had a very weird flow with a stateful boolean value that was passed through from method to method.
Instead of doing that, the first time we authenticate we define what MSI is available, and subsequent calls won't run any validation.
This aligns with .Net.
Adds Azure Arc support
This PR also showcases the refactoring by how simple it is to add a new MSI to the main ManagedIdentityCredential class.
The notes on how I was able to write and test the Arc MSI are here: https://gist.github.com/sadasant/888dc7e88543a21ee7061997984dd207
The change on the ManagedIdentityCredential consists of adding
arcMsito the array of MSIs used inside of thecachedAvailableMSIfunction.There's an important note on how I'm currently validating this environment here: link.
I'll leave this PR as draft until we find the time to do an internal review, then I'll move it out of draft.
Fixes #11653
Fixes #10235
New:
Fixes #11595
Fixes #10238
Closes #12164
Fixes #12058