Commit 9228345
authored
feat: support MFA step-up authentication via popup in iframe-based silent auth flow (#1540)
### Summary
Extend `interactiveErrorHandler: 'popup'` to handle MFA step-up errors
from the iframe path. Previously, step-up only worked with refresh
tokens. The iframe path returned `login_required` (not `mfa_required`),
which caused a premature `logout()` and was not detected as an
interactive error. Now both token acquisition paths trigger the popup
automatically.
Extends step-up functionality added in
#1531
### Changes
- Detect iframe MFA step-up errors by matching `error='login_required'`
+ `error_description='Multifactor authentication required'`
- Widen interactive error detection to match both `MfaRequiredError`
(refresh tokens) and the iframe `GenericError` variant
- Skip `logout()` when the `login_required` error is an MFA step-up and
the handler is configured, preserving the session for the popup
- Add two tests: popup opens on iframe MFA error, and `logout()` is not
called
- Remove internal jargon ("iframe flow", "refresh token flow") from
user-facing step-up docs
### Example
```js
// Works with or without useRefreshTokens — no change needed
const auth0 = await createAuth0Client({
domain: '<AUTH0_DOMAIN>',
clientId: '<AUTH0_CLIENT_ID>',
interactiveErrorHandler: 'popup'
});
// If MFA is required, popup opens automatically
const token = await auth0.getTokenSilently({
authorizationParams: {
audience: 'https://api.example.com',
scope: 'read:sensitive-data'
}
});
```
### Testing
- Added two new tests to cover the recent changes
- All tests are passing
- `npm run build` completes successfully
- Performed manual testing using `static/step-up.html`: reproduced the
iframe-based silent token flow with MFA step-up and confirmed that the
popup appears and successfully returns a token1 parent ddbadd8 commit 9228345
File tree
4 files changed
+153
-15
lines changed- __tests__/Auth0Client
- src
4 files changed
+153
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1208 | 1208 | | |
1209 | 1209 | | |
1210 | 1210 | | |
1211 | | - | |
1212 | | - | |
1213 | | - | |
1214 | | - | |
| 1211 | + | |
1215 | 1212 | | |
1216 | 1213 | | |
1217 | 1214 | | |
1218 | | - | |
| 1215 | + | |
1219 | 1216 | | |
1220 | 1217 | | |
1221 | 1218 | | |
1222 | 1219 | | |
1223 | 1220 | | |
1224 | | - | |
1225 | | - | |
1226 | 1221 | | |
| 1222 | + | |
| 1223 | + | |
1227 | 1224 | | |
1228 | 1225 | | |
1229 | 1226 | | |
| |||
1279 | 1276 | | |
1280 | 1277 | | |
1281 | 1278 | | |
1282 | | - | |
| 1279 | + | |
1283 | 1280 | | |
1284 | 1281 | | |
1285 | 1282 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
325 | 326 | | |
326 | 327 | | |
327 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
328 | 432 | | |
329 | 433 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
926 | 927 | | |
927 | 928 | | |
928 | 929 | | |
929 | | - | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
930 | 935 | | |
931 | | - | |
932 | | - | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
933 | 953 | | |
934 | 954 | | |
935 | 955 | | |
| |||
1207 | 1227 | | |
1208 | 1228 | | |
1209 | 1229 | | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
1213 | 1243 | | |
1214 | 1244 | | |
1215 | 1245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
49 | 56 | | |
50 | 57 | | |
51 | 58 | | |
| |||
0 commit comments