Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net mvc role based authentication

I created a new web application and chose organizational as authentication type. I have the app tied to my office 365 account. In azure I was able to create roles and able to assign to users. My question is how do I allow my web application to take advantage of these roles either using controller annotation (eg Authorize(Role=admin)) or using the method User.IsInRole()?

like image 356
jheatherington Avatar asked Apr 30 '26 23:04

jheatherington


1 Answers

I use controller annotation, but for individual accounts with roles. I guess it's the same for organizational accounts. The benefit from using authorize attribute is that the attribute can be added for whole controller, unlike User.IsInRole() in every action.

Authorize attribute example

like image 89
mihkov Avatar answered May 03 '26 13:05

mihkov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!