IdentityServer / IdentityServer3.Samples

Samples for IdentityServer v3
Apache License 2.0
610 stars 1.25k forks source link

ID_Token contains the claim but the Post Example doesn't parse the claim #343

Open hargrave81 opened 7 years ago

hargrave81 commented 7 years ago

I've been plugging away at this issue for a bit now. I have a claim that regardless of what scope I add the claim to, is not added to the list of claims for the logged in user using the MVC Form POST example project.

        var url = this.Request.GetOwinContext().Environment.GetIdentityServerBaseUrl() + "connect/authorize" +
            "?client_id=03fe9716-90d9-42bc-9d4a-136585e11e37" +
            "&response_type=id_token" +
            "&scope=openid email profile roles" +
            "&redirect_uri=" + this.Request.GetOwinContext().Environment.GetIdentityServerBaseUrl()  + "account" +
            "&response_mode=form_post" +
            "&state=" + state +
            "&nonce=" + nonce;

The server sees the need to include the claims (by default they were part of the roles scope, but I've tried other scopes like email). My claim name is superadmin. The JWT when you look at what is posted back to the MVC app contains the superadmin claim. It however isn't parsed.

public class AuthOwin : AuthorizeAttribute { protected override bool AuthorizeCore(HttpContextBase httpContext) {
var e = httpContext.GetOwinContext().Environment.GetIdentityServerFullLoginAsync().Result; } }

e.Claims does not contain the super admin claim. It has email, given_name, etc. But not my custom claim.

Suggestions?

brockallen commented 7 years ago

I'm not following exactly, but if you want a specific claim type then you need to add it to one of the scope definitions being requested.