Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升级到 ABP 6.0.1 并支持 OpenIddict 实现 #54

Merged
merged 6 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
- name: dotnet build
run: dotnet build -c Release

- name: dotnet test
run: dotnet test -c Release --no-restore --no-build

- name: dotnet pack
run: dotnet pack -c Release --no-build -o dest

Expand All @@ -47,6 +50,7 @@ jobs:
del *.Host.Shared.*
del *.HttpApi.Host.*
del *.IdentityServer.*
del *.AuthServer.*
del *.Web.Host.*
del *.Web.Unified.*
del *.HttpApi.Client.ConsoleTestApp.*
Expand Down
10 changes: 1 addition & 9 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,4 @@ paket-files/

# JetBrains Rider
.idea/
*.sln.iml

# WeChatManagementSample
src/WeChatManagementSample.Web/Logs/*
src/WeChatManagementSample.Web.Host/Logs/*
src/WeChatManagementSample.IdentityServer/Logs/*
src/WeChatManagementSample.HttpApi.Host/Logs/*
src/WeChatManagementSample.HttpApi.HostWithIds/Logs/*
src/WeChatManagementSample.DbMigrator/Logs/*
*.sln.iml
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>

<AbpVersion>5.3.1</AbpVersion>
<EasyAbpAbpWeChatModuleVersion>1.9.2</EasyAbpAbpWeChatModuleVersion>
<AbpVersion>6.0.1</AbpVersion>
<EasyAbpAbpWeChatModuleVersion>1.10.1</EasyAbpAbpWeChatModuleVersion>

</PropertyGroup>
</Project>
32 changes: 30 additions & 2 deletions WeChatManagement.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeChatManagementSample.Appl
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeChatManagementSample.EntityFrameworkCore", "samples\WeChatManagementSample\aspnet-core\src\WeChatManagementSample.EntityFrameworkCore\WeChatManagementSample.EntityFrameworkCore.csproj", "{C956DD76-69C8-4A9C-83EA-D17DF83340FD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeChatManagementSample.Web", "samples\WeChatManagementSample\aspnet-core\src\WeChatManagementSample.Web\WeChatManagementSample.Web.csproj", "{068855E8-9240-4F1A-910B-CF825794513B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeChatManagementSample.Web.OpenIddict", "samples\WeChatManagementSample\aspnet-core\src\WeChatManagementSample.Web.OpenIddict\WeChatManagementSample.Web.OpenIddict.csproj", "{068855E8-9240-4F1A-910B-CF825794513B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{CA9AC87F-097E-4F15-8393-4BC07735A5B0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{04DBDB01-70F4-4E06-B468-8F87850B22BE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeChatManagementSample.Application.Tests", "samples\WeChatManagementSample\aspnet-core\test\WeChatManagementSample.Application.Tests\WeChatManagementSample.Application.Tests.csproj", "{50B2631D-129C-47B3-A587-029CCD6099BC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeChatManagementSample.Web.Tests", "samples\WeChatManagementSample\aspnet-core\test\WeChatManagementSample.Web.Tests\WeChatManagementSample.Web.Tests.csproj", "{5F1B28C6-8D0C-4155-92D0-252F7EA5F674}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeChatManagementSample.Web.Ids4.Tests", "samples\WeChatManagementSample\aspnet-core\test\WeChatManagementSample.Web.Ids4.Tests\WeChatManagementSample.Web.Ids4.Tests.csproj", "{5F1B28C6-8D0C-4155-92D0-252F7EA5F674}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WeChatManagementSample.Domain.Shared", "samples\WeChatManagementSample\aspnet-core\src\WeChatManagementSample.Domain.Shared\WeChatManagementSample.Domain.Shared.csproj", "{42F719ED-8413-4895-B5B4-5AB56079BC66}"
EndProject
Expand Down Expand Up @@ -115,6 +115,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyAbp.WeChatManagement.Co
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyAbp.WeChatManagement.Common.TestBase", "modules\Common\test\EasyAbp.WeChatManagement.Common.TestBase\EasyAbp.WeChatManagement.Common.TestBase.csproj", "{23D54D42-4626-43BE-8949-14B1965F24B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeChatManagementSample.Web.Ids4", "samples\WeChatManagementSample\aspnet-core\src\WeChatManagementSample.Web.Ids4\WeChatManagementSample.Web.Ids4.csproj", "{7710B6B3-6908-44C0-A343-1CB78A630C19}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeChatManagementSample.Web.OpenIddict.Tests", "samples\WeChatManagementSample\aspnet-core\test\WeChatManagementSample.Web.OpenIddict.Tests - 副本\WeChatManagementSample.Web.OpenIddict.Tests.csproj", "{A9F6AEDE-4F11-492B-87C0-20AEA340C5CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyAbp.WeChatManagement.MiniPrograms.Domain.OpenIddict", "modules\MiniPrograms\src\EasyAbp.WeChatManagement.MiniPrograms.Domain.OpenIddict\EasyAbp.WeChatManagement.MiniPrograms.Domain.OpenIddict.csproj", "{0B64E953-2865-47C2-A5C6-8E2E5A403A64}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EasyAbp.WeChatManagement.MiniPrograms.Domain.Ids4", "modules\MiniPrograms\src\EasyAbp.WeChatManagement.MiniPrograms.Domain.Ids4\EasyAbp.WeChatManagement.MiniPrograms.Domain.Ids4.csproj", "{AA8349BB-A8A6-4E4F-87CD-008E8D1BD0B8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -301,6 +309,22 @@ Global
{23D54D42-4626-43BE-8949-14B1965F24B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23D54D42-4626-43BE-8949-14B1965F24B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23D54D42-4626-43BE-8949-14B1965F24B4}.Release|Any CPU.Build.0 = Release|Any CPU
{7710B6B3-6908-44C0-A343-1CB78A630C19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7710B6B3-6908-44C0-A343-1CB78A630C19}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7710B6B3-6908-44C0-A343-1CB78A630C19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7710B6B3-6908-44C0-A343-1CB78A630C19}.Release|Any CPU.Build.0 = Release|Any CPU
{A9F6AEDE-4F11-492B-87C0-20AEA340C5CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9F6AEDE-4F11-492B-87C0-20AEA340C5CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9F6AEDE-4F11-492B-87C0-20AEA340C5CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9F6AEDE-4F11-492B-87C0-20AEA340C5CE}.Release|Any CPU.Build.0 = Release|Any CPU
{0B64E953-2865-47C2-A5C6-8E2E5A403A64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B64E953-2865-47C2-A5C6-8E2E5A403A64}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B64E953-2865-47C2-A5C6-8E2E5A403A64}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B64E953-2865-47C2-A5C6-8E2E5A403A64}.Release|Any CPU.Build.0 = Release|Any CPU
{AA8349BB-A8A6-4E4F-87CD-008E8D1BD0B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AA8349BB-A8A6-4E4F-87CD-008E8D1BD0B8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AA8349BB-A8A6-4E4F-87CD-008E8D1BD0B8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA8349BB-A8A6-4E4F-87CD-008E8D1BD0B8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -360,6 +384,10 @@ Global
{9B78FFE3-32AA-4EDA-8475-F931EA6171B1} = {32D52B09-3F02-4EA3-A295-977D364FCFC7}
{E793F3D2-5E8A-4281-9597-3F8EA14FA8E8} = {32D52B09-3F02-4EA3-A295-977D364FCFC7}
{23D54D42-4626-43BE-8949-14B1965F24B4} = {32D52B09-3F02-4EA3-A295-977D364FCFC7}
{7710B6B3-6908-44C0-A343-1CB78A630C19} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0}
{A9F6AEDE-4F11-492B-87C0-20AEA340C5CE} = {04DBDB01-70F4-4E06-B468-8F87850B22BE}
{0B64E953-2865-47C2-A5C6-8E2E5A403A64} = {BBF90359-754D-4BDB-8F3B-B01FFC426D88}
{AA8349BB-A8A6-4E4F-87CD-008E8D1BD0B8} = {BBF90359-754D-4BDB-8F3B-B01FFC426D88}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {28315BFD-90E7-4E14-A2EA-F3D23AF4126F}
Expand Down
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>1.3.5</Version>
<Version>1.4.0</Version>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Authors>EasyAbp Team</Authors>
Expand Down
41 changes: 36 additions & 5 deletions docs/MiniPrograms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![ABP version](https://img.shields.io/badge/dynamic/xml?style=flat-square&color=yellow&label=abp&query=%2F%2FProject%2FPropertyGroup%2FAbpVersion&url=https%3A%2F%2Fraw.githubusercontent.com%2FEasyAbp%2FWeChatManagement%2Fmaster%2FDirectory.Build.props)](https://abp.io)
[![小程序模块](https://img.shields.io/nuget/v/EasyAbp.WeChatManagement.MiniPrograms.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.WeChatManagement.MiniPrograms.Domain.Shared)
[![下载量](https://img.shields.io/nuget/dt/EasyAbp.WeChatManagement.MiniPrograms.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.WeChatManagement.MiniPrograms.Domain.Shared)
[![Discord online](https://badgen.net/discord/online-members/S6QaezrCRq?label=Discord)](https://discord.gg/S6QaezrCRq)
[![Discord online](https://badgen.net/discord/online-members/xyg8TrRa27?label=Discord)](https://discord.gg/xyg8TrRa27)
[![GitHub stars](https://img.shields.io/github/stars/EasyAbp/WeChatManagement?style=social)](https://www.github.com/EasyAbp/WeChatManagement)

Abp 小程序管理模块,提供小程序登录、用户个人信息记录、小程序微信服务器等功能,自动适应微信开放平台规则,与微信第三方平台模块轻松衔接。
Expand All @@ -18,7 +18,8 @@ We have launched an online demo for this module: [https://wechat.samples.easyabp

* EasyAbp.WeChatManagement.MiniPrograms.Application
* EasyAbp.WeChatManagement.MiniPrograms.Application.Contracts
* EasyAbp.WeChatManagement.MiniPrograms.Domain
* (2选1) EasyAbp.WeChatManagement.MiniPrograms.Domain.OpenIddict
* (2选1) EasyAbp.WeChatManagement.MiniPrograms.Domain.Ids4
* EasyAbp.WeChatManagement.MiniPrograms.Domain.Shared
* EasyAbp.WeChatManagement.MiniPrograms.EntityFrameworkCore
* EasyAbp.WeChatManagement.MiniPrograms.HttpApi
Expand All @@ -33,9 +34,39 @@ We have launched an online demo for this module: [https://wechat.samples.easyabp

1. Add EF Core migrations and update your database. See: [ABP document](https://docs.abp.io/en/abp/latest/Tutorials/Part-1?UI=MVC&DB=EF#add-database-migration).

1. 在 Web / HttpApi.Host 启动项目的 appsettings.json 的 AuthServer 中增加 `ClientId` 和 `ClientSecret` 配置(可使用文件中 IdentityServer 中的配置)。

1. 在 IdentityServerClientGrantTypes 表中给上一步使用的 Client 增加一条 `WeChatMiniProgram_credentials` 的 GrantType.
1. 在启动项目的 appsettings.json 中增加微信登录授权服务器配置:
```json
{
"WeChatManagement": {
"MiniPrograms": {
"AuthServer": {
"Authority": "https://localhost:44380",
"ClientId": "MyProjectName_WeChatMiniProgram",
"ClientSecret": "1q2w3e*"
}
}
}
}
```

1. 在 OpenIddictDataSeedContributor 中增加新的客户端 Data Seed (你也可以使用 [IDS4](https://github.com/EasyAbp/WeChatManagement/blob/master/samples/WeChatManagementSample/aspnet-core/src/WeChatManagementSample.Domain/IdentityServer/IdentityServerDataSeedContributor.cs)):
```CSharp
// WeChat MiniProgram PC Login
var weChatMiniProgramPcLoginClientId =
configurationSection["MyProjectName_WeChatMiniProgram:ClientId"];

if (!weChatMiniProgramPcLoginClientId.IsNullOrWhiteSpace())
{
await CreateClientAsync(
weChatMiniProgramPcLoginClientId,
commonScopes,
new[] { "refresh_token", WeChatMiniProgramConsts.GrantType },
(configurationSection["MyProjectName_WeChatMiniProgram:ClientSecret"] ?? "1q2w3e*").Sha256()
);
}
```

1. 运行 DbMigrator 项目,以创建新的授权客户端。

## Usage

Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![ABP version](https://img.shields.io/badge/dynamic/xml?style=flat-square&color=yellow&label=abp&query=%2F%2FProject%2FPropertyGroup%2FAbpVersion&url=https%3A%2F%2Fraw.githubusercontent.com%2FEasyAbp%2FWeChatManagement%2Fmaster%2FDirectory.Build.props)](https://abp.io)
[![NuGet](https://img.shields.io/nuget/v/EasyAbp.WeChatManagement.Common.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.WeChatManagement.Common.Domain.Shared)
[![NuGet Download](https://img.shields.io/nuget/dt/EasyAbp.WeChatManagement.Common.Domain.Shared.svg?style=flat-square)](https://www.nuget.org/packages/EasyAbp.WeChatManagement.Common.Domain.Shared)
[![Discord online](https://badgen.net/discord/online-members/S6QaezrCRq?label=Discord)](https://discord.gg/S6QaezrCRq)
[![Discord online](https://badgen.net/discord/online-members/xyg8TrRa27?label=Discord)](https://discord.gg/xyg8TrRa27)
[![GitHub stars](https://img.shields.io/github/stars/EasyAbp/WeChatManagement?style=social)](https://www.github.com/EasyAbp/WeChatManagement)

基于[EasyAbp.Abp.WeChat](https://github.com/EasyAbp/Abp.WeChat)模块实现微信登录、微信用户信息存储、微信服务器管理、微信第三方平台等高级功能的Abp应用模块组
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using EasyAbp.Abp.WeChat;
using EasyAbp.Abp.WeChat.MiniProgram;
using EasyAbp.Abp.WeChat.MiniProgram.Services.ACode;
using EasyAbp.Abp.WeChat.MiniProgram.Services.Login;
Expand All @@ -18,6 +17,7 @@
using EasyAbp.Abp.WeChat.MiniProgram.Infrastructure.OptionsResolve.Contributors;
using EasyAbp.WeChatManagement.Common.WeChatApps;
using EasyAbp.WeChatManagement.Common.WeChatAppUsers;
using Volo.Abp;
using Volo.Abp.Caching;
using Volo.Abp.Data;
using Volo.Abp.Domain.Repositories;
Expand Down Expand Up @@ -145,6 +145,7 @@ public virtual async Task UnbindAsync(LoginInput input)
}
}

[UnitOfWork(IsDisabled = true)]
public virtual async Task<LoginOutput> LoginAsync(LoginInput input)
{
var loginResult = await GetLoginResultAsync(input);
Expand All @@ -168,12 +169,12 @@ await UpdateWeChatAppUserAsync(identityUser, loginResult.MiniProgram, loginResul
await uow.CompleteAsync();
}

var response = await RequestIds4LoginAsync(input.AppId, loginResult.UnionId,
var response = await RequestAuthServerLoginAsync(input.AppId, loginResult.UnionId,
loginResult.Code2SessionResponse.OpenId);

if (response.IsError)
{
throw response.Exception;
throw response.Exception ?? new AbpException(response.Raw);
}

return new LoginOutput
Expand Down Expand Up @@ -278,7 +279,7 @@ protected virtual async Task<LoginResultInfoModel> GetLoginResultAsync(LoginInpu

public virtual async Task<string> RefreshAsync(RefreshInput input)
{
return (await RequestIds4RefreshAsync(input.RefreshToken))?.Raw;
return (await RequestAuthServerRefreshAsync(input.RefreshToken))?.Raw;
}

protected virtual async Task UpdateWeChatAppUserAsync(IdentityUser identityUser, WeChatApp miniProgram, string unionId, string openId, string sessionKey)
Expand Down Expand Up @@ -340,17 +341,17 @@ protected virtual async Task TryRemoveUserInfoAsync(IdentityUser identityUser)
}
}

protected virtual async Task<TokenResponse> RequestIds4LoginAsync(string appId, string unionId, string openId)
protected virtual async Task<TokenResponse> RequestAuthServerLoginAsync(string appId, string unionId, string openId)
{
var client = _httpClientFactory.CreateClient(WeChatMiniProgramConsts.IdentityServerHttpClientName);
var client = _httpClientFactory.CreateClient(WeChatMiniProgramConsts.AuthServerHttpClientName);

var request = new TokenRequest
{
Address = _configuration["AuthServer:Authority"] + "/connect/token",
Address = _configuration["WeChatManagement:MiniPrograms:AuthServer:Authority"] + "/connect/token",
GrantType = WeChatMiniProgramConsts.GrantType,

ClientId = _configuration["AuthServer:ClientId"],
ClientSecret = _configuration["AuthServer:ClientSecret"],
ClientId = _configuration["WeChatManagement:MiniPrograms:AuthServer:ClientId"],
ClientSecret = _configuration["WeChatManagement:MiniPrograms:AuthServer:ClientSecret"],

Parameters =
{
Expand All @@ -365,16 +366,16 @@ protected virtual async Task<TokenResponse> RequestIds4LoginAsync(string appId,
return await client.RequestTokenAsync(request);
}

protected virtual async Task<TokenResponse> RequestIds4RefreshAsync(string refreshToken)
protected virtual async Task<TokenResponse> RequestAuthServerRefreshAsync(string refreshToken)
{
var client = _httpClientFactory.CreateClient(WeChatMiniProgramConsts.IdentityServerHttpClientName);
var client = _httpClientFactory.CreateClient(WeChatMiniProgramConsts.AuthServerHttpClientName);

var request = new RefreshTokenRequest
{
Address = _configuration["AuthServer:Authority"] + "/connect/token",
Address = _configuration["WeChatManagement:MiniPrograms:AuthServer:Authority"] + "/connect/token",

ClientId = _configuration["AuthServer:ClientId"],
ClientSecret = _configuration["AuthServer:ClientSecret"],
ClientId = _configuration["WeChatManagement:MiniPrograms:AuthServer:ClientId"],
ClientSecret = _configuration["WeChatManagement:MiniPrograms:AuthServer:ClientSecret"],

RefreshToken = refreshToken
};
Expand Down Expand Up @@ -495,7 +496,7 @@ public virtual async Task<PcLoginRequestTokensOutput> PcLoginRequestTokensAsync(

await _pcLoginAuthorizationCache.RemoveAsync(input.Token);

var response = await RequestIds4LoginAsync(cacheItem.AppId, cacheItem.UnionId,
var response = await RequestAuthServerLoginAsync(cacheItem.AppId, cacheItem.UnionId,
cacheItem.OpenId);

if (response.IsError)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void ConfigureServices(ServiceConfigurationContext context)
options.AddMaps<WeChatManagementMiniProgramsApplicationModule>(validate: true);
});

context.Services.AddHttpClient(WeChatMiniProgramConsts.IdentityServerHttpClientName, c =>
context.Services.AddHttpClient(WeChatMiniProgramConsts.AuthServerHttpClientName, c =>
{
c.Timeout = TimeSpan.FromMilliseconds(5000);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="..\..\..\..\common.props" />

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Volo.Abp.IdentityServer.Domain" Version="$(AbpVersion)" />
<ProjectReference Include="..\EasyAbp.WeChatManagement.MiniPrograms.Domain\EasyAbp.WeChatManagement.MiniPrograms.Domain.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.IdentityServer;
using Volo.Abp.Modularity;

namespace EasyAbp.WeChatManagement.MiniPrograms;

[DependsOn(
typeof(AbpIdentityServerDomainModule),
typeof(WeChatManagementMiniProgramsDomainModule)
)]
public class WeChatManagementMiniProgramsDomainIds4Module : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
context.Services.PreConfigure<IIdentityServerBuilder>(builder =>
{
builder.AddExtensionGrantValidator<WeChatMiniProgramGrantValidator>();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ public virtual async Task ValidateAsync(ExtensionGrantValidationContext context)
var claims = new List<Claim>
{
// 记录 appid
new Claim("appid", appId)
new("appid", appId)
};

if (identityUser.TenantId.HasValue)
{
claims.Add(new Claim(AbpClaimTypes.TenantId, identityUser.TenantId?.ToString()));
claims.Add(new Claim(AbpClaimTypes.TenantId, identityUser.TenantId?.ToString() ?? string.Empty));
}

claims.AddRange(identityUser.Claims.Select(item => new Claim(item.ClaimType, item.ClaimValue)));
Expand Down
Loading