How to implement custom authentication in Blazor Server (WITHOUT Microsoft.AspNetCore.Identity)

preview_player
Показать описание
When it comes to authentication, I generally advise using Microsoft.AspNetCore.Identity as a minimum and IdentityServer4 for more complex scenarios. However, there might be scenarios in which you can't use neither of hem and you'd have to implement custom authentication in Blazor Server apps. In this video we take a look into how to implement custom authentication in Blazor Server using cookies (without any help from Microsoft.AstNetCore.Identity)
#Blazor #AspNetCore #Authentication

Join this channel to get access to perks:

Mentioned videos:

Chapters:
1.Intro: 00:00
2. Why using custom auth might be WRONG: 01:09
3. Creating an Auth Service (use databases instead in real scenarios): 02:37
4. Setting up cookie authentication: 05:16
5. User registration and sign in: 09:05
6. Creating claims: 12:18
7. Creating ClaimsIdentity and ClaimsPrincipal: 13:55
8. Signing a user in: 16:20
9. Implementing login: 17:48
10. Implementing logout: 23:31
11. See it in action: 25:57
Рекомендации по теме
Комментарии
Автор

Thanks! I’m looking forward to your video with a Provider such as Google or Facebook using this same authorization example.

quincintchristian
Автор

This is the best video I found about custom authentication

vittoriomorellini
Автор

Good explanation here, have tried same way but custom authentication state is not persist after redirect to different page using interactive auto render mode.

manojnaik
Автор

Can we use this method inside Razor Component instead of using that cshtml Page ? as I see you have used existing structure of identity pages.

it will be great if you purely use razor components for registration/login and authorization. Good Work

owner
Автор

This would be so much easier to follow if you either started from a new project, so I don't have to go through another video only to have to remove half of it, or if you provided source code so I already have what I need.

theNeptuneViolin
Автор

Thanks for your creativity, it is very useful to fill knowledge gaps!

sergeyt
Автор

Is the source code available for download somewhere ?

thebeast
Автор

Hi! Scenario: You are loged in, you copy auth cookie, you log out the user and paste "saved" cookie again. What will happen?

franciszekkaliszewski
Автор

How to do this in the razor component and without a role, only the user-id and password to be passed in?

hermanreyes
Автор

Hi, ClaimsIdentity data where is stored? after logout i checked cookie in browser but not there. can you please explain?

karthin
Автор

Is it possible to omit the argument for AddAuthentication? Leaving it empty and handling it via Authorization policies?

yakupipek
Автор

How to restrict user to access the Registrater.cshtml Page? Example only Administrators can only add users. Is it possible to write and implement authorization/authentication (login and register page) using Blazor components rather than using cshtml razor pages?

coolwaterdvr
Автор

Hi, i'd like to ask regarding the uses of .cshtml page instead of .razor component.
I assume that you use cshtml page so you can access HttpContext property out-of-the-box, but what if we register an HttpContext accessor service and inject it instead to the razor component to access the HttpContext ? Would there be any difference, catch or it is a valid workaround ?

Thank you

tommyariap
Автор

Hello!

I just set up a Blazor server app with individual accounts.

Considering the fact that I use razor component for login page and register page, I tried to make a repository with an interface that I registered in Program.cs.

In this repository I have set async methods for login and registration, but every time, for example, when I want to login, I get this error "The response headers cannot be modified because the response has already started.".

I mention that I have not implemented CustomAuthorisation.

Any advice for this?

Thank you

DavidAlexandru
Автор

If you have two browser tabs logged in with cookies and you log out of one of them, the other tab is still active.
Please tell me how to fix the error that keeps me logged in.

ybleeLee
Автор

Thank you for this. Can you share code.

korbashi