-
Notifications
You must be signed in to change notification settings - Fork 223
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
[Feature Request] HYBRID SPA Integration with IdWeb #1528
Comments
Thanks @gladjohn |
Sure @jmprieur tracking item for sample AzureAD/microsoft-authentication-library-for-dotnet#3006 |
Proposed design:
In the controller the applications could retrieve the auth code from the |
Hi, I was wondering if this issue is still on your roadmap? |
@Grovespaz. It's still on the roadmap. |
@jmprieur we could use it very much starting today already. Our use case is a privileged SPA whose source can not be accessible to the public, only to authenticated users. But once loaded, the SPA does all the heavy lifting itself and thus uses MSAL.js. So it would be ideal for us if we could have the backend use IdWeb to authenticate and authorize and then pass the authorization to MSAL.js to prevent a second redirect to AAD whenever possible. Thanks for your time. |
@Grovespaz You need to add the following in your Startup.cs: services.AddSession(options =>
{
options.Cookie.IsEssential = true; // if this is not included, the session is not maintained
}); In ...
app.UseSession();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
... In the Controller, get the spa auth code:
|
@jennyf19 Thanks for getting back to me so soon with this! One thing I did notice was that when I stopped the project (to make a change) and restarted it again, I would remain logged in to the backend but the session would no longer contain the spa code, leading to (what feels like a) spurious login redirect through MSAL.js in the frontend. Additionally if I did have a code, when I refreshed the page it would try to use the same code from the session to acquire a token in MSAL.js but the request would fail with I'll continue working with this to make sure it covers everything we need, but I thought I'd give you my preliminary feedback already as you were so quick and helpful in responding to me too. |
@Grovespaz the spa code should be removed from the session anyway once you have redeemed it. It's only usable once. |
Adding @jasonnutter who might have thoughts. You are welcome to open this issue on MSAL.js library so we can track there: |
@Grovespaz It is the responsibility of the backend (MSAL.net / MS Identity Web) to acquire the spa authorization code and provide it to the frontend (MSAL.js), and then MSAL.js will redeem that for its own set of tokens (including an RT which can be used to get more tokens). Once the spa has loaded, it doesn't need another spa authorization code from the backend, as it can get its own authorization code (i.e. once the RT has expired). MSAL.js will not cache/store the spa authorization code once it has been used. And if the user has already logged in (i.e. have already redeemed the spa auth code), they do not need to go through the hybrid spa flow a second time. |
Perfect, thank you all. That just leaves me to (dare) ask when you expect this to land in an official release. 😊 If anything meaningful can be said about that already, of course. |
@Grovespaz I can aim to get it out Monday (2/14) |
Just catching up on the thread :/ |
@Grovespaz 1.23.0 with Hybrid Spa support is available on Nuget. https://www.nuget.org/packages/Microsoft.Identity.Web/1.23.0 |
Why would the backend for front end pattern not suffice for this use-case? IE: The confident client authenticates the user, YARP could then be configured to proxy the requests, after appending the bearer token to the request. |
Feature is described here: https://identitydivision.visualstudio.com/DevEx/_git/AuthLibrariesApiReview/pullrequest/3922?_a=files&iteration=17&base=16
Feature has already been implemented in MSAL.Net. Work to be done for ID WEB
This is a tracking item for adding feature to ID WEB
MSAL ,Net PR : AzureAD/microsoft-authentication-library-for-dotnet#2981
The text was updated successfully, but these errors were encountered: