1

How do I set the HttpContext.User from a razor login page in my server side Blazor app?

The user credentials are fetched from Active Directory when the user signs in. The reason for the login page is that I want to allow people to sign in from outside of the domain (if the ar at a client or similar).

Or don I use something else than HttpContext.User in Blazor?

Fred
  • 1,129
  • 1
  • 14
  • 35
  • As far as I can tell, authentication in Blazor isn't fully supported at the moment. There are ways of making it work, but they aren't fully 100% supported. During episode 27 of The .NET Core Podcast (disclosure: I'm the host), Chris Sainty said (referring to .NET Core 3.0, "There's going to be an authentications coming in that one which I think is something that's been anticipated by the community for quite a long time. We've kind of been able to do authentication but it's been not been anything over the official. But with version six we're getting at that, which is awesome" – Jamie Taylor Jun 24 '19 at 14:17
  • @Jamie Taylor, I think that authentication in Blazor server-side is fully supported, though updates are inevitable. – enet Jun 24 '19 at 14:22
  • @Issac Ok. I was going off of what Chris had said, but couldn't remember whether he was referring to client-side or server-side Blazor. – Jamie Taylor Jun 24 '19 at 14:24
  • @Jamie Taylor, Authentication I dare say is fully supported in client-side Blazor too. Perhaps not complete, but still supported. See the following how to implement authentication on Blazor client-side: https://github.com/dotnet-presentations/blazor-workshop/blob/1c35728a9cafb1add72e14fae88dd037216913d7/docs/06-authentication-and-authorization.md – enet Jun 24 '19 at 14:32
  • @Fred, please focus on a single question. Where do you want to set your HttpContext.User ? Are you using the Blazor built-in authentication objects ? – enet Jun 24 '19 at 14:37
  • @jamie Thank you! I am a subscriber. I will look in to the link provided. – Fred Jun 25 '19 at 08:24
  • @issac Thank you! Maybe I asked the question in the wrong way. What I am trying to find out is how do I manually authenticate the user in server side Blazor? I tried with HttpContext.SignInAsync but it responds with "Response already started". – Fred Jun 25 '19 at 08:30
  • Would something like this implementation help you? https://stackoverflow.com/questions/57172840/how-do-you-create-a-api-identityserver-blazorserver-side-application – Rabbitslayer Jul 30 '19 at 15:40

0 Answers0