|
|
|
@ -1,7 +1,10 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Security.Claims;
|
|
|
|
|
using System.Security.Principal;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
@ -26,6 +29,16 @@ public class OpenIddictClaimsPrincipalContributor : IAbpClaimsPrincipalContribut
|
|
|
|
|
identity.AddIfNotContains(new Claim(OpenIddictConstants.Claims.PreferredUsername, usernameClaim.Value));
|
|
|
|
|
identity.AddIfNotContains(new Claim(JwtRegisteredClaimNames.UniqueName, usernameClaim.Value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var httpContext = context.ServiceProvider.GetRequiredService<IHttpContextAccessor>().HttpContext;
|
|
|
|
|
if (httpContext != null)
|
|
|
|
|
{
|
|
|
|
|
var clientId = httpContext.GetOpenIddictServerRequest()?.ClientId;
|
|
|
|
|
if (clientId != null)
|
|
|
|
|
{
|
|
|
|
|
identity.AddClaim(OpenIddictConstants.Claims.ClientId, clientId, OpenIddictConstants.Destinations.AccessToken);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|