Skip to content
This repository has been archived by the owner on Dec 14, 2017. It is now read-only.

MVC OWIN Roles #9

Closed
jmichas opened this issue Oct 9, 2014 · 2 comments
Closed

MVC OWIN Roles #9

jmichas opened this issue Oct 9, 2014 · 2 comments
Labels

Comments

@jmichas
Copy link

jmichas commented Oct 9, 2014

How can I access the roles using the MVC OWIN middleware (UseOpenIdConnectAuthentication)?
I can see them coming through in the claims so they are read out of the token properly but Im not sure how I get them to a point where they can be used in the

[Authorize("RoleName")]

attribute.

I suspect it has something to do with the JwtSecurityTokenHandler.InboundClaimTypeMap, but I have no experience with this.

Is there an example you can point me to? Everything else seems to be working fine.

@jmichas
Copy link
Author

jmichas commented Oct 9, 2014

Well, I apologize for maybe posting prematurely. My suspicion was correct and a little trial and error and I figured it out. For anyone else looking to do this add this to your startup.auth

JwtSecurityTokenHandler.InboundClaimTypeMap = new Dictionary<string, string>
{
    {"role", System.Security.Claims.ClaimTypes.Role}
};

@brockallen
Copy link
Member

thanks for posting the follow-up. this will be useful for others that need to understand the mismatch between OIDC claims and WIF claims.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants