ASP.NET Core - Roles vs Claims vs Policy

Поділитися
Вставка
  • Опубліковано 23 лип 2024
  • In this video I attempt to give me interpretation and explanation of the roles, claims and policy implementations in asp.net core.
    Project on github
    github.com/T0shik/rolesvsclai...
    Patreon 🤝 / raw_coding
    Courses 📚 learning.raw-coding.dev
    Shop 🛒 shop.raw-coding.dev
    Discord 💬 / discord
    Twitter 📣 / anton_t0shik
    Twitch 🎥 / raw_coding
    👉 Try Rider
    www.jetbrains.com/store/redeem/
    RD5K9-4TXXW-KMV3G-NYWSF-3ZSTP
    More Information on the Roles, Claims and Policies.
    Role based Authorization
    docs.microsoft.com/en-us/aspn...
    Claims based Authorization
    docs.microsoft.com/en-us/aspn...
    Policy based Authorization
    docs.microsoft.com/en-us/aspn...
    Good Stack Overflow Thread
    stackoverflow.com/questions/2...

КОМЕНТАРІ • 141

  • @RawCoding
    @RawCoding  Рік тому

    UPDATED VIDEO: ua-cam.com/video/W5T6713KRzg/v-deo.html

  • @mistrykam
    @mistrykam 2 роки тому +1

    Great explaination! The diagrams showing the difference between role (binary) and claims (key/value) and how it's related to policy (permission) was really helpful.

  • @AssasinsCreeper
    @AssasinsCreeper 3 роки тому +1

    I had to watch this video a couple of times and read differets documentatons on this subject. But now, days later, I've finally understood! Many thanks!

    • @RawCoding
      @RawCoding  3 роки тому +1

      Glad you got it! Nice avatar as well )

    • @AssasinsCreeper
      @AssasinsCreeper 3 роки тому

      ​@@RawCoding I see you are a man of culture

  • @mieto5545
    @mieto5545 5 років тому +5

    Thank u vvvvery much!!!! I am a new programmer but there is few tutorial on this newest version of Asp.net core 2.2 MVC. I have just been confusing for a long time on what you made in this tutorial . It really helps!

  • @far-red
    @far-red 3 роки тому +2

    At 9:15, i totally got the roles and policy concepts, i immediately git pull the solution, tested and understood, code is nice and clean.
    i was looking for this, and this really really helped, thanks.

  • @TakuCoding
    @TakuCoding 5 років тому +130

    Best intro lol

    • @RawCoding
      @RawCoding  5 років тому +1

      Rhank you, I try my best ))

    • @ManuelBasiri
      @ManuelBasiri 4 роки тому +1

      Very original. Really liked it. Keep up the good work good dude.

    • @RawCoding
      @RawCoding  4 роки тому +1

      Thanks) glad you liked it

    • @viktorbelousov640
      @viktorbelousov640 4 роки тому +1

      comment just for pay respect) Thank you for the video!

    • @RawCoding
      @RawCoding  4 роки тому

      Thank you for watching)

  • @josiahtmahachi7291
    @josiahtmahachi7291 3 роки тому +3

    Awesome tutorial. Really clears up things. Thank you...

    • @RawCoding
      @RawCoding  3 роки тому

      Thank you for watching

  • @anikovarkonyi2419
    @anikovarkonyi2419 4 роки тому +1

    Best video, thanks a lot I could finally understand these 3!

  • @Suncircle2011
    @Suncircle2011 4 роки тому +3

    Thank you, man! Finally I’ve got it. Msdn documentation doesn’t make it clear, and you do.

  • @codecorn6069
    @codecorn6069 4 роки тому +1

    Hi. I have a question about "YearWorkedFilter" class in "YearsWorkedAttribute.cs" file. how Year property get value? in constructor, there is a [ Years = years; ] but how we get years at all?

    • @RawCoding
      @RawCoding  4 роки тому

      at 13:33 you can see we pass the value in the constructor (therse no 'new' keyword), github.com/T0shik/rolesvsclaimsvspolicy/blob/master/Claims/PolicyHandlers/YearsWorkedHandler.cs here's the class you can see we set year to Year.

  • @josephcoyle8126
    @josephcoyle8126 Рік тому +1

    I was immediately hooked once I heard that intro track!

  • @shenbrgd
    @shenbrgd 4 роки тому +13

    Very informative. Love the intro 😂

  • @aikidoshi007
    @aikidoshi007 4 роки тому +1

    Brilliant! Well done, thanks!

  • @trash2trash
    @trash2trash 2 роки тому +1

    SuperB! nice abstraction demonstration :)

  • @abdelkrimbournane7332
    @abdelkrimbournane7332 3 роки тому +3

    Hello, thanks for the tutorial.
    I want to ask you : what's the difference between a claim and any other field in the user table (if we extends IdentityUser table) thank you.

    • @RawCoding
      @RawCoding  3 роки тому +1

      Claim goes in the ClaimsPrincipal object, the others are just properties on the User object

    • @abdelkrimbournane7332
      @abdelkrimbournane7332 3 роки тому

      I got it thanks, I should've finished the video before asking the question. Great content, thank you

  • @TriPham-id7jo
    @TriPham-id7jo Рік тому

    Great video!

  • @bahmanasheghi
    @bahmanasheghi Рік тому

    the grand entry was awesome :)

  • @aj.arunkumar
    @aj.arunkumar Рік тому

    very awesome video... thanks man..!!

  • @TheZohan-777
    @TheZohan-777 5 років тому +1

    great tutorial, thank you!

    • @RawCoding
      @RawCoding  5 років тому

      Glad you enjoyed it))

  • @sammygimnyigei
    @sammygimnyigei 4 роки тому +1

    Impressive!!!! thanks for the video

    • @RawCoding
      @RawCoding  4 роки тому +1

      Glad you enjoyed it!

  • @vandeljasonstrypper6734
    @vandeljasonstrypper6734 4 роки тому +1

    Hi man, In the new ASP.NET CORE
    the parameter of the controller can seem to read the Json object from the body of POST REQUEST from postman or nightingale
    Did you recently encounter this before ?

    • @RawCoding
      @RawCoding  4 роки тому

      If the http method is POST and the body of the request contains text that happens to be json, the dotnet core [FromBody] attribute will try to model bind that json to your model. It doesn't matter where the request is coming from. This has been working since v1 I think.

    • @vandeljasonstrypper6734
      @vandeljasonstrypper6734 4 роки тому +1

      @@RawCoding I fixed it, turn out I remove the object and just throw the attributes to it and it automatically work. I have struggle all day with it

    • @RawCoding
      @RawCoding  4 роки тому

      Good job.

  • @samlama6223
    @samlama6223 3 роки тому +1

    Hello great tutorial, but quick question IAuthorization filter to validate claim for controller, but does it validate TokenValidationParameters?

  • @rezameshksar503
    @rezameshksar503 3 роки тому +1

    I gave my like in the first second of the video. Great intro

  • @martink4975
    @martink4975 4 роки тому +1

    I know this is an old video, but this one was one of the better once on the subject. Something clicked when you described policies as functions, which made me wonder about a scenario.
    If you have a Blog site and want to limit the amount of blogs a user can create, would you use a claim with a policy to check if the max limit has been reached on CreateNewBlog action (get/post) ? OR would you do something simpler like checking the DB when the user is inside the CreateNewBlog action ?

    • @RawCoding
      @RawCoding  4 роки тому +1

      Thank you, and you'd check the db no need to store it as claim. And in my auth series, (episode 3 or 4 I think) I explain how dotnet core provides resource based authorization.

    • @martink4975
      @martink4975 4 роки тому +1

      @@RawCoding Amazing! I hope i can repay the time and effort you put into your educational content, just got to get that full stack job. thx again and have a wonderful weekend my man.

    • @RawCoding
      @RawCoding  4 роки тому +1

      @@martink4975 thank you man, don't forget to wash your hands

  • @mohammadkheder8994
    @mohammadkheder8994 4 роки тому +1

    thank you . if i create new role on runtime , how i can give this new role permission on specefic method at runtime.

    • @RawCoding
      @RawCoding  4 роки тому

      It's a complicated thing to make, I can't explain in a comment.

    • @mohammadkheder8994
      @mohammadkheder8994 4 роки тому +1

      @@RawCoding thank you ,do you know vedio explain this ?

    • @RawCoding
      @RawCoding  4 роки тому

      @@mohammadkheder8994 No, it takes time and skill to properly implement what you are asking for.

  • @taraspelenio8259
    @taraspelenio8259 4 роки тому +1

    Great explanation as well

  • @lessel7517
    @lessel7517 4 роки тому +1

    Intro sound effects are Hollywood level

  • @dmitrypopov501
    @dmitrypopov501 2 роки тому +1

    Thanks very much.

    • @RawCoding
      @RawCoding  2 роки тому

      Thank you for watching

  • @priyanshu4016
    @priyanshu4016 3 роки тому +1

    best start :)

  • @edward_t450
    @edward_t450 4 роки тому +1

    Nice vídeo, Nice Channel. Alrewdy subscribed

    • @RawCoding
      @RawCoding  4 роки тому

      Thank you! Don't forget to join the discord server!

  • @PerryCodes
    @PerryCodes 2 роки тому +1

    IsAdmin claim vs Admin role… I still don’t have a clue what the pros and cons are and what situation each might be best used in…

    • @RawCoding
      @RawCoding  2 роки тому

      Claims describe a user, Roles are just claims with an extra layer. So just use claims really

  • @govindsaini5600
    @govindsaini5600 4 роки тому +2

    Intro sound great.

    • @RawCoding
      @RawCoding  4 роки тому

      Hahha still cracks me up

  • @yogeswarank
    @yogeswarank 3 роки тому +2

    Thank you very much. Can you also make a video on how to change the user claim after the user is logged in. Need a flexibility to refresh the claims of the user without asking him to log out and login again.

    • @RawCoding
      @RawCoding  3 роки тому +1

      Use IClaimsTransformer

    • @yogeswarank
      @yogeswarank 3 роки тому +1

      @@RawCoding Thanks for your suggestion. I tried the IClaimsTransformation earlier. The modified claims under TransformAsync works only for the current controller and doesn't work when redirecting to another controller. I'm using cookie authentication in .Net Core 3.1. Do I need to do anything additionally for IClaimsTransformation to work for subsequent requests to work with new claims.

    • @RawCoding
      @RawCoding  3 роки тому +1

      Watch episode 3 or 4 of my auth series I explain how to use it there.

  • @albertogalvan3425
    @albertogalvan3425 3 роки тому +1

    awesome!

  • @nobudy_left
    @nobudy_left 9 місяців тому

    best intro ever

  • @gasletel
    @gasletel 4 роки тому +1

    Thumbs up for the intro

  • @kinggoncalo1587
    @kinggoncalo1587 3 роки тому +1

    Can u tell me whats the password for the admin ?

  • @hadibazmi6340
    @hadibazmi6340 3 роки тому

    love the them song:D

  • @ibknl1986
    @ibknl1986 3 роки тому +1

    Good video

  • @esnatzea
    @esnatzea 4 роки тому +1

    Nice intro bro!

  • @khusravkholmatov3667
    @khusravkholmatov3667 4 роки тому +1

    Thanks

    • @RawCoding
      @RawCoding  4 роки тому +1

      Thank you for watching

  • @psalterynbass
    @psalterynbass 5 років тому +2

    Where is the git repository?

    • @RawCoding
      @RawCoding  5 років тому

      Thank you for watching the video, link to the git repo is in the description

  • @christianrazvan
    @christianrazvan 2 роки тому +1

    Good intro!

  • @baoshenyi
    @baoshenyi 5 років тому +1

    Roles are required:
    a) admin has access functions
    b) not admin has no access to functions
    Claim = Role + other business rules (complicated authorization)
    a) admin + 5 years employee has access functions
    Policy : use Claim to apply the authorization, which could make claim easy to be coded

    • @baoshenyi
      @baoshenyi 5 років тому +1

      Is this a good way to understand it? If authorization is complicated, role will be chosen and without policy?

    • @RawCoding
      @RawCoding  5 років тому +3

      I think you understand Roles correctly.
      Claims are not specific to Authorization but rather they define a user, You can then take a step to use the user definition to apply authorization using policies.
      Hope this helps.

  • @RagdollRocket
    @RagdollRocket 4 роки тому +1

    intro gave me superpowers. and a slight headache =)

    • @RawCoding
      @RawCoding  4 роки тому +2

      Hahaha well balanced

  • @abhikale3946
    @abhikale3946 Рік тому

    😘😘 your intro...

  • @sammygimnyigei
    @sammygimnyigei 4 роки тому +1

    i hope ill find a video on third party accounts by you

    • @RawCoding
      @RawCoding  4 роки тому

      Hey what do you mean third party accounts? You mean external authentication?

    • @sammygimnyigei
      @sammygimnyigei 4 роки тому +1

      @@RawCoding yes OAuth facebook,twitter etc

    • @RawCoding
      @RawCoding  4 роки тому +1

      @@sammygimnyigei yes I. Will be covering that including identity server.

    • @sammygimnyigei
      @sammygimnyigei 4 роки тому

      @@RawCoding imm looking forward to it

  • @marvincorreia2040
    @marvincorreia2040 3 роки тому +1

    God damn nice intro kkk

  • @akbare-z815
    @akbare-z815 3 роки тому +1

    dope intro

  • @craige7485
    @craige7485 4 роки тому +1

    Could you please give me this code. I need it for a school project.

    • @RawCoding
      @RawCoding  4 роки тому +1

      Did you check the description?

  • @realliveone
    @realliveone 4 роки тому +1

    If you weren't scrolling like a maniac when showing the code, I would know what's in it.

    • @RawCoding
      @RawCoding  4 роки тому

      lol, gotta go fast man! source code is available :)

  • @isnakolah
    @isnakolah 3 роки тому +1

    A like for the intro 🤣🤣🤣🤣🤣

  • @workcompe-bill4780
    @workcompe-bill4780 Рік тому

    Please redo this presentation. I've only found your channel a few days ago and I've watched many of your presentations. Wow! You have one of the most well articulated and thought-out set of videos but this one got away from you. You are all over the place. Although I understood the content and it made sense, I personally have struggled with staying focused. It was as if you were uncertain, disconnected, or at best you were forced into doing this video and didn’t want to. It very much seamed like you were an amateur that you are most certainly not! I am a loyal fan now, but not of this particular production.

    • @RawCoding
      @RawCoding  Рік тому +1

      Good shout I’ll remake it, thank you.

    • @RawCoding
      @RawCoding  Рік тому

      video will be up next week.

  • @yuhechen7258
    @yuhechen7258 3 роки тому +1

    Congratulate everyone who come across this video.

    • @RawCoding
      @RawCoding  3 роки тому

      Thank you everyone for watching!

  • @demiryasinoruc
    @demiryasinoruc 4 роки тому +2

    Like for first 10 seconds

  • @LienNguyen-vq1qv
    @LienNguyen-vq1qv 2 роки тому +1

    the video image is too poor, you need to fix it more

  • @wisnu7734
    @wisnu7734 3 роки тому +1

    Hi...just advice...i'm from asia..my english is not that good..so please talk slowly and using easy vocabulary on the next video...🙏🙏🙏

  • @hidaya1538
    @hidaya1538 2 роки тому

    The into hhhhhhhhhhhhhhhhhhh

  • @nemanjacvetkovic3003
    @nemanjacvetkovic3003 2 роки тому +1

    I've learned a lot from you videos. Thanks.
    But this one is you worst video sorry.

    • @RawCoding
      @RawCoding  2 роки тому

      Oh yea it was made long time agon

  • @ahmmedisthebest
    @ahmmedisthebest 3 роки тому +2

    Oh man I disliked because of the first seconds
    You deal with nervous viewers because they have problems to solve. They need something clear, organized, and formal, not this low American behavior.

    • @RawCoding
      @RawCoding  3 роки тому +3

      Nervous viewers? You come to this video when you have time to study not when it’s crunch time. And low American behaviour? Seriously? Sorry high and mighty Ahmed’s Tutorials.

    • @ahmmedisthebest
      @ahmmedisthebest 3 роки тому +1

      it's not about me and whether i have time or not this is supposed to be technical video and its intro is not this is it

    • @RawCoding
      @RawCoding  3 роки тому +3

      So this is to uphold the “technical ideology” standards for witch you’ve invented yourself. Not saying this video is done to a high standard but a lot of good educational content is fitted with silly jokes.

  • @absmand
    @absmand 3 роки тому +1

    downvoted due to intro.