-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Implement redirect bridge to support COOP #8118
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
Changes from 25 commits
0e9e1c4
8da953b
9759da1
b785cbb
125588f
7eb65d7
1be20ef
d72ba13
2b46d6a
da8168d
f186235
afae280
e7e5c54
40b8e3e
2a28584
afe6890
240757c
c3a5ed9
a4c9ce5
8a167fc
49b3506
2895e20
076df1d
5cb8ca8
bb9480a
6636748
48e01bf
b42be72
15086a0
2780349
4c1a103
def925e
704968f
5ffe984
ba93bd2
f786341
7d7bdd3
0aadd91
4c73bbd
18b1e4f
348c75e
d45e1d4
2644d40
25996a0
48ba45d
b58bd67
9a7bd3d
ece3225
9c32ec0
a5572f0
cfef9f8
be545c8
f5b340c
7c088ed
22be0a0
ce57d1c
53d9d6b
8d09b33
38566ec
2c8fc69
35b7d56
98116eb
3be38b9
3c69a41
5237f78
ace9170
569e764
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "minor", | ||
| "comment": "Implement redirect bridge to support COOP #8118", | ||
| "packageName": "@azure/msal-browser", | ||
| "email": "kshabelko@microsoft.com", | ||
| "dependentChangeType": "patch" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "minor", | ||
| "comment": "Implement redirect bridge to support COOP #8118", | ||
konstantin-msft marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "packageName": "@azure/msal-common", | ||
| "email": "kshabelko@microsoft.com", | ||
| "dependentChangeType": "patch" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -263,7 +263,7 @@ This error occurs when MSAL.js surpasses the allotted storage limit when attempt | |
| - Authority mismatch error. Authority provided in login request or PublicClientApplication config does not match the environment of the provided account. Please use a matching account or make an interactive request to login to this authority. | ||
|
|
||
| ### `invalid_request_method_for_EAR` | ||
| - The EAR protocol cannot be used with HTTP method `GET`. The `httpMethod` parameter in all requests using `protocolMode: ProtocolMode.EAR` must be either unset or `"POST"`/`HttpMethod.POST`. | ||
| - The EAR protocol cannot be used with HTTP method `GET`. The `httpMethod` parameter in all requests using `protocolMode: ProtocolMode.EAR` must be either unset or `"POST"`/`HttpMethod.POST`. | ||
|
|
||
| ## Interaction required errors | ||
|
|
||
|
|
@@ -558,6 +558,40 @@ If you are unable to figure out why this error is being thrown please [open an i | |
| - Refresh the page. Does the error go away? | ||
| - Open your application in a new tab. Does the error go away? | ||
|
|
||
| ### `interaction_in_progress_overridden` | ||
konstantin-msft marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - The current interaction was overridden by a new interaction request with `overrideInteractionInProgress` set to `true`. | ||
|
|
||
| This error is thrown when an existing popup interaction is cancelled because a new popup request was initiated with the `overrideInteractionInProgress` flag set to `true`. This is not necessarily an error condition - it indicates that the previous interaction was intentionally cancelled to allow a new one to proceed. | ||
|
|
||
| **When This Occurs:** | ||
|
|
||
| This error is thrown for the **previous/cancelled** interaction when: | ||
| 1. A popup interaction is in progress (e.g., `acquireTokenPopup`) | ||
| 2. A new popup request is made with `overrideInteractionInProgress: true` | ||
| 3. The library cancels the pending interaction and starts the new one | ||
|
|
||
| **Example:** | ||
|
|
||
| ```javascript | ||
| // First popup request starts | ||
| const request1 = { scopes: ["User.Read"] }; | ||
| const promise1 = msalInstance.acquireTokenPopup(request1); | ||
|
|
||
| // User closes the popup or something goes wrong | ||
| // App decides to retry with override flag | ||
| const request2 = { | ||
| scopes: ["User.Read"], | ||
| overrideInteractionInProgress: true // Override the previous interaction | ||
| }; | ||
| const promise2 = msalInstance.acquireTokenPopup(request2); | ||
|
|
||
| // promise1 will reject with interaction_in_progress_overridden | ||
| // promise2 will proceed normally | ||
| ``` | ||
|
|
||
| **Note:** This error should only be seen when you explicitly use the `overrideInteractionInProgress` flag. Under normal circumstances, concurrent interaction attempts will throw `interaction_in_progress` instead. | ||
|
|
||
| ### `popup_window_error` | ||
|
|
||
| - Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser. | ||
|
|
@@ -570,43 +604,53 @@ If you are unable to figure out why this error is being thrown please [open an i | |
|
|
||
| - User cancelled the flow. | ||
|
|
||
| ### `monitor_popup_timeout` | ||
| ### `redirect_bridge_timeout` | ||
|
|
||
| - Communication with the redirect page (popup or iframe) timed out while waiting for authentication response. | ||
|
|
||
| - Token acquisition in popup failed due to timeout. | ||
| **Error Messages**: | ||
|
|
||
| ### `monitor_window_timeout` | ||
| - Token acquisition in popup failed due to timeout. | ||
| - Token acquisition in iframe failed due to timeout. | ||
|
|
||
| - Token acquisition in iframe failed due to timeout. | ||
| This error can be thrown when calling `ssoSilent`, `acquireTokenSilent`, `acquireTokenPopup` or `loginPopup` when the redirect bridge script fails to send the authentication response back to the main window within the configured timeout period. This typically occurs for the following reasons: | ||
konstantin-msft marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| **Error Messages**: | ||
| 1. The page you use as your `redirectUri` is not loading the `msal-redirect-bridge.js` script | ||
| 1. The redirect page is removing or manipulating the hash before the bridge script can process it | ||
| 1. The redirect page is automatically navigating to a different page before the bridge can communicate the response | ||
| 1. Your identity provider is being slow to redirect back to your `redirectUri` (network latency) | ||
| 1. You are being throttled by your identity provider due to too many requests in a short period | ||
|
|
||
| - Token acquisition in iframe failed due to timeout. | ||
| **Resolution Steps:** | ||
|
|
||
| This error can be thrown when calling `ssoSilent`, `acquireTokenSilent`, `acquireTokenPopup` or `loginPopup` and there are several reasons this could happen. These are a few of the most common: | ||
| ✔️ **Ensure the redirect bridge script is loaded:** | ||
|
|
||
| 1. The page you use as your `redirectUri` is removing or manipulating the hash | ||
| 1. The page you use as your `redirectUri` is automatically navigating to a different page | ||
| 1. You are being throttled by your identity provider. The identity provider may throttle clients that make too many similar requests in a short period of time. Never implement an endless retry mechanism or retry more than once. Attempts to retry non-network errors typically yield the same result. See [throttling guide](#Throttling) for more details. | ||
| 1. Your identity provider did not redirect back to your `redirectUri`. | ||
| Your `redirectUri` page must include the redirect bridge script to enable communication back to the main window: | ||
|
|
||
| ```html | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Redirect</title> | ||
| </head> | ||
| <body> | ||
| <script src="path/to/msal-redirect-bridge.js"></script> | ||
| <script> | ||
| msalRedirectBridge.sendRedirectPayloadToMainFrame(); | ||
| </script> | ||
| </body> | ||
| </html> | ||
| ``` | ||
|
|
||
| **Important**: If your application uses a router library (e.g. React Router, Angular Router), please make sure it does not strip the hash or auto-redirect while MSAL token acquisition is in progress. If possible, it is best if your `redirectUri` page does not invoke the router at all. | ||
|
|
||
| #### Issues caused by the redirectUri page | ||
|
|
||
| When you make a silent call, in some cases, an iframe will be opened and will navigate to your identity provider's authorization page. After the identity provider has authorized the user it will redirect the iframe back to the `redirectUri` with the authorization code or error information in the hash fragment. The MSAL instance running in the frame or window that originally made the request will extract this response hash and process it. If your `redirectUri` is removing or manipulating this hash or navigating to a different page before MSAL has extracted it you will receive this timeout error. | ||
| When you make a silent call, in some cases, an iframe will be opened and will navigate to your identity provider's authorization page. After the identity provider has authorized the user it will redirect the iframe back to the `redirectUri` with the authorization code or error information in the hash fragment. The MSAL redirect bridge running in the iframe will broadcast response to MSAL instance running in the frame or window that originally made the request. If your `redirectUri` is removing or manipulating this hash or navigating to a different page before MSAL redirect bridge has extracted it you will receive this timeout error. | ||
|
||
|
|
||
| ✔️ To solve this problem you should ensure that the page you use as your `redirectUri` is not doing any of these things, at the very least, when loaded in a popup or iframe. We recommend using a blank page as your `redirectUri` for silent and popup flows to ensure none of these things can occur. | ||
| ✔️ To solve this problem you should ensure that the page you use as your `redirectUri` is not doing any of these things, at the very least, when loaded in a popup or iframe. | ||
|
||
|
|
||
| You can do this on a per request basis, for example: | ||
|
|
||
| ```javascript | ||
| msalInstance.acquireTokenSilent({ | ||
| scopes: ["User.Read"], | ||
| redirectUri: "http://localhost:3000/blank.html", | ||
| }); | ||
| ``` | ||
|
|
||
| Remember that you will need to register this new `redirectUri` on your App Registration. | ||
| Remember that you will need to register `redirectUri` on your App Registration. | ||
|
|
||
| **Notes regarding Angular and React:** | ||
|
|
||
|
|
@@ -641,24 +685,27 @@ Some B2C flows are expected to throw this error due to their need for user inter | |
|
|
||
| Another potential reason the identity provider may not redirect back to your application in time may be that there is some extra network latency. | ||
|
|
||
| ✔️ The default timeout is about 10 seconds and should be sufficient in most cases, however, if your identity provider is taking longer than that to redirect you can increase this timeout in the MSAL config with either the `iframeHashTimeout`, `windowHashTimeout` or `loadFrameTimeout` configuration parameters. | ||
| ✔️ The default timeout is about 10 seconds and should be sufficient in most cases, however, if your identity provider is taking longer than that to redirect you can increase this timeout in the MSAL config with either the `iframeBridgeTimeout` or `popupBridgeTimeout` configuration parameters. | ||
konstantin-msft marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```javascript | ||
| const msalConfig = { | ||
| auth: { | ||
| clientId: "your-client-id", | ||
| }, | ||
| system: { | ||
| windowHashTimeout: 9000, // Applies just to popup calls - In milliseconds | ||
| iframeHashTimeout: 9000, // Applies just to silent calls - In milliseconds | ||
| loadFrameTimeout: 9000, // Applies to both silent and popup calls - In milliseconds | ||
| popupBridgeTimeout: 50000, // Applies just to popup calls - In milliseconds | ||
| iframeBridgeTimeout: 9000, // Applies just to silent calls - In milliseconds | ||
tnorling marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
| ``` | ||
|
|
||
| > [!IMPORTANT] | ||
| > Please consult the [Troubleshooting Single-Sign On](https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/FAQ.md#troubleshooting-single-sign-on) section of the MSAL Browser FAQ if you are having trouble with the `ssoSilent` API. | ||
|
|
||
| ### `redirect_bridge_empty_response` | ||
|
|
||
| - The redirect bridge returned an empty, indicating the redirect bridge script may have been modified or replaced. | ||
konstantin-msft marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### `redirect_in_iframe` | ||
|
|
||
| - Redirects are not supported for iframed or brokered applications. Please ensure you are using MSAL.js in a top frame of the window if using the redirect APIs, or use the popup APIs. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.