Commit 64b3278
Add MSAL client metadata headers to IMDS managed identity requests (#8529)
IMDS managed identity token requests only sent `Metadata: true`,
preventing IMDS from forwarding client telemetry to ESTS. Aligns with
the fix already shipped in MSAL.NET ([PR
#5912](AzureAD/microsoft-authentication-library-for-dotnet#5912)).
### Changes
- **`Constants.ts`** — Added `CLIENT_SKU`, `CLIENT_VER`, and
`CLIENT_REQUEST_ID` entries to `ManagedIdentityHeaders` so header
strings are defined as named constants
- **`Imds.ts`** — Added `x-client-SKU`, `x-client-VER`, and
`x-ms-client-request-id` headers to `createRequest()` using
`ManagedIdentityHeaders` constants, `Constants.MSAL_SKU`,
`packageMetadata.version`, and `cryptoProvider.createNewGuid()`
- **`BaseManagedIdentitySource.ts`** — Changed `cryptoProvider`
visibility from `private` to `protected` so `Imds` can generate
correlation GUIDs
- **`Imds.spec.ts`** — Added header assertions to three existing tests
(UAMI Client Id, UAMI Resource Id, SAMI) using `ManagedIdentityHeaders`
and `NodeConstants.MSAL_SKU` constants with UUID regex validation
- **`managed-identity.md`** — Updated Troubleshooting section to reflect
that IMDS requests now include `x-ms-client-request-id` for end-to-end
tracing
```ts
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
request.headers[ManagedIdentityHeaders.CLIENT_SKU] = NodeConstants.MSAL_SKU;
request.headers[ManagedIdentityHeaders.CLIENT_VER] = packageVersion;
request.headers[ManagedIdentityHeaders.CLIENT_REQUEST_ID] = this.cryptoProvider.createNewGuid();
```
> **Note:** Uses `x-ms-client-request-id` — not `client-request-id`.
IMDS requires the `x-ms-` prefix.
> **Note:** Uses `Constants.MSAL_SKU` (`"msal.js.node"`) for
`x-client-SKU` to align with existing msal-node AAD telemetry, and
canonical `x-client-VER` casing matching
`AADServerParamKeys.X_CLIENT_VER`.
No changes to CloudShell, App Service, Azure Arc, Service Fabric, or any
other managed identity source.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: gladjohn <90415114+gladjohn@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 45bb72c commit 64b3278
7 files changed
Lines changed: 76 additions & 42 deletions
File tree
- change
- lib/msal-node
- docs
- src
- client/ManagedIdentitySources
- utils
- test/client/ManagedIdentitySources
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
93 | 102 | | |
94 | 103 | | |
95 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
167 | 169 | | |
168 | 170 | | |
169 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
170 | 177 | | |
171 | 178 | | |
172 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| |||
Lines changed: 45 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
65 | 72 | | |
66 | 73 | | |
67 | 74 | | |
| |||
115 | 122 | | |
116 | 123 | | |
117 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
118 | 136 | | |
119 | 137 | | |
120 | 138 | | |
| |||
169 | 187 | | |
170 | 188 | | |
171 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
172 | 201 | | |
173 | 202 | | |
174 | 203 | | |
| |||
185 | 214 | | |
186 | 215 | | |
187 | 216 | | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
188 | 222 | | |
189 | 223 | | |
190 | 224 | | |
| |||
194 | 228 | | |
195 | 229 | | |
196 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
197 | 242 | | |
198 | 243 | | |
199 | 244 | | |
| |||
0 commit comments