Skip to content

Conversation

captainsafia
Copy link
Member

@captainsafia captainsafia commented Dec 8, 2020

Description

This PR fixes bugs that prevented users from being redirected back to the page they were on after logging in and from successfully signing in again after their refresh tokens expire.

Technical Description

If retrieving the users tokens fails (for example, due to an expired refresh token), then trigger sign-in again:

try {
const response = await this._msalApplication.acquireTokenSilent(silentRequest);
return response.idTokenClaims;
} catch (e) {
await this.signInCore(silentRequest);
}
}

Pass the state containing the redirect URL when completing sign-in. Return this state from the redirectCallback:

var state = await this._redirectCallback;
if (state) {
return this.success(state.state);
}

Process state in redirectCallback after sign-in or sign-out:

if (result?.state) {
return this.success(this.retrieveState(result.state));
}
return this.operationCompleted();
}

Customer Impact

This PR addresses user-reported issues in the JavaScript client for MS Identity-based authentication in Blazor WebAssembly.

These bugs prevent users from completely integrating authentication into their Blazor WASM apps.

There are no viable workarounds or acceptable alternatives to these bugs.

Regression?

Yes, the changes are a regression from 3.1.

Risk

Low, because this covers a well-defined area (MSAL-based authentication in Blazor WebAssembly) and the following test scenarios were manually validated. The changes made for handling refresh token expiration are those recommended by MS Identity.

Validation
  • Navigate to authorized view, login, logout (Azure AD, Redirect Mode)
  • Navigate to authorized view, login, logout (Azure AD, Pop-up Mode)
  • Navigate to authorized view, login, logout (Azure B2C, Pop-up Mode)
  • Navigate to authorized view, login, logout (Azure B2C, Redirect Mode)
  • Pending: Navigate to page with expired token (Azure AD, Redirect Mode)

Addresses #28151, #28330

@captainsafia captainsafia requested review from SteveSandersonMS and a team as code owners December 8, 2020 04:01
@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Dec 8, 2020
@captainsafia captainsafia added the Servicing-consider Shiproom approval is required for the issue label Dec 9, 2020
@ghost
Copy link

ghost commented Dec 9, 2020

Hello human! Please make sure you've included the Shiproom Template in a comment or (preferably) the PR description. Also, make sure this PR is not marked as a draft and is ready-to-merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants