|
|
@ -1,5 +1,6 @@ |
|
|
using IdentityServer4.AspNetIdentity; |
|
|
using IdentityServer4.AspNetIdentity; |
|
|
using IdentityServer4.Models; |
|
|
using IdentityServer4.Models; |
|
|
|
|
|
using Microsoft.AspNetCore.Identity; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Security.Principal; |
|
|
using System.Security.Principal; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
@ -7,6 +8,7 @@ using Volo.Abp.Identity; |
|
|
using Volo.Abp.MultiTenancy; |
|
|
using Volo.Abp.MultiTenancy; |
|
|
using Volo.Abp.Security.Claims; |
|
|
using Volo.Abp.Security.Claims; |
|
|
using Volo.Abp.Uow; |
|
|
using Volo.Abp.Uow; |
|
|
|
|
|
using IdentityUser = Volo.Abp.Identity.IdentityUser; |
|
|
|
|
|
|
|
|
namespace LINGYUN.Abp.IdentityServer.AspNetIdentity |
|
|
namespace LINGYUN.Abp.IdentityServer.AspNetIdentity |
|
|
{ |
|
|
{ |
|
|
@ -15,7 +17,7 @@ namespace LINGYUN.Abp.IdentityServer.AspNetIdentity |
|
|
protected ICurrentTenant CurrentTenant { get; } |
|
|
protected ICurrentTenant CurrentTenant { get; } |
|
|
public AbpWeChatProfileServicee( |
|
|
public AbpWeChatProfileServicee( |
|
|
IdentityUserManager userManager, |
|
|
IdentityUserManager userManager, |
|
|
Microsoft.AspNetCore.Identity.IUserClaimsPrincipalFactory<IdentityUser> claimsFactory, |
|
|
IUserClaimsPrincipalFactory<IdentityUser> claimsFactory, |
|
|
ICurrentTenant currentTenant) |
|
|
ICurrentTenant currentTenant) |
|
|
: base(userManager, claimsFactory) |
|
|
: base(userManager, claimsFactory) |
|
|
{ |
|
|
{ |
|
|
@ -30,10 +32,8 @@ namespace LINGYUN.Abp.IdentityServer.AspNetIdentity |
|
|
await base.GetProfileDataAsync(context); |
|
|
await base.GetProfileDataAsync(context); |
|
|
|
|
|
|
|
|
// TODO: 可以从令牌获取openid, 安全性呢?
|
|
|
// TODO: 可以从令牌获取openid, 安全性呢?
|
|
|
if (context.RequestedClaimTypes.Any(rc => rc.Contains(WeChatClaimTypes.OpenId))) |
|
|
TryAddWeChatClaim(context, WeChatClaimTypes.OpenId); |
|
|
{ |
|
|
TryAddWeChatClaim(context, WeChatClaimTypes.UnionId); |
|
|
context.IssuedClaims.Add(context.Subject.FindFirst(WeChatClaimTypes.OpenId)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -45,5 +45,17 @@ namespace LINGYUN.Abp.IdentityServer.AspNetIdentity |
|
|
await base.IsActiveAsync(context); |
|
|
await base.IsActiveAsync(context); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual void TryAddWeChatClaim(ProfileDataRequestContext context, string weChatClaimType) |
|
|
|
|
|
{ |
|
|
|
|
|
if (context.RequestedClaimTypes.Any(rc => rc.Contains(weChatClaimType))) |
|
|
|
|
|
{ |
|
|
|
|
|
var weChatClaim = context.Subject.FindFirst(weChatClaimType); |
|
|
|
|
|
if (weChatClaim != null) |
|
|
|
|
|
{ |
|
|
|
|
|
context.IssuedClaims.Add(weChatClaim); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|