🔒 Identity with a .NET 6 Web API & Blazor WebAssembly

🚀 .NET Jumpstart Course: www.udemy.com/course/net-core...
📧 Newsletter: newsletter.patrickgod.com/
❤️ Ko-fi: ko-fi.com/patrickgod
☕ Coffee: www.buymeacoffee.com/patrickgod
💻 GitHub: github.com/patrickgod/BlazorI...
🐦 Twitter: / _patrickgod
📓 Articles: / patrickgod
🎥 Skillshare: www.skillshare.com/r/user/pat...
🔥 Blazor E-Commerce Course: www.udemy.com/course/blazor-e...
🔥 Blazor Bootcamp: www.udemy.com/course/blazor-w...
Table of Contents:
00:00 🔒 Identity with a .NET 6 Web API & Blazor WebAssembly
03:39 Create the Project
06:11 Solution Overview
07:29 Run Application for the First Time
10:31 Use SQL Server Management Studio for the Database
12:18 Change the Connection String
13:12 Install EF Core Tools
14:39 Apply Migrations
18:58 Register a User
21:20 Scaffolding Identity Files
27:33 Add a Relationship to the ApplicationUser
30:43 Add a new Migration
31:49 Add Super Heroes
32:42 Add a Controller to GET related Super Heroes from the Database
37:43 Implement Web API Call on the Blazor Client
39:26 Test the Implementation
40:18 Use the Include() function to load the related Super Heroes
41:13 Utilize the UserManager of Identity
42:57 Load related data with AutoInclude()
44:18 Use the AuthenticationStateProvider to get the current User's Authentication State
🙏MANY THANKS TO THESE LOVELY PEOPLE:
Piotr Franczak
Jan Trichter
Tom
H. Ali
Ashley Gahl
Daniel Viveros
Mehmet Ali Ege
Winther
harry j
@Alaffer
Sam Catlow
Jim
Brian Williams
Gonzo
Jonas
Ariel Sartor
Andy Benson
@stevelikespies
Raphael Lukas
James Goforth
@williamdevine
Doug Nelson
Arif Hasanov
@kohji1712
@dlb78dlb
Thomas Korsgaard
FastTrak
Jeff Sager
Dan Moyer
AlgoMarket
Mennskr
Simon
Michael Mel
Hermann Rösch
Jim McNeal
Kieron
@mgrainger231
Gerrit Esmeijer
Axel
Kareem Skinner
Joaquim
Alain Legrand
Per Rieland
@prodrigu75
Greg
Brendan Maunder
Stageoner
Andrew Campbell
pascalditzfeld
PovilasSimanskas
Ameet Jayawant
jenö
Marco Otilli
Mark
l33ter
alibux
g.dassel
Luke Vincent
mrcl
Alain Legrand
Thomas Werner
István Csibor
Grant Burdon
@gianluigiconti
Gerrit Esmeijer
Illia
Németh-Pók István
Michael Mel
Marko Zdilar
GerryB
@DADA_universe
Domen Hren
@heroesch
Carey
Peter De Tender
Baris Keskin
@Big_Bear_27390
Mathias
walter e watkins
Günther Dassel
Axel
Josh
Daniel Huber
Fredric Adell
Juan Carlos
Manolis
Pajani
P.
Jonas Granlund
Bobby
Kristina
@xamarin007
#DotNet #Identity #PatrickGod

Пікірлер: 62

  • @YuzzyBee
    @YuzzyBee2 жыл бұрын

    A complete tutorial with Blazor, Oauth and Roles would be really amazing because authentication and authorization are quite complicated at the beginning but almost indispensable for every project. Thank you so much Patrick !

  • @FredHendrix
    @FredHendrix2 жыл бұрын

    It is like you are in my head - I was thinking about using MS Identity with Blazor and you alert popped up. You have supernatural insight.

  • @Artmageddon
    @Artmageddon2 жыл бұрын

    OMG I've been so eager to learn about this! Was looking at other tutorials and was getting super confused going through it so I can't wait to see this!

  • @Duelweb
    @Duelweb2 жыл бұрын

    Am working on this right now, could not have come at a better time! Thank you.

  • @digitaldaridesatv1545
    @digitaldaridesatv15452 жыл бұрын

    Thank you Patrick!

  • @bowend01
    @bowend01 Жыл бұрын

    This is pure gold! I've been beating my head on the desk trying to figure out this type of authentication and this is a concrete, pragmatic description of this process and gets me exactly what I need. Thanks so much!

  • @PatrickGod

    @PatrickGod

    Жыл бұрын

    Thank you so much for your feedback, Doug. Glad I could help! 😊

  • @ranjisnnirma7
    @ranjisnnirma73 ай бұрын

    Thank you patrik sir, we will would much appreciate your help

  • @rdagger
    @rdagger2 жыл бұрын

    Thanks for the great tutorials! I appreciate how much time and work you must spend making them. At 5:57 in the video a readme appears that suggests licensing may be required. I followed the link and it looks like many businesses would need a rather expensive yearly license from Duende to use this authentication.

  • @ricardothomas3779
    @ricardothomas3779 Жыл бұрын

    Patrick you are awesome! Thank you for the content you share with your viewers. I/We are learning a lot. Security/Identity is one of the main areas I want to understand and get right for all my projects. I purchased your "Authentication & Authorization in . NET 6 with JSON Web Tokens (JWT), Refresh Tokens & Roles" course and I learnt a whole lot. The question I have is, how can I do the same thing in that course using Active Directory on-premises? Since Active Directory would has all users, how do I authenticate users via Active Directory on-premises to generate Access Tokens, Refresh Tokens, with claims and roles info to secure the resources ?

  • @remixowlz
    @remixowlz7 ай бұрын

    thank you really helpful

  • @joe77s
    @joe77s Жыл бұрын

    Thanks, this is great as usual.

  • @PatrickGod

    @PatrickGod

    Жыл бұрын

    Glad you enjoyed it!

  • @bayesdiarra3900
    @bayesdiarra39002 жыл бұрын

    Great tutorial!!!! can you please do one the complete Identity authentication with roles?

  • @fridayman99
    @fridayman99 Жыл бұрын

    Great video, Patrick! This stuff's non-trivial and you explain it so well. Do you mind doing a similar video, combining Identity + Blazor WebAssembly + JWT tokens? It can build on this video. Thanks again!

  • @PedalsizBerkay
    @PedalsizBerkay10 ай бұрын

    THANKS GOD !!!!!!!!!!!

  • @ahmetturkoz9954
    @ahmetturkoz9954 Жыл бұрын

    thanks..

  • @ryantunis7465
    @ryantunis7465 Жыл бұрын

    Super helpful tips on the scaffolding in this video! I got stuck there but not anymore! Any chance you have a video that explains Social login providers (Google, Facebook, Microsoft) in a production environment? I have a situation where the redirect URL's work just fine locally but when deployed in an Azure App Service the redirects go to the correct pages "signin-google" (for example) but the WebAssembly app routes just pick it up as a "page not found" and the full authentication flow does not complete on the Server portion.

  • @10Totti
    @10Totti2 жыл бұрын

    Great was a video I wanted to ask you :)

  • @comroec
    @comroec2 жыл бұрын

    thanks

  • @PatrickGod

    @PatrickGod

    2 жыл бұрын

    You're welcome! 😊

  • @remixowlz
    @remixowlz7 ай бұрын

    11:46 connection atabase

  • @dotnetdevni
    @dotnetdevni2 жыл бұрын

    Will this work within the confinds of blazor maui web assembly?

  • @shifuteamendurance
    @shifuteamendurance10 ай бұрын

    Hello, great tutorial as usual. thank you. I have a question about GDPR though. Do you know if as in your scenario, we're using JSON Web Tokens, we should do anything more to be GDPR compliant?

  • @coder3123
    @coder3123 Жыл бұрын

    is there a way to extend the Application user metadata using a one to one relationship? I want to keep the AspNetUsers table pure and add extra fields separately but when I try to do it the Add Migration does not create appropriate foreign key relationship, it puts the fk in AspNetUsers instead of putting users key in the new table.

  • @chezchezchezchez
    @chezchezchezchez2 жыл бұрын

    I’m making a server app, instead of the webassembly. all this apply to me too?

  • @witoldbarcinski813
    @witoldbarcinski813 Жыл бұрын

    MultipleActiveResultSets=false in connection string was helpfull

  • @abdullahal-nahian
    @abdullahal-nahian2 жыл бұрын

    Hi Patrick, I can't thank you enough for your videos. You have made my life easier. I'm facing a problem after scaffolding. A new ApplicationDbContext.cs file is created in Areas>Identity>Data>ApplicationDbContext.cs in addition to the existing Data>ApplicationDbContext.cs which is causing me headache. Can you please help me with this? PLEASE

  • @lantisdylan
    @lantisdylan2 жыл бұрын

    Sir can u make a blazor upload image save to database and save to folder

  • @leonardojosevargashernande1937
    @leonardojosevargashernande193711 ай бұрын

    Hello Patrick, thanks for the class, I've a doubt, if I need that de principal page of project will be /Identity/Account/Login, how can I do this? I don't want that the principal page will be index.html, however if the user is authenticated must redirect to index.html.

  • @samiryasser
    @samiryasser Жыл бұрын

    Can you tell how can I style scaffolded identity using css files in client site ?????

  • @LoneTaha
    @LoneTaha2 жыл бұрын

    more videos of blazor pleaseeee

  • @PatrickGod

    @PatrickGod

    2 жыл бұрын

    Alright! 😊

  • @EidurMoller
    @EidurMoller Жыл бұрын

    Why do you create the SuperHero class in the shared folder and not the Models folder in Server ?

  • @NaniwaRocky
    @NaniwaRocky2 жыл бұрын

    You look tired :D Keep up the great work! Waiting on a Hosted Blazor WASM with Microsoft Identity for Azure with implementation of roles etc.. would be nice! Thanks

  • @tiagocandeias3969
    @tiagocandeias3969 Жыл бұрын

    How can you disable the registration?

  • @briantheitguy
    @briantheitguy Жыл бұрын

    I love your videos and I am learning a lot in just the last week. I do have a question though.. Where can I find instruction on getting more info (like First & Last name) from the Google or Facebook identity?

  • @bigggmoustache8868

    @bigggmoustache8868

    Жыл бұрын

    If you add a breakpoint the validation you can dig through the object that the service returns. It probably varies a bit between whatever method you use, but I know it's not too hard to find in there. (sorry I'm new'ish and can't describe things well, but have used both google and facebook social sign-in methods and played with them a bit).

  • @coder3123
    @coder31232 жыл бұрын

    Do you have a tutorial on how to utilize .net password less auth and user registration for a .net api?

  • @uzibiran285
    @uzibiran285 Жыл бұрын

    Hello Patrick, I am interested in building a login API to use login from Blozer calinat, but I encounter a problem that all APIs are blocked before login. How can I solve this problem, and thanks in advance

  • @10Totti
    @10Totti Жыл бұрын

    So if we use identity we can do without jwt right?

  • @callistusogu5036
    @callistusogu5036 Жыл бұрын

    Please can you point me to a tutorial where .net 6 API with identity is taught. I don't want to use blazor I want use angular or rather someone else does frontend so I just want API that I can expose for the frontend engineer

  • @ceejayviii
    @ceejayviii19 күн бұрын

    How to initialize it in vs code?

  • @franciscoruiz7031
    @franciscoruiz70312 жыл бұрын

    Blazor + OAuth or something like that, thanksssss

  • @davidlyons24
    @davidlyons242 жыл бұрын

    I've been programing C# for almost 20 years for win apps with WinForms and then Webs in PHP and Laravel. I really love C# but this authentication system of Wasm Net Core it's a mess! Your tutorial it's great because it's the first one to show how to load User related entities. But net Core team should simplify it. For example in Laravel to get the user superheroes will be just a line of code. Anyway... I'll continue with this mess because of the multiplatform target :S

  • @flogginga_dead_horse4022

    @flogginga_dead_horse4022

    2 жыл бұрын

    Have you ever made Laravel work in an Enterprise with Azure AD, Office 365 etc.? Probably not.

  • @MarioStaats
    @MarioStaats2 жыл бұрын

    Great Video - but is it possible to use this without de license of duende? maybe a tutorial with openiddict or similar? *thubsUp for this Video

  • @m.ramadan
    @m.ramadan2 жыл бұрын

    Mine Didn't work :( i am using VisualStudio for mac on my M1 mac mini , the generated project is using SqlLite instead of SQLServer and I couldn't apply the migration.

  • @davidlyons24

    @davidlyons24

    2 жыл бұрын

    Normally that happens also when you create a project and change it to mysql for ex, that you have to delete the files in the migrations folder and then execute "dotnet ef migrations add InitialCreate" and "dotnet ef migrations add InitialCreate"

  • @amirameri1354
    @amirameri13549 ай бұрын

    Tank you for your nice video. But after all this, how to deploy website with blazor webassembly with host and individual account to external server? There are not any video or tutorial for this step.😢

  • @Denvercoder
    @Denvercoder Жыл бұрын

    The thing that bothers me is that all of these tutorials use SQL Server which is fine but try and deploy that. It will cost like $127/month for a cheap "DEV" SQL Server instance on Azure. You have one tutorial where you build a blog and you use Sqlite and I tried that but when I deployed the project it stopped working. I haven't been able to figure out how to deploy a Sqlite database on Azure. Could you please maybe make a short video where we can have: Blazor A cheap or free database that you show how to deploy and get it working? All I want to do is create a simple blog for myself and I'm not able to pay $100+/month to run it. I'm one of your supporters BTW ;)

  • @PatrickGod

    @PatrickGod

    Жыл бұрын

    Hey there, Thanks for reaching out. I haven't deployed SQLite to Azure, yet, but let me add this to my list. That said, have you thought about renting a Windows Server? Deploying a Blazor App there with SQL Server Express might be a better choice for you. I have a video about that here: kzread.info/dash/bejne/e5-qx7yIabfApLg.html Hope this helps! Take care, Patrick

  • @Denvercoder

    @Denvercoder

    Жыл бұрын

    @@PatrickGod I've been working with dotnet since 2003 but I have been doing React development for the past 6 years so my dotnet skills are a bit rusty and I'm a little stupid. The reason it didn't work is because the .db file didn't deploy. You have to go to Properties > Always Copy after doing that the .db file gets copied to the server. So now it works just fine. I am using the SQLite database but I had to use Microsoft Identity through Azure AD because I didn't know how to setup auth with the Sqlite database. Researching that now. For a simple blog it's nice not to have to pay for a database.

  • @azgan123
    @azgan1232 жыл бұрын

    Patrick. The JS community really sticks to firebase for small projects. How about a course on WASM + Firebase so I can learn how a pro does it?

  • @flogginga_dead_horse4022

    @flogginga_dead_horse4022

    2 жыл бұрын

    they do?

  • @dotnetdevni
    @dotnetdevni2 жыл бұрын

    U listened to my last comment then thanks so much ;-)

  • @kicker8641
    @kicker8641 Жыл бұрын

    I think Microsoft broke something, I started following the tutorial and when I got ot the scaffolding part and it keeps erroring, I thought I made some mistake, deleted the project and restarted same. Tried 3 different projects all failed with the same error *facepalm*

  • @k2an
    @k2an2 жыл бұрын

    Please give up this scenario.. how many firm using identityframework ready-to-use scheme! please!

  • @michaelswells

    @michaelswells

    2 жыл бұрын

    This is a great tutorial but I agree with Kaan. Most bigger companies provide authentication already (with SSO). You do not need to register an account but would request one or more roles, i.e., Program Manager (A), Program Manager(B), and Contract Manager (program C, contract 1). On the other hand, a website administrator would provision the role the user needs.

  • @torrvic1156
    @torrvic1156 Жыл бұрын

    Honestly your tutorial is counterintuitive. You didn’t started from the scratch. You just jumping from place to place. Hard to understand as to what is going on. And you are way too fast.

  • @kourosh234
    @kourosh234 Жыл бұрын

    When I debug the app I get an error, it says that it "Metadata file 'xxx.client.dll' could not be found". Anybody knows why?

  • @reidartho
    @reidartho2 жыл бұрын

    When I use a connectionstring to the productionserver I get error 500 "connBlazor": "Data Source=xxx.xxx.xxx.xxx;Initial Catalog=dbBlazorIdentity;User ID=sa;Password=Secret;MultipleActiveResultSets=true"

Келесі