<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D51Y0000ATxAL1SQNOkta Classic EngineSingle Sign-OnAnswered2021-02-22T00:23:19.000Z2021-02-17T05:20:16.000Z2021-02-22T00:23:19.000Z

JoshH.59428 (Customer) asked a question.

Mapping Roles in .NET Hosted Blazor Solution

I have a .NET 5.0 (upgraded from .NET Core) hosted Blazor solution integrated with Okta.

 

I am able to log in without issue, but when I am redirected back to my app I'm running into an issue mapping roles to claims.

 

```crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]

   Unhandled exception rendering component: InvalidOperation_EnumFailedVersion

System.InvalidOperationException: InvalidOperation_EnumFailedVersion

  at System.Collections.Generic.List`1.Enumerator[[System.Security.Claims.Claim, System.Security.Claims, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNextRare()

  at System.Collections.Generic.List`1.Enumerator[[System.Security.Claims.Claim, System.Security.Claims, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].MoveNext()

  at System.Security.Claims.ClaimsIdentity.FindAll(Predicate`1 match)+MoveNext()

  at WFBC.Client.RolesClaimsPrincipalFactory.CreateUserAsync(RemoteUserAccount account, RemoteAuthenticationUserOptions options)

  at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService`3.<GetAuthenticatedUser>d__26[[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationState, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=5.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteUserAccount, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=5.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[Microsoft.AspNetCore.Components.WebAssembly.Authentication.OidcProviderOptions, Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=5.0.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()```

 

The error is being thrown here:

 

```      foreach (var existingClaim in roleClaims)

      {

        identity.RemoveClaim(existingClaim);

      }````

 

The only info I've been able to find seems to point to attempting to modify an IEnumerable, but in this case I am not. roleClaims is an IEnumerable, but identity is a ClaimsIdentity object.

 

This was working previously, so I'm not sure if it's caused by the .NET 5.0 upgrade or some changes to the Okta nuget packages. Unfortunately Blazor debugging into the client project is far from production ready, and not working for me currently.


This question is closed.
Loading
Mapping Roles in .NET Hosted Blazor Solution