.NET 7 Blazor Web Assembly Authentication using Web API and ASP.NET Core Identity
HTML-код
- Опубликовано: 13 июл 2024
- Table of Contents:
00:00:00 | Introduction to Blazor Authentication.
00:03:44 | Creating Web Assembly App.
00:05:55 | Installing JwtBearer, EFCore, EFcore.SQL Server, EFCore.Tools, Identity.UI, Diagnostic.EFCore NuGet packages.
00:08:35 | Setting up Database connection string in AppSettings.josn file.
00:10:55 | Creating Application Db Context class.
00:12:30 | Registering database connection service in program.cs file.
00:13:41 | Registering Default Identity in program.cs file.
00:14:40 | Add Database-Migration.
00:17:15 | Registering Authentication and JWT (Json Web Token) in program.cs file.
00:19:50 | Add Authentication and Authorization middleware pipeline.
00:20:38 | Creating Account Controller for registration.
00:23:40 | Creating Register & Register Result models.
00:26:30 | Install Swashbuckle NuGet package for API UI.
00:27:12 | Registering Swagger service and configuring the middleware pipeline in program.cs file.
00:27:41 | Testing the Account registration Action method in swagger UI.
00:30:00 | Adding Login Controller.
00:32:41 | Creating Login & Login Result models.
00:35:15 | Testing the Login Action method in swagger UI for JWT.
00:36:54 | Updating App.razor to check Authentication.
00:40:00 | Creating Custom Authentication State Provider.
00:41:38 | Installing Blazored Local Storage & Component Authorization NuGet package.
00:47:39 | Creating Authentication Service.
00:48:00 | Creating registration, login and logout razor components.
00:59:59 | Configuring Dependency injection on Authentication service in program.cs.
01:02:09 | Running the application.
Download source code | github.com/CodeAcademyCA/Auth...
Step-By-Step | • .NET Blazor | Authenti... | Authentication with Client-Side Blazor using Web API and ASP.NET Core Identity.
Related Videos
• .NET Blazor | Blazor W... | Blazor Web Assembly Authentication using Individual Account.
• .NET 7 Blazor Web Asse... | Blazor Web Assembly Authentication using Web API and ASP.NET Core Identity
• .NET 7 SQLite Database... | SQLite Database CRUD Operations in Web API using Entity Framework Core.
• .NET 7 SQL Server CRUD... | SQL Server CRUD Operations in Web API using Entity Framework Core.
• .NET 7 EFCore All Rela... | EFCore Relationships (One-to-One, One-to-Many, Many-to-Many) in Web API with SQL Server.
• .NET 7 AutoMapper Data... | AutoMapper Data Transfer Objects DTOs explained
• .NET 7 Navigation Comp... | Navigation Component in Blazor Web Assembly using NavigationLock
• .NET 7 Object Relation... | Object Relational Mapper ORM Explained for Everyone
• .NET EFCore | Scaffold... | Scaffold SQL Database with DB First migration in Web API using EntityFrameworkCore.
• .NET EFCore | Web API ... | Web API EntityFrameworkCore (EF7) Pagination using Skip() and Take() methods.
• .NET EFCore | Send Ema... | Send Email in Web API using Mailkit SMTP.
• .NET EFCore | AutoMapp... | AutoMapper Data Transfer Objects DTO with Web API Explained.
• Video | Blazor WebAssembly Chat with SignalR using WebSockets.
• .NET EFCore | Create J... | Create JSON Web Token (JWT) for User Registration and Login using Password Hash and Salt.
• .NET EFCore | EFCore A... | EFCore All Relationships (11, 1n, nn ) with Entity Framework Core SQL Server.
• .NET EFCore | Read JWT... | Web API Role - Based Authorization with JSON Web Token (JWT).
Introduction
Authentication and authorization are the most common requirements of most applications. Authentication is a process of validating users and Authorization is a process of validating access right of users for accessing application resources.
Blazor uses the ASP.NET core security model to provide authentication and authorization. Both Blazor server app and client app (WebAssembly) have different security scenarios as Blazor server app uses server resource to provide authorization, and Blazor client app (WebAssembly) runs on the client; hence authorization is only determined which UI option can be accessible by the user.
Authentication
Server-side Blazor uses ASP.NET Core authentication mechanisms. The Server-side Blazor uses SignalR for real-time connection between the server and UI. So, SignalR handles the authentication on established connection. There is an option available to enable authentication for the Blazor app when you create the application.
Blazor Web Assembly authentication
In Blazor WebAssembly, authentication checks can be bypassed because all client-side code can be modified by users. The same is true for all client-side app technologies, including JavaScript SPA frameworks and native apps for any operating system.
The background music was a little too loud for this type of video, but other than than great tutorial, exactly what i needed. Thank you.
thank you so much
thank you
it is perfect
This is absolutely the best and latest tutorial on this. As a beginner, I wasted days trying to figure this out. Thank you, thank you! Can we add a few additional pages such as email confirm, lost password and so on in a later video?
Please check these:
Email Confimation
ruclips.net/video/4L_JMal-R6c/видео.html
Forgot Password
ruclips.net/video/9bwO6_qw1jU/видео.html
This is the full playlist
ruclips.net/p/PL285LgYq_FoKtKfBhPh5puq4Y_d5FDiRA
this is the channel:
www.youtube.com/@Netcode-Hub
😀
I have a question here: for the CreateAccount method in the controller, why didn't you use "public async Task Register([FromBody] IdentityUser user)" why did you have to user "public async Task Register([FromBody] RegisterModel model)"?. since you are already implementing aspnetcore identity?
thanks you
You are welcome 🤗 😃
Isn't there something missing for registering via the Blazor site? It seems like you can log in, but creating an account via the client with Blazor doesn't seem to work... Or am I the only one having this problem?
how do i remove cookie authentication??
Didn't you already post it a few days ago?
Really ? Will cross check . Thanks by the way
No music in the next video please
when i execute the "Update-Database" command I got this error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SNI_PN11, error: 26 - Error Locating Server/Instance Specified).
I've done some research and I've tried everything I found. Anything seems to work, could anyone help me please I'm about to be fired please 😭💀
... SQL Server. The server was not found or was not accessible. This tells me you haven't installed Server. Do install MySql Server. Get one from here... www.microsoft.com/en-us/sql-server/sql-server-downloads
Getting an error when trying to register through the client. The console says: Failed to load resource: the server responded with a status of 405 ().
Any idea how to fix this?
The HTTP 405 status code indicates that the server has received your request, but the resource you are requesting doesn't support the request method. This may occur if you're using an incorrect method or the server is configured to disallow the said method.
@@Code-Academy Thank you
is it possible to have multi-role for a user?
add list of claims on role and assign the number of roles you want
@@Code-AcademyThanks, but when I tried thsi to [Authorized Roles = "Admin, User", Policy = "CanAddEmployee, CanEditEmployee"] it gives me and error of unauthorized.
The Application is closing automatically afert a few seconds
Try to update the VS studio I suggest
background music very bad
Sorry about that 😢
@@Code-Academy Ye bro, no one wants segmented repetitions of music as the pause and play to code along lmao. I look forward to this video though, thank you for the content!
@@Code-Academy Broooo this music I hadn't even started the video when I made the first comment lmaoooo 🤣🪦🤣🪦🤣🪦🤣🪦 It's like music for antidepressant commercials or something 🤣 🤣 🤣 🤣 🤣 🤣
@@bigggmoustache8868 😃
The background music was a little too loud for this type of video, but other than than great tutorial, exactly what i needed. Thank you.