-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Scaffolding into Blazor Server apps #17940
Conversation
Updates Updates Updates Update aspnetcore/includes/scaffold-identity/id-scaffold-dlg-auth.md Co-Authored-By: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Remove dup Identity code in Startup Use the relative path for Login redirect Login redirect requires the force flag Surface a Identity pages styling approach
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@mkArtakMSFT @danroth27 It's been a month on this one, and we don't have any guidance at the moment. Do we need to hold off on this further? Check my opening remarks ☝️ for the contentious points. |
Hi @guardrex I've managed to do a Blazor Server app with 100% Blazor pages for A&A, and no calls to Razor pages, or kludges on the use of XSRF, or writing APIs. And it is gorgeous! I found notes from @SteveSandersonMS about The downside is that refresh/change the underlying websocket, and authentication is lost (it is a new circuit, so of course it disappears). I haven't gone any further on this issue, but I haven't needed to either for the scope of my dev work. When I start moving to Production, I'll switch out to AD B2C anyway, so I'm not losing anything over this issue. (FYI, not using AD B2C up front because of the UI/UX downgrade from Blazor. Secondly, my SUSI flow is different from B2C default. Together those equal massive customization, which is not my priority.) Frankly with the release of WASM, I'm not sure 100% Blazor Server app is even relevant any more? Maybe Education as a use case, but any serious application will probably be Server and WASM, and we already know API and Token based A&A works with BS and WASM combination. So what problem are we solving? I've been crunched with deadlines (haven't we all been this month.) so I haven't built a repo of my solution yet. If this is important, I'm happy to do so and share. And now that A&A are working, I've caught up on my work, just a bit. Just let me know how I can be of assistance. |
Thanks for that @bdnts and congrats 🎉 on working it out.
That would be helpful if I find out from engineering that that's what they want done. In that case, I can take this PR in that direction. We should co-author the updates based on your work if that's what they want. At this point, the PR follows the direction of the templates. The components interact with the Identity via normal Identity endpoints. It's a low-hanging fruit approach that doesn't require much code or thought. Anywho ... we'll see what they say and then take it from there.
You might want to get out of there! ... There's a 💀 Microsoft Hit Squad 💀 in-route to your location. ETA 10 minutes! 😄 lol ....... ⚰️ Here lies @bdnts - Gone but not forgotten - RIP ⚰️ 😁 lol Seriously tho ...
The same reasons for Blazor Server persist. They're listed in the Hosting Models topic at ... https://docs.microsoft.com/en-us/aspnet/core/blazor/hosting-models?view=aspnetcore-3.1#blazor-server |
😆 Hah, What are they going to do? Hurl insults and then apologize because they hurt my feelings? 🤣 I'm tougher than that. 💪 Actually, I see that when creating a WASM with Identity, there is no Work/School Account or Windows Authentication option (greyed out). So I guess there is a use case for BS using Work/Windows AD internally at a business. Good to know. I withdraw my question. ("Knock. Knock" "Who's there?" "WHACK!" Wife took em out. 😄 ) I'll go ahead an knock out a repo, as my day keeps getting interrupted, and my next task needs about 10 hours of non-interruptions (I did 36 hours non-stop coding yesterday to release 2 major features. 😪 🛌 😴 ). This will take about 4 hours, and it is Friday. (I work for myself 🤳) Time to goof off. 🤪 Let me know what Engineering says and will go from there. |
Hello @guardrex. Well, I believe I have a solution to Blazor Server Identity that matches the UI/UX experience of MVC/Razor when creating a new application. Both in terms of time and functionality. The short answer is MVC/Razor pages are approved/guidance for Blazor Identity, but the issues with this approach are well discussed (UI/UX). I experimented with the solution of storing the AF token in _Host.cshtml file, but as some people remarked, it was "kludgy." So I took a new approach:
This is clean, simple, and robust. And it is not kludgy 😆 I've published it to Azure as BlazorServerIdentityInterop.Azurewebsites.net for review, and the source is at https://github.com/bdnts/BlazorServerIdentityInterop. How I figured this all out, and why I'm confident in it, is I put a protocol analyzer on the wire (Fiddler), and watched the traffic of how Login Razor page worked, and then replicated in Blazor SignIn page. Because I'm working with unscaffolded Identity, I can't change anything in the Login.cshtml.cs, because I don't have the source version. This insured the solution would be compliant, especially in XSRF. In the Readme.md, I have laid out the various use cases, technical and non-technical constraints, and the various implementations available, upsides and downsides. With the constraints the way they are (and I do cite documentation to make the boundaries clear), I think this is a great, low-end solution. Cheers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine to me. If I miss something, we'll learn about it soon.
Thanks @mkArtakMSFT ... Yes ... the community will sharpen their BEAKS and CLAWS 🦅 for me if they see something off. I plan to revisit this on UE passes shortly, too. I'll walk the steps again at that time and see if it still holds up or what it further needs. Thanks again @bdnts for discussion and help on this. |
Fixes #15651
Fixes #13316
Internal Review Topic
For a
RedirectToLogin
component, note that ...force
flag set totrue
to make it redirect to the Login Identity page. Otherwise, it won't redirect to the page.You have to POST to the Identity logout endpoint (
Identity/Account/Logout
) from the component (or to a dev-created endpoint per Javier instructions here). To POST from an HTML form, the app requires an XSRF token. This PR covers the scenario using Javier's Pass a token to a Blazor Server app approach. Check for a 💩 Rex Code Smell!™️ 💩 there, but it seems to work well.Styling in Pages/Shared/Layout.cshtml for Identity pages to use the Blazor theme works ok, except that secure components should be removed from the
NavMenu
component for the page layout. I have the reader create a newNavMenu_IdentityPage
component for their pages layout page. If you try to use a secured component in theNavMenu
, the Navigation Manager redirect inRedirectToLogin
hits a 💥. The guidance here is very preliminary (and I placed a NOTE in the guidance that says so), but it probably starts readers off in the right direction.