-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Added token revocation functionality to Managed Identity #7422
base: dev
Are you sure you want to change the base?
Conversation
@@ -549,13 +550,136 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => { | |||
); | |||
}); | |||
|
|||
test("ignores a cached token when claims are provided", async () => { | |||
test('checks if a token was cached or not and if was "bypass_cache=true" was sent to ESTS depending on whether or not claims are provided, and ensures "xms=client-capabilites-string" was sent to ESTS when client capabilities are provided via the Managed Identity Request Parameters', async () => { |
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.
I think you should also include tests when claims are passed, and client capabilities are not and when client capabilities are passed, and claims are not.
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.
I think some are covered, but the tests are somewhat difficult to read.
There are 3 dimensions for this test, each with 2 possible values. So a total of 2^3 = 8 combos.
CP1: {sent, not_sent}
Claims: {sent, not_sent}
Token_in_cache? { yes, no}
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.
Recommend adding more unit tests for the combination of presence of client capabilities and claims. Also were you able to test all the scenarios manually?
@Robbie-Microsoft MSI v1 token revocation is supported only on MSI endpoints versioned |
lib/msal-node/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts
Outdated
Show resolved
Hide resolved
@@ -55,6 +55,7 @@ import { | |||
} from "../../../src"; |
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.
The tests aren't related to IMDS? Is this the right location for them?
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.
ClientCapabilities is an app level setting. Isn't it the case for ConfidentialClientApplication?
Yes. Fixed in this PR now. |
@@ -133,6 +133,17 @@ export abstract class BaseManagedIdentitySource { | |||
managedIdentityId | |||
); | |||
|
|||
// if claims are present, the MSI will get a new token | |||
if (managedIdentityRequest.claims) { |
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.
suggest using const here,
const BYPASS_CACHE = "bypass_cache";
const XMS_CC = "xms_cc";
@@ -549,13 +550,82 @@ describe("Acquires a token successfully via an IMDS Managed Identity", () => { | |||
); | |||
}); | |||
|
|||
test("ignores a cached token when claims are provided", async () => { | |||
test('checks if a token was cached or not and if was "bypass_cache=true" was sent to the MSI depending on whether or not claims are provided, and ensures "xms=client-capabilites-string" was sent to ESTS when client capabilities are provided via the Managed Identity configuration object', async () => { |
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.
No tests in the PR to validate that the MSI V1 endpoint version is updated to 2024-09-30
@@ -133,6 +133,17 @@ export abstract class BaseManagedIdentitySource { | |||
managedIdentityId | |||
); | |||
|
|||
// if claims are present, the MSI will get a new token | |||
if (managedIdentityRequest.claims) { |
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.
can we add logs to these two conditions? i.e. when claims or capabilities are present?
We should bump the source's version to the one that supports MSI V1 CAE. But there are no Azure Resource that still supports this in GA, so we should bump the version for just this PR, mark it as
No, we should not.
MI Teams needs to guarantee that the version is updated across the board / azure resources, we will then test add e2e and then release/GA. For now, this is just an internal preview. So do not merge this PR. |
If claims are present, the cache will already be bypassed. Now, additionally,
bypass_cache=true
will be included in the token request, which indicates to ESTS that it should get a new token.Client Capabilities can now, optionally, be sent to ESTS as a non-empty string query parameter in the form of
xms_cc=client-capabilities-string-separated-by-commas
.Client Capabilities can be set in the Managed Identity configuration object, which is consistent with non-Managed Identity configurations.