syncweek-react-aad / react-aad

A React wrapper for Azure AD using the Microsoft Authentication Library (MSAL). The easiest way to integrate AzureAD with your React for authentication.
MIT License
344 stars 94 forks source link

Cannot use MSAL's state/userState with react-aad-msal #249

Open dantman opened 4 years ago

dantman commented 4 years ago

Is your feature request related to a problem? Please describe. MSAL supports a state parameter for the redirect login flows. For MSAL.js you provide a state parameter in the AuthenticationParameters, MSAL.js wraps this in its own state putting it in a userState key in a base64 encoded object, and then in the AuthResponse the value of the state parameter you provided is available as accountState on the response.

react-aad-msal provides its own redirect callback handler authenticationRedirectCallback. However this implementation ignores the AuthResponse argument to that callback entirely and as a result the response data (and thus the accountState) is completely inaccessible to the application using react-aad-msal.

Describe the solution you'd like

Describe alternatives you've considered

I considered adding my own login handler. However react-add-msal uses the internal handler to update the auth state and can't simply be replaced or wrapped.