Тёмный

ASP.NET Core 3 - Authorization - Ep.4 Extras (UPDATED: READ DESCRIPTION) 

Raw Coding
Подписаться 73 тыс.
Просмотров 44 тыс.
50% 1

Опубликовано:

 

27 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 128   
@RawCoding
@RawCoding 5 лет назад
Timestamps for different topics (I recomend IAuthorizationService and AuthorizationPolicyProvider): 00:31 - IAuthorizationService 10:18 - Global Authorization Filter 12:30 - AllowAnonymous Attribute 13:24 - OperationAuthorizationRequirement 21:47 - ResourceBasedHandler 28:32 - IClaimsTransformation 34:39 - AuthorizationPolicyProvider 57:53 - Custom Authorize Attribute
@RobinRana88
@RobinRana88 3 года назад
Please pin your comment its useful
@00l4
@00l4 3 года назад
If you have these timestamps in the description starting from 00:00, youtube will segment out your video automatically for you. It's usually more easier for your viewers to see the segments in the built-in media player rather than looking up for comments to find the timestamps. You just need to edit your description and add 00:00 - Intro to your timestamp list.
@RawCoding
@RawCoding 3 года назад
Yeah this video was out before that feature )
@00l4
@00l4 3 года назад
@@RawCoding You still can edit your description to have 00:00 - Intro at the first line of the list. It would still work regardless of when your video was out.
@RawCoding
@RawCoding 3 года назад
I’m aware
@mattomwit
@mattomwit 4 года назад
You rule. The best tutorials I have found even comparing to paid portals. Thank you for giving us the opportunity to learn this stuff.
@RawCoding
@RawCoding 4 года назад
Glad you liked it!
@drspyqwerty
@drspyqwerty 4 года назад
MEGA series. Ultra detailed. Problem solving. So much Info. Stick with it, absolutely worth it. Liked , Subbed, and Belled .
@RawCoding
@RawCoding 4 года назад
Thank you for encouraging the audiance :D
@nikhilkhambete5800
@nikhilkhambete5800 4 года назад
Your analogies are extremely good. This makes it very easy for us to understand the core concepts. Keep up the good work.
@RawCoding
@RawCoding 4 года назад
Cheers!
@dickybird08
@dickybird08 3 года назад
Been developing in .net for the last 2 years and so much of what you talk about in this series was almost a black box to me (and I think a lot of other developers). Videos like these are so valuable. Heading to Patreon now. Thank you.
@RawCoding
@RawCoding 3 года назад
Thank you very much, glad I could help)
@mustafabulgu5834
@mustafabulgu5834 2 года назад
Really good technical depth. Thank you.
@RawCoding
@RawCoding 2 года назад
Cheers
@LinuxUser822
@LinuxUser822 4 года назад
I've just started to watch it and I've clicked 'liked' upfront. I'm sure it will be great episode again!
@RawCoding
@RawCoding 4 года назад
Thanks! Glad you like these
@wutever0
@wutever0 2 года назад
great stuff man.. clean code and good descriptions
@RawCoding
@RawCoding 2 года назад
Checkout the new videos
@42069_
@42069_ 2 года назад
Authentication and Authorization user to be a scary concept to me, but not anymore thanks to you buddy :D you're a GOAT! I didn't get what was the purpose of the Rank field yet tho.
@abugsbunny
@abugsbunny 2 года назад
Great explanation and tutorial. Thx
@RawCoding
@RawCoding 2 года назад
Thank you for watching
@GorgeousPuree
@GorgeousPuree 3 года назад
You are a goddamn philanthropist... Thank you very much.
@RawCoding
@RawCoding 3 года назад
Thank you for watching
@alireza136211
@alireza136211 3 года назад
This is a great episode, really learned something valuable today. Thank you
@RawCoding
@RawCoding 3 года назад
Thank you for watching)
@juhairahamed5342
@juhairahamed5342 2 года назад
Thanks for good explanation
@RawCoding
@RawCoding 2 года назад
Thank you for watching
@EngDuraid
@EngDuraid 3 года назад
I hope that i can like this playlist more than one time , thank you very much for this useful course.
@RawCoding
@RawCoding 3 года назад
Thank you for watching
@azizbekibnhamid642
@azizbekibnhamid642 Год назад
Amazing course!
4 года назад
Great video as usual. I like the bookmarks in the comment. Very helpful. Great job, keep it up :)
@RawCoding
@RawCoding 4 года назад
Cheers :P
@remi8118
@remi8118 3 года назад
I didn't understand the difference between Operation and Claim :/ but I learn so much in your videos, thanks !
@RawCoding
@RawCoding 3 года назад
which part was this?
@vahitbayri
@vahitbayri 4 года назад
Thanks for great videos.
@RawCoding
@RawCoding 4 года назад
Thank you!
@yeasinahmed4819
@yeasinahmed4819 3 года назад
Thanks for awesome series. I'm learning more things from you. But I have a question. After the adding CookieJarAuthorizationHandler into the service scope. How do i know this _authorizationService.AuthorizeAsync using this CookieJarAuthorizationHandler in the controller action method. Thanks in advanced.
@RawCoding
@RawCoding 3 года назад
you can put a break point or log something
@gjorgenson
@gjorgenson 3 года назад
Excellent!
@RawCoding
@RawCoding 3 года назад
Cheers
@r0man0v-r0man
@r0man0v-r0man 4 года назад
dude, you are best!!!
@RawCoding
@RawCoding 4 года назад
Thank you))
@ArgeKumadan
@ArgeKumadan 4 года назад
I had to do the samething with DynamicPolicy in .net core 2.2. And i implemented the permission based authorization by that way. Which role has access to which permission? That info stored on my database. Great serie by the way, well explained and pretty enogh deep dived. Thanks...
@RawCoding
@RawCoding 4 года назад
Thank you!
@tiendang5149
@tiendang5149 2 года назад
Keep going, tysm
@RawCoding
@RawCoding 2 года назад
Thank you for watching
@lucianofabre4345
@lucianofabre4345 4 года назад
Thanks for greats videos!!
@RawCoding
@RawCoding 4 года назад
Thank you for watching
@juhairahamed5342
@juhairahamed5342 7 месяцев назад
Good Explanation
@pseudosmurf2k7
@pseudosmurf2k7 4 года назад
Fantastic tutorials, keep it up!
@RawCoding
@RawCoding 4 года назад
Cheers!
@THERESAPARTYINMYHEAD
@THERESAPARTYINMYHEAD 3 года назад
27:43 Should there be more code in the CookieJarAuthrizationHandler to handle what type of CookieJar resource it is? Or whats the point, its just going to authorize any cookie jar right?
@RawCoding
@RawCoding 3 года назад
This was meant to be an example, as long as you understand the concept you can put your own logic in there.
@THERESAPARTYINMYHEAD
@THERESAPARTYINMYHEAD 3 года назад
@@RawCoding Ok thanks, I thought so but just checking I wasnt missing something. Great series btw, really helpful :)
@_grzehotnik
@_grzehotnik 3 года назад
So, if I understand correctly, ResourceBasedHandler lets me authenticate User based on model that is provied in HttpRequest? Let's say we have an Order.cs tlike this: class Order { String name; ApplicationUser Owner; String OwnerID; } Obviously, when sending an HttpPut request to update an Order I require the user sending the request to be the owner of the Order (so basically User.Id == Order.OwnedID). If not, return 403. Wouldn't it just be easier to check current user's id and the OwnerID of Order posted in HttpPut method and then just return a proper HttpStatusCode? ResourceBasedHandler seems like a lot of boilerplate code. And what if I don't wanna use these Requirements and create static class for just storing them? All I need is just the current User and the Resource (Order in this case) to be able to authorize or deny authorization to the user, any way to do that with AuthorizationHandler? What comes to my mind is that I could just user AuthorizationHandler and authorize the user based on the data there.
@RawCoding
@RawCoding 3 года назад
You understand correct. Weather something is easier that the other one is hard to say because it'll largely depend on the wider system implementation.
@_grzehotnik
@_grzehotnik 3 года назад
@@RawCoding Ok, thanks.
@manisharma3068
@manisharma3068 4 года назад
You are a God Sent!.. ThankYauzaa :D
@RawCoding
@RawCoding 4 года назад
Thank you for watching
@calvinnel3954
@calvinnel3954 4 года назад
dude you rock keep making vids
@RawCoding
@RawCoding 4 года назад
Thanks dude!
@arico94
@arico94 3 года назад
Great videos. How the heck do you code so fast??
@RawCoding
@RawCoding 3 года назад
Practice and movie magic
@Naveen-qy2hw
@Naveen-qy2hw 3 года назад
sir, 29:35 meaning of Any time user is checked for his authentication better way to call this method multiple times ... not understood. Why you are added claim(Friend,"bad") at runtime to user Identity....not understand the advantage of Extending IClaimsTransformation....can you explore more ....i am eagerly waiting for reply
@RawCoding
@RawCoding 3 года назад
It’s a way to extend a ClaimsPrincipal at runtime. Use it when you need it there’s no advantage, this tool solves a problem.
@FancyRecoder
@FancyRecoder 4 года назад
i'm a dotnet core learner from China. thank you so much for so many great videos. i got a problem with the authorizationHandler middleware. i've typed almost every code , in this episode i created every class u have created in homeController.cs and customAuthorizationPolicyProvider.cs, and everything works fine except class securityLevelHandler. i created that class〖public SecurityLevelHandler:AuthorizationHandler{protected override Task HandleRequirementAsync(... ...)......}〗, then register it in my startup 〖services.AddScoped....〗, but it doesn't work at all. i create a breakpoint at HandleRequirementAsync function, then access page home/securityLevel or home/securityHigherLevel, every class and function works but this class and this function, all i got is access denied. i checked my spell or if sth i missed but found nothing. i post my code screenshot in my twitter: [ twitter.com/michael_65536/status/1256868855479021568?s=20 ] i 've been stuck in here for whole day... Hope you can help me to solve the problem, thanks a lot ! by the way, i'm using dotnet core 3.1 and vs 2019 v16.5
@FancyRecoder
@FancyRecoder 4 года назад
were i wrote wrong or something else? thank u a lot
@RawCoding
@RawCoding 4 года назад
Thank you for your comment, you have very good english :) github.com/T0shik/aspnetcore3-authentication/commit/c9ff075bd0cc74d0c760eadde7c1e153968a8900#diff-ddeef559d2c8678d57c226b9c27e010bR47 > .AddRequirements(new SecurityLevelRequirement(Convert.ToInt32(value))) You don't add the requirement in order for the handler to be triggered, you rather check if the claim is there.
@FancyRecoder
@FancyRecoder 4 года назад
@@RawCoding god, that's true... i really missed it, stupid on me... thank you so much for this!!! and thank you for this series of video again!
@georgemukwewa376
@georgemukwewa376 4 года назад
dude, thank you!!!
@RawCoding
@RawCoding 4 года назад
no, thank you!
@Rodrick.
@Rodrick. 5 лет назад
Thanks for the vid! I have used .Net for a few years now, but always as a backend API , always with Angular as the frontend App I have never tried MVC or Razor, less Blazor. My question is, do I start straight into Blazor? or MVC first? or Razor Pages? Another thing, to my knowledge Blazor replaces the front end App like Angular, but there is still the backend, does the backend here counts as Razor pages?
@RawCoding
@RawCoding 5 лет назад
Cheers! Try mvc or razor 1st that will just get you used to html and templating with c#, this skill will then be transferable in to blazor where you can extend what you've done with razor components, word of warning though server side blazor is a specific niche and client side isn't production ready. Your last question is a bit confusing, but just so you know the backend is just C#/F#, unless with js framework you want server side rendering then you also spin up an instance of Nodejs. If you are on about server side blazor just remember that blazor/razor compiles down in to C#.
@dmnreddy
@dmnreddy 2 года назад
Hi Can you please upload how to achieve two factor authentication - using ID Server. It will be great help. Thank you.
@RawCoding
@RawCoding 2 года назад
ID Server has nothing to do with MFA
@craigacronin
@craigacronin 3 года назад
Hi, I am building an application that has a single signon page. What I need to happen is for it to try ldap but if that fails to fall back to forms authentication. I can't see any examples on the web on how to achieve this, I've seen the mention of JWT, or IdentityServer so working through these videos but any advice you could give would be great.
@RawCoding
@RawCoding 3 года назад
Don’t know much about idap
@craigacronin
@craigacronin 3 года назад
@@RawCoding active directory windows authentication.
@RawCoding
@RawCoding 3 года назад
The docs are really good on this one docs.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-5.0 You should be automatically authenticated when visiting the site otherwise sign in. You can try enable windows auth but protect your site with another schema so when they visit the sign in page you conver the windows identity in to your custom one
@MrShakir820
@MrShakir820 4 года назад
CookieJar! hahahha. U love cookie! I got you.
@RawCoding
@RawCoding 4 года назад
I love cookie
@MrShakir820
@MrShakir820 4 года назад
@@RawCoding hahaha.
@oladipotimothy6007
@oladipotimothy6007 4 года назад
How do you know the DefaultAuthorizationpolicy inherits from IAuthorizationPolicyProvider
@RawCoding
@RawCoding 4 года назад
Dotnet is open source and you can see the source code
@oladipotimothy6007
@oladipotimothy6007 4 года назад
@@RawCoding so you literally check the source code for any implementation?
@RawCoding
@RawCoding 4 года назад
If I want to know the implementation details then yes
@PelleWidell
@PelleWidell 4 года назад
Another great tutorial that helps you understand this tolic very good! I loved the ”custom” SecurityLevel instead of just Authorized for the iactionresult Secretlevel. But what if you have say Securitylevel(int Id), can you handle the value of id in your custompolicyprovider? I have tried to get both classname and actionname in an handler like that but haven’t succeed, less any inputpara,eters for the action. Any idea on where too find a so,ution for that?
@RawCoding
@RawCoding 4 года назад
what do you mean handle value of id? don't we do exactly that but it's just named level or something?
@PelleWidell
@PelleWidell 4 года назад
@@RawCoding say you change the code to: [SecurityLevel(5)] public IActionResult SecretLevel(int id) { } And instead of an url of home/secretlevel you have home/secretlevel?id=105 Are there any way you can include 105 in your customhandler?
@agnieszkaryznar6775
@agnieszkaryznar6775 5 лет назад
I have login method in my code and i want to use [Authorize] attribute, but every time i log in to my homepage ( Redirect(returnurl ?? "/")) it doesnt work and i dont know why is that, because the result of authorization (Succeeded value) is true.
@RawCoding
@RawCoding 5 лет назад
Check your pipeline, have you watched the 1st episode?
@Naveen-qy2hw
@Naveen-qy2hw 3 года назад
33:43 doesn't override the state...not understood, actually in real-time project we store claims at the database, from there we pick/take. what is extracted, what is dragged...unable to understand th
@RawCoding
@RawCoding 3 года назад
Doesn’t override the state meaning if you add a claim via claims transformer it doesn’t actually add it to the cookie. So you load the original claimsprincipal from cookie in to httpcontext and then you extend it with claims transformation
@ItsJustEza
@ItsJustEza 4 года назад
Keyboard with MX Browns? Sounds good haha
@RawCoding
@RawCoding 4 года назад
Damn you have a good ear
@johnsmith-hs1we
@johnsmith-hs1we 2 года назад
InvalidOperationException: AuthorizationPolicy must have at least one requirement. 😭
@RawCoding
@RawCoding 2 года назад
Give it a requirement John
@johnsmith-hs1we
@johnsmith-hs1we 2 года назад
@@RawCoding I have tried but cant work it out 😣
@RawCoding
@RawCoding 2 года назад
Post the code for your policy John
@davidwu1907
@davidwu1907 4 года назад
Can IdentityAuthentiation implement the SecurityLevel example also?
@RawCoding
@RawCoding 4 года назад
Yes
@davidwu1907
@davidwu1907 4 года назад
@@RawCoding Thank you. Your english is good.
@RawCoding
@RawCoding 4 года назад
Cheers
@paviad
@paviad 4 года назад
When the user tries to access an action to which they are not authorized, I want to redirect to a "Not authorized" page, not to the login page, how do I do that?
@RawCoding
@RawCoding 4 года назад
There's a fundamental difference between authorization and authentication. If the user is not authenticated then by default he is not authorized, at this point we set the LoginPath. If the user is authenticated but not authorized then we set the AccessDeniedPath. If you would like more fine grained redirects, like for instance on some actions an unAUTHENTICATED user should not be redirect to login but show the access denied page, you would need to manually handle this within an action and use the IAuthorizationService, or create a custom Authorization attribute to handle this.
@sisfocom
@sisfocom 4 года назад
Good, I hope you can help me with the dilemma I have, when generating the Claims in this way "new Claim (ClaimTypes.Name," ABCD ")", the format is "{schemas.xmlsoap.org/ws/ 2005/05 / identity / claims / name: ABCD} ", and when" new Claim ("Name", "ABCD") "is generated in this way, the format is" {Name: ABCD} ", the problem in First way I don't know how to find the value, since in the second way I can use @ User.FindFirst ("Name"). Value in the view and claimsIdentity.FindFirst ("Name"). Value in the controller, as I should look for the value in the first form or format ...?, Thank you very much.
@RawCoding
@RawCoding 4 года назад
Use ClaimTypes.Name to find the claim, make sure you have the namespace.
@sisfocom
@sisfocom 4 года назад
@@RawCoding Dear, I am trying to see or use the Claim in a view, but I can't find what the ClaimTypes.Name tells me, any ideas ...? THANKS.
@RawCoding
@RawCoding 4 года назад
I did tell you, include the namespace, @using you can even put it in the _ViewImports file if you have one
@heyderelesgerov9499
@heyderelesgerov9499 3 года назад
44:48 - constant methods lol
@RawCoding
@RawCoding 3 года назад
Happens )
@heyderelesgerov9499
@heyderelesgerov9499 3 года назад
@@RawCoding We love you )
@huyhoangtran4031
@huyhoangtran4031 2 года назад
Good
@emilsimonyan2818
@emilsimonyan2818 4 года назад
👍👍👍👍👍👍
@RawCoding
@RawCoding 4 года назад
Thumb
@BaoNguyen-xj5td
@BaoNguyen-xj5td 4 года назад
Thanks for great videos. And I think your other videos should have agenda like this one, follow easier.
@RawCoding
@RawCoding 4 года назад
You think explaining topics rather than building projects is better to learn?
@BaoNguyen-xj5td
@BaoNguyen-xj5td 4 года назад
@@RawCoding building projects, i think, is better to learn. But some cases should be explained for wider view. It likes you show up other options so that we'll understand why we should it
@RawCoding
@RawCoding 4 года назад
@@BaoNguyen-xj5td valuable information thank you
@soberacidtrip
@soberacidtrip 4 года назад
These tutorials have a lot of potential, but they fail to tie together the concepts in the first lesson -- namely claims, claims principals, claims identity -- with asp.net identity. You showed that a person can have multiple claims with multiple claims identities, but didn't show how that works with, or give real life examples of this, with asp.net identity. I watched all of the episodes hoping so badly that I might finally grasp all this identity stuff, but you never quite got there.
@RawCoding
@RawCoding 4 года назад
You can find real world examples in my Blog (Roles example) and Shop (Claims example) series. Real world examples require a real world application and its a long and dragged out process which has steps of planning and justifying decisions that's not what these series were. Trust yourself if you understand the concept you can map ideas in to these constructs.
@3dsupplies
@3dsupplies 3 года назад
Great course, you just have to learn to talk and type a bit slower,.. Hard to follow. Pauze button is my companion....
@RawCoding
@RawCoding 3 года назад
Thank you, it’s a hard thing to balance
Далее
Гаджет из даркнета 📦
00:45
Просмотров 266 тыс.
Brutally honest advice for new .NET Web Developers
7:19
Implementing JWT Authentication in ASP.NET Core
23:51
Microsoft Makes Windows Worse With AI
9:34
Просмотров 165 тыс.