Multiple custom authorization handlers for a requirement in asp net core

preview_player
Показать описание
Why we need multiple authorization handlers for a given requirement with an example.

Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.

We implement multiple handlers for a given single requirement, when we have cases where want the evaluation to be on an OR basis. Let's understand this with an example.

Text version of the video

Slides

ASP.NET Core Text Articles & Slides

ASP.NET Core Tutorial

Angular, JavaScript, jQuery, Dot Net & SQL Playlists
Рекомендации по теме
Комментарии
Автор

Hi Venkat, context.Resource as AuthorizationFilterContext is coming as null, even it is decorated with and I have also injected in the service. Any idea why is giving null?

TheAnup
Автор

I am getting following error


An unhandled exception occurred while processing the request.

InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found.
context, string scheme, AuthenticationProperties properties)


Stack
InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found.
context, string scheme, AuthenticationProperties properties)
context)
result)



httpContext)
context)
context)
context)

gauribavdekar
Автор

Dear sir, I don't know, It is possible to see you or not... But tonight I have seen you in my dream .

piasuddin
Автор

Since the SuperAdminHandler is somewhat generic and I could see it being reused elsewhere, do we need to specify that it inherits AuthorizationHandler<specific requirement class>. I see that it ties the handler to that requirement. But instead can change it to and add the requirement to the needed policy definitions?

Octopie
Автор

Can you re-use Handlers for different Requirements? Say you have an "AdminHandler" that you use to determine who is an Admin. So you use that to handle a GetIntoArea1Requirement. But there is another Requirement GetIntoArea2Requirement that both Admin and another group can see - so you have to write another handler for the 'another group' - but is there a way to re-use the Admin Handler or do you have to write the same logic again as it pertains to a different Requirement??

evant
Автор

In SuperAdminHandler, I placed a breakpoint to see whats going on
For super admins, the if condition does return true and the context.succeed is also run but for some reason it doesn't let the resource be accessed even though it succeeded. HasSucceeded property is still false even though im calling the succeed method on the context. I googled this and i didnt find any solutions.
This behavior persists only if im logged in as a super admin. This doesn't happen with admins. the context.succeed works for admins but not for super admin accounts. Any idea why? thanks.

AkshayKumar-dzts
Автор

Hope you can do some tutorials on Asp.net Core with Razor Pages. Thanks!

doorscomputersco.
Автор

Because in the _Layout view the condition for showing Manage option is if the user is in Admin role.
please help @kudvenkat

iamsaddamahmad
Автор

Hi..Sir, Can you Upload Vb.net video because i want to learn vb.net because your method is very nice to explaination..

vaseemahmad
Автор

but in second superadmin handler you are allowing super admin to manage his own roles and claims.

VinodKashyap-jbny
Автор

Very confusing, not understand at all

ymtan