Reputation: 9113
We've been using Idsrv4 for about 2 years and we have successfully integrated with .Net Core Apis, .Net Core Apps. Now, we've got a legacy app which is costly to migrate to .Net Core from Net461.
I'm trying to integrate our .Net 461 MVC app with Identity Server 4 and I almost managed to integrate it successfully. But the issue is that, I don't know how to map non-standard claims to MVC App User Claims.
For example, in our claims, we've got special params like Country and custom_user_id. If I inspect the JwtAccessToken, I can see the values and I can confirm that the claims/scopes are working correct. But in UserClaims, they do not exist at all. I can only find the standard claims like sub, nbr, etc...
In .Net Core app, it's easy and we just need to use ClaimActions.MapUniqueJsonKey
like following:
services.AddOpenIdConnect("oidc", options =>
{
....
options.ClaimActions.MapUniqueJsonKey(JwtClaimTypes.Role, JwtClaimTypes.Role);
options.ClaimActions.MapUniqueJsonKey(Constants.CustomClaimTypes.Country, Constants.CustomClaimTypes.Country);
options.ClaimActions.MapUniqueJsonKey("custom_user_id", "custom_user_id");
options.ClaimActions.MapUniqueJsonKey("custom_company_id", "custom_company_id");
Could you please guide me how can I force OWIN library to get data from UserInfoEndpoint and map our custom claims to UserClaims?
I'm using OWIN library and my OWIN StartUp class looks like the following:
public void Configuration(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = xxxx,
ClientSecret = xxx,
Authority = Constants.Urls.IdentityServerProviderUrl,
......
Scope = PopulateScopes(), // custom method
SignInAsAuthenticationType = CookieAuthenticationDefaults.AuthenticationType,
ResponseType = OpenIdConnectResponseType.Code,
UseTokenLifetime = false,
RedeemCode = true,
SaveTokens = true,
TokenValidationParameters = new TokenValidationParameters()
{
ValidateIssuer = true
},
}
);
}
Upvotes: 1
Views: 553