Native Blazor SignInManager #26878
Unanswered
mysteryx93
asked this question in
Q&A
Replies: 1 comment
-
oooh I'm a genius :)
Breakpoint triggers in HandleSignInAsync. Now we're in business. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm looking at whether it would be possible to use Authentication Framework login from Blazor without resorting to Razor pages.
The idea is to write the cookie manually via JS interop.
Upon investigation, SignInManager leads to HttpContext.SignInAsync extension method, then IAuthenticationService, then IAuthenticationHandler, then CookieAuthenticationHandler, then... CookieAuthenticationEvents
Unfortunately, calling SignInAsync throws "System.InvalidOperationException: 'The response headers cannot be modified because the response has already started.'" so CookieAuthenticationEvents won't be reached.
Furthermore, IJSRuntime.InvokeAsync needs to call a function, and I need to set a property like
If I want to write a generic NuGet class library that has no awareness of the UI, how could I inject the needed JS function?
I think it "should" be doable, just need to hook into the right place, either CookieAuthenticationHandler or CookieAuthenticationEvents, and knowing how to register them correctly. After setting the cookie, reloading the page so that the cookie is working normally.
AuthenticationHandler is set with
AuthenticationEvents is set with
Both are set completely differently than Identity Framework options, so I'm not sure how they'll play together.
Any help would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions