I implemented OWIN bearer token authorization, and based on this article: http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/, and now i want to add roles to the bearer token so that i can be able retrieve it on the controller like am doing with the userName...identity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
and was able to get the username of the current user with User.Identity.Name
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- How to store image outside of the website's ro
- 'System.Threading.ThreadAbortException' in
- Request.PathInfo issues and XSS attacks
- How to dynamically load partial view Via jquery aj
相关文章
- asp.net HiddenField控件扩展问题
- asp.net HiddenField控件扩展问题
- Asp.Net网站无法写入错误日志,测试站点可以,正是站点不行
- asp.net mvc 重定向到vue hash字符串丢失
- FormsAuthenticationTicket expires too soon
- “Dynamic operations can only be performed in homog
- What is the best way to create a lock from a web a
- Add to htmlAttributes for custom ActionLink helper
http://forums.asp.net/t/1998896.aspx?Cannot+assign+claims+identity+to+a+variable+using+asp+net+WebAPI+with+Oauth+
http://nareshjois.com/custom-information-in-asp-net-identity-cookie-ticket/
i managed to add and read new roles manually by creating a new column in the asp identity
AspNetUsers
table named RoleName and i added roles directly...i then could read a role associated with each user like so
I PERSONALLY FIND THIS EASIER TO MAINTAIN...
You can add a function to do so.
Check my latest post on bitoftechwhere I read Roles once I generate token, or you can assign roles manually using the
ClaimsType.Role
like you assign the UserName. Hope this answers your question.