Commit d8a8069
committed
msauth: surface the authentication flow on the result
Two consumer needs the current result shape can't answer:
- "Did MSAL prompt the user to acquire this token?" Useful for
diagnostics, telemetry, and consumer policy: silent paths can
be retried more aggressively, interactive paths cost the user
real time.
- "Which technique did MSAL use?" Same audiences plus the
ability to distinguish broker-cached from MSAL-cached tokens
(different revocation and tenant-switch behaviour), or to
detect device-code use (often a fallback rather than the
user's first preference).
Add a public `MicrosoftAuthenticationFlow` enum and a `Flow`
property on `IMicrosoftAuthenticationResult` so consumers can read
both signals. No consumer reads `Flow` today — surfacing it now is
preparation for picker policy, future telemetry, and trace
diagnostics that already had no good way to learn this without
re-deriving it from log scraping.
The enum collapses non-interactive paths into named buckets
(`ServicePrincipal`, `ManagedIdentity`, `WorkloadFederation`,
`Silent`, `BrokerSilent`) rather than a single `NonInteractive`
value: the distinction is cheap to populate and the names carry
useful diagnostic information for free. `Silent` vs `BrokerSilent`
is determined at the silent return site by inspecting MSAL's own
`AuthenticationResultMetadata.TokenSource` — tokens returned by
the broker carry `TokenSource.Broker`, everything else (MSAL's
own cache, or a refresh against the identity provider) does not.
The interactive bucket splits the same way the existing private
`InteractiveFlowType` enum already does: `BrokerInteractive`,
`EmbeddedWebView`, `SystemWebView`, `DeviceCode`. `BrokerInteractive`
(rather than just `Broker`) is named symmetrically with
`BrokerSilent` so a reader looking at one finds the other.
"Interactive" is exposed as an `IsInteractive()` extension method
on the enum, not as a property on the result. This keeps the
result interface minimal and works for callers that have a flow
value from elsewhere (e.g. an enum field on a stored request).
The OS-account-default flow does silent token acquisition
followed by a GCM-side "continue with current account?"
confirmation prompt — the token itself was acquired silently, so
the flow is `Silent` or `BrokerSilent`; the confirmation prompt
is GCM chrome that isn't reflected here.
Workload federation reports itself as `WorkloadFederation` even
though `GetTokenUsingWorkloadFederationAsync` internally calls
`GetTokenForManagedIdentityAsync`: the intermediate MI result is
private to the WIF path, and the surfaced result describes the
outer top-level call.
`MsalResult`'s constructor grows an optional
`MicrosoftAuthenticationFlow` parameter that defaults to `Unknown`.
Every in-tree call site supplies a real value, so the default is
purely an escape hatch for callers that don't classify (test
fakes that build a result without going through
`MicrosoftAuthentication`, or future call sites that want to
construct a result before the flow is decided).
The test fake `AzureReposHostProviderTests.MockMsAuthResult`
grows the property to satisfy the interface; nothing reads it.
Assisted-by: Claude Opus 4.7
Signed-off-by: Matthew John Cheetham <mjcheetham@outlook.com>1 parent 3782cd1 commit d8a8069
2 files changed
Lines changed: 85 additions & 5 deletions
File tree
Lines changed: 84 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
105 | 163 | | |
106 | 164 | | |
107 | 165 | | |
| |||
297 | 355 | | |
298 | 356 | | |
299 | 357 | | |
| 358 | + | |
300 | 359 | | |
301 | 360 | | |
302 | 361 | | |
| |||
316 | 375 | | |
317 | 376 | | |
318 | 377 | | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
319 | 386 | | |
320 | 387 | | |
321 | 388 | | |
| |||
359 | 426 | | |
360 | 427 | | |
361 | 428 | | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
362 | 435 | | |
363 | 436 | | |
364 | 437 | | |
| |||
369 | 442 | | |
370 | 443 | | |
371 | 444 | | |
| 445 | + | |
372 | 446 | | |
373 | 447 | | |
374 | 448 | | |
| |||
395 | 469 | | |
396 | 470 | | |
397 | 471 | | |
| 472 | + | |
398 | 473 | | |
399 | 474 | | |
400 | 475 | | |
| |||
404 | 479 | | |
405 | 480 | | |
406 | 481 | | |
| 482 | + | |
407 | 483 | | |
408 | 484 | | |
409 | 485 | | |
| |||
412 | 488 | | |
413 | 489 | | |
414 | 490 | | |
| 491 | + | |
415 | 492 | | |
416 | 493 | | |
417 | 494 | | |
| |||
420 | 497 | | |
421 | 498 | | |
422 | 499 | | |
423 | | - | |
| 500 | + | |
424 | 501 | | |
425 | 502 | | |
426 | 503 | | |
| |||
438 | 515 | | |
439 | 516 | | |
440 | 517 | | |
441 | | - | |
| 518 | + | |
442 | 519 | | |
443 | 520 | | |
444 | 521 | | |
| |||
462 | 539 | | |
463 | 540 | | |
464 | 541 | | |
465 | | - | |
| 542 | + | |
466 | 543 | | |
467 | 544 | | |
468 | 545 | | |
| |||
482 | 559 | | |
483 | 560 | | |
484 | 561 | | |
485 | | - | |
| 562 | + | |
486 | 563 | | |
487 | 564 | | |
488 | 565 | | |
| |||
1173 | 1250 | | |
1174 | 1251 | | |
1175 | 1252 | | |
1176 | | - | |
| 1253 | + | |
1177 | 1254 | | |
1178 | 1255 | | |
1179 | 1256 | | |
| 1257 | + | |
1180 | 1258 | | |
1181 | 1259 | | |
1182 | 1260 | | |
1183 | 1261 | | |
| 1262 | + | |
1184 | 1263 | | |
1185 | 1264 | | |
1186 | 1265 | | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1088 | 1088 | | |
1089 | 1089 | | |
1090 | 1090 | | |
| 1091 | + | |
1091 | 1092 | | |
1092 | 1093 | | |
1093 | 1094 | | |
0 commit comments