<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Role Claims Issue with OpenIdConnect netcore5]]></title><description><![CDATA[<p dir="auto">FA Team, I have been working on a netcore 5 application using FusionAuth with the OpenIdConnect middelware (nearly an exact clone of the demo app found at <a href="https://github.com/FusionAuth/fusionauth-example-asp-netcore5" rel="nofollow ugc">https://github.com/FusionAuth/fusionauth-example-asp-netcore5</a>). When I inspect the JWT access token that comes back from the token call, I can see the roles in the decrypted token:</p>
<p dir="auto"><img src="https://i.ibb.co/c3hbPQv/example.jpg" alt="alt text" class=" img-fluid img-markdown" /></p>
<p dir="auto">However, when it is parsed into user claims by the middleware I'm not seeing the roles:</p>
<p dir="auto"><img src="https://i.ibb.co/F7vtvzd/example2.jpg" alt="alt text" class=" img-fluid img-markdown" /></p>
<p dir="auto">Even though according to this blog post they should come along for the ride automatically:<br />
<a href="https://fusionauth.io/blog/2020/05/27/sharing-custom-oauth-claims-with-a-asp-netcore-app/" rel="nofollow ugc">https://fusionauth.io/blog/2020/05/27/sharing-custom-oauth-claims-with-a-asp-netcore-app/</a></p>
<p dir="auto">Has anyone else run into this problem? I think this almost has to be a bug withing fusion auth or a mis-configuration of our deployment because I even pulled the aforementioned demo project and just put our deployment credentials into the appsettings and the roles did not come through either.</p>
]]></description><link>https://fusionauth.io/community/forum/topic/1485/role-claims-issue-with-openidconnect-netcore5</link><generator>RSS for Node</generator><lastBuildDate>Mon, 05 Oct 2026 11:17:39 GMT</lastBuildDate><atom:link href="https://fusionauth.io/community/forum/topic/1485.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 Jan 2022 20:00:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Role Claims Issue with OpenIdConnect netcore5 on Thu, 27 Jan 2022 00:17:00 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for sharing this! I'm glad you figured it out. I'll add a note to the sample application pointing to this forum post.</p>
]]></description><link>https://fusionauth.io/community/forum/post/4271</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/4271</guid><dc:creator><![CDATA[dan]]></dc:creator><pubDate>Thu, 27 Jan 2022 00:17:00 GMT</pubDate></item><item><title><![CDATA[Reply to Role Claims Issue with OpenIdConnect netcore5 on Wed, 26 Jan 2022 17:51:25 GMT]]></title><description><![CDATA[<p dir="auto">For anyone else that runs into this issue. The resolution was as follows:</p>
<p dir="auto">I needed to include the following code in my ConfigureServices mehtod:</p>
<pre><code>options.GetClaimsFromUserInfoEndpoint = true; 
options.ClaimActions.MapAll();
options.ClaimActions.Add(new RoleClaimAction());
</code></pre>
<p dir="auto">The first line brings the roles claim over, but the values are still in a string array, and do not get automatically parsed into the ClaimPrincipal as a claim.</p>
<p dir="auto">The second line maps all of the JWT properties to claims. This could probably be refactored to only map the roles property if needed.</p>
<p dir="auto">The third line takes the string array in the "roles" claim and splits them into individual "role" claims so that you can properly use the User.InRole() methods or set up custom auth policies based on user roles.</p>
<p dir="auto">Here is the code for the custom RoleClaimAction class:</p>
<pre><code>public class RoleClaimAction : ClaimAction
    {
        private const string RoleClaimType = "roles";

        public RoleClaimAction() : base(RoleClaimType, ClaimValueTypes.String)
        {
        }
    
        public override void Run(JsonElement userData, ClaimsIdentity identity, string issuer)
        {
            //Map array of roles to separate role claims
            if (userData.TryGetProperty(RoleClaimType, out var roles))
            {
                if (roles.ValueKind == JsonValueKind.Array)
                {
                    var enumerator = roles.EnumerateArray();
                    while (enumerator.MoveNext())
                    {
                        AddRoleClaim(identity, enumerator.Current.ToString(), issuer);
                    }   
                }else if(roles.ValueKind == JsonValueKind.String)
                {
                    AddRoleClaim(identity, roles.ToString(), issuer);
                }

            };
        }

        private void AddRoleClaim(ClaimsIdentity identity, string role, string issuer)
        {
            identity.AddClaim(new Claim(ClaimTypes.Role, role, ClaimValueTypes.String, issuer));
        }
    }
</code></pre>
]]></description><link>https://fusionauth.io/community/forum/post/4270</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/4270</guid><dc:creator><![CDATA[devteam]]></dc:creator><pubDate>Wed, 26 Jan 2022 17:51:25 GMT</pubDate></item><item><title><![CDATA[Reply to Role Claims Issue with OpenIdConnect netcore5 on Tue, 25 Jan 2022 23:36:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/645">@joshua</a> So I think I may have stumbled across something... it looks like the claims are being generated off of the security token and not the access token. When I decode the security token, the claims match 1-1 with what is in the token. When I decode the access token, that is where I'm seeing the roles added. Is there a configuration setting inside of fusion auth to attach the roles to the security token?</p>
]]></description><link>https://fusionauth.io/community/forum/post/4262</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/4262</guid><dc:creator><![CDATA[devteam]]></dc:creator><pubDate>Tue, 25 Jan 2022 23:36:08 GMT</pubDate></item><item><title><![CDATA[Reply to Role Claims Issue with OpenIdConnect netcore5 on Tue, 25 Jan 2022 18:45:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/645">@joshua</a> I tried removing that claim already, but it doesn't appear to be the issue.</p>
]]></description><link>https://fusionauth.io/community/forum/post/4251</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/4251</guid><dc:creator><![CDATA[devteam]]></dc:creator><pubDate>Tue, 25 Jan 2022 18:45:06 GMT</pubDate></item><item><title><![CDATA[Reply to Role Claims Issue with OpenIdConnect netcore5 on Mon, 24 Jan 2022 21:27:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://fusionauth.io/community/forum/uid/1348">@devteam</a></p>
<p dir="auto">I did a search briefly and one possibility is that the claims are being modified by the ASP middleware.</p>
<p dir="auto">This is adjacent, but similar SO post regarding.</p>
<p dir="auto"><a href="https://stackoverflow.com/questions/69289426/missing-aud-claim-in-asp-net-core-policy-check-prevents-authorization-but-it" rel="nofollow ugc">https://stackoverflow.com/questions/69289426/missing-aud-claim-in-asp-net-core-policy-check-prevents-authorization-but-it</a></p>
<p dir="auto">I will let you know if I discover anything else.</p>
<p dir="auto">Thanks,<br />
Josh</p>
]]></description><link>https://fusionauth.io/community/forum/post/4249</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/4249</guid><dc:creator><![CDATA[joshua]]></dc:creator><pubDate>Mon, 24 Jan 2022 21:27:17 GMT</pubDate></item></channel></rss>