简体   繁体   中英

Oauth with Custom Role Provider in asp.net mvc 5

I am using Thinktecture Identity Server V3 (Oauth) for authentication with custom user store and I want to use role based authorization.

I am trying to use custom role provider to check for the roles. username attribute is null for IsInRole method. How can I add user data to current context?

Is it good idea to use RoleProvider in this case or add the roles as Claims? If I add them to Claims how can I use [Authorize] attribute? Do I need to write a custom Authorize attribute?

The AuthorizeAttribute does work for authorization based on the role claim, but it sounds like your claims aren't being stored properly.

If this is the case, see this Form Post client (AccountController) or this OWIN/Katana client (Startup class) for good examples.

Also, roles should be considered and handled as a claim.

Thinktecture also have their own authorization manager package if you are interested. See Dominick Baier's blog post about this for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM