Browse Source

feat(cloud-tencent): support qq connect.

pull/501/head
cKey 4 years ago
parent
commit
ff0b13c6c6
  1. 16
      aspnet-core/LINGYUN.MicroService.All.sln
  2. 29
      aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/LINGYUN/Abp/Aliyun/SettingManagement/AliyunSettingAppService.cs
  3. 18
      aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/en.json
  4. 18
      aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/zh-Hans.json
  5. 36
      aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Settings/AliyunSettingNames.cs
  6. 94
      aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Settings/AliyunSettingProvider.cs
  7. 8
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN.Abp.Sms.Tencent.csproj
  8. 12
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN/Abp/Sms/Tencent/Localization/Resources/en.json
  9. 12
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN/Abp/Sms/Tencent/Localization/Resources/zh-Hans.json
  10. 23
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN/Abp/Sms/Tencent/Settings/TencentCloudSmsSettingNames.cs
  11. 12
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN/Abp/Sms/Tencent/TencentCloudSmsSender.cs
  12. 3
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/FodyWeavers.xml
  13. 30
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/FodyWeavers.xsd
  14. 19
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN.Abp.Tencent.QQ.csproj
  15. 30
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/AbpTencentQQCacheItem.cs
  16. 28
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/AbpTencentQQModule.cs
  17. 23
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/AbpTencentQQOptions.cs
  18. 24
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/AbpTencentQQOptionsFactory.cs
  19. 57
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/AbpTencentQQOptionsManager.cs
  20. 13
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Localization/en.json
  21. 13
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Localization/zh-Hans.json
  22. 50
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Settings/TencentQQSettingDefinitionProvider.cs
  23. 16
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Settings/TencentQQSettingNames.cs
  24. 1
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN.Abp.Tencent.SettingManagement.csproj
  25. 40
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN/Abp/Tencent/SettingManagement/TenantCloudSettingAppService.cs
  26. 7
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Localization/Resources/en.json
  27. 7
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Localization/Resources/zh-Hans.json
  28. 116
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Settings/TencentCloudSettingDefinitionProvider.cs
  29. 18
      aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Settings/TencentCloudSettingNames.cs
  30. 25
      aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs
  31. 16
      aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/Localization/Resources/en.json
  32. 16
      aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/Localization/Resources/zh-Hans.json
  33. 43
      aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/Settings/AliyunSmsSettingNames.cs
  34. 109
      aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/Settings/AliyunSmsSettingProvider.cs
  35. 3
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/FodyWeavers.xml
  36. 30
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/FodyWeavers.xsd
  37. 3
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/FodyWeavers.xml
  38. 30
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/FodyWeavers.xsd
  39. 19
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/LINGYUN.Abp.IdentityServer.QQ.csproj
  40. 8
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/LINGYUN/Abp/IdentityServer/QQ/AbpIdentityServerQQConsts.cs
  41. 19
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/LINGYUN/Abp/IdentityServer/QQ/AbpIdentityServerQQModule.cs
  42. 31
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/LINGYUN/Abp/IdentityServer/QQ/AbpQQClaimTypes.cs
  43. 175
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/Microsoft/AspNetCore/Authentication/QQ/QQConnectOAuthHandler.cs
  44. 47
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/Microsoft/AspNetCore/Authentication/QQ/QQConnectOAuthOptions.cs
  45. 63
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/Microsoft/AspNetCore/Authentication/QQAuthenticationExtensions.cs
  46. 16
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/System/BytesExtensions.cs
  47. 17
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/System/StringExtensions.cs
  48. 63
      aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/System/Text/Json/JsonElementExtensions.cs
  49. 2
      aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs
  50. 1
      aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj
  51. 2
      aspnet-core/services/LY.MicroService.identityServer/Properties/launchSettings.json
  52. 5
      build/modules.dependencies.json

16
aspnet-core/LINGYUN.MicroService.All.sln

@ -380,7 +380,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.BlobStoring.Ten
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.OssManagement.Tencent", "modules\oss-management\LINGYUN.Abp.OssManagement.Tencent\LINGYUN.Abp.OssManagement.Tencent.csproj", "{31E60E23-FD98-4D5E-A137-2B3F2968BA09}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.IdentityServer.LinkUser", "modules\identityServer\LINGYUN.Abp.IdentityServer.LinkUser\LINGYUN.Abp.IdentityServer.LinkUser.csproj", "{25378F9D-2A66-4568-AAC6-E9282ACA3DD3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.IdentityServer.LinkUser", "modules\identityServer\LINGYUN.Abp.IdentityServer.LinkUser\LINGYUN.Abp.IdentityServer.LinkUser.csproj", "{25378F9D-2A66-4568-AAC6-E9282ACA3DD3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.IdentityServer.QQ", "modules\identityServer\LINGYUN.Abp.IdentityServer.QQ\LINGYUN.Abp.IdentityServer.QQ.csproj", "{A34CCD3F-28A1-4BAD-A995-EB8720CE4105}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Tencent.QQ", "modules\cloud-tencent\LINGYUN.Abp.Tencent.QQ\LINGYUN.Abp.Tencent.QQ.csproj", "{3FCB1BCD-34BC-4F66-968F-38DB28371D0F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -988,6 +992,14 @@ Global
{25378F9D-2A66-4568-AAC6-E9282ACA3DD3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{25378F9D-2A66-4568-AAC6-E9282ACA3DD3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{25378F9D-2A66-4568-AAC6-E9282ACA3DD3}.Release|Any CPU.Build.0 = Release|Any CPU
{A34CCD3F-28A1-4BAD-A995-EB8720CE4105}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A34CCD3F-28A1-4BAD-A995-EB8720CE4105}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A34CCD3F-28A1-4BAD-A995-EB8720CE4105}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A34CCD3F-28A1-4BAD-A995-EB8720CE4105}.Release|Any CPU.Build.0 = Release|Any CPU
{3FCB1BCD-34BC-4F66-968F-38DB28371D0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FCB1BCD-34BC-4F66-968F-38DB28371D0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FCB1BCD-34BC-4F66-968F-38DB28371D0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FCB1BCD-34BC-4F66-968F-38DB28371D0F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1174,6 +1186,8 @@ Global
{A4B972EC-9F0B-4405-9965-766FABC9B07E} = {3B96F4D8-4993-419B-BCEB-AFE4ED39449F}
{31E60E23-FD98-4D5E-A137-2B3F2968BA09} = {B05CB08F-C088-4D6D-97EE-A94A5D1AE4A6}
{25378F9D-2A66-4568-AAC6-E9282ACA3DD3} = {0439B173-F41E-4CE0-A44A-CCB70328F272}
{A34CCD3F-28A1-4BAD-A995-EB8720CE4105} = {0439B173-F41E-4CE0-A44A-CCB70328F272}
{3FCB1BCD-34BC-4F66-968F-38DB28371D0F} = {3B96F4D8-4993-419B-BCEB-AFE4ED39449F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C95FDF91-16F2-4A8B-A4BE-0E62D1B66718}

29
aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun.SettingManagement/LINGYUN/Abp/Aliyun/SettingManagement/AliyunSettingAppService.cs

@ -1,7 +1,6 @@
using LINGYUN.Abp.Aliyun.Localization;
using LINGYUN.Abp.Aliyun.Settings;
using LINGYUN.Abp.SettingManagement;
using LINGYUN.Abp.Sms.Aliyun.Settings;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Authorization.Permissions;
@ -106,45 +105,45 @@ namespace LINGYUN.Abp.Aliyun.SettingManagement
var smsSetting = aliyunSettingGroup.AddSetting(L["DisplayName:Aliyun.Sms"], L["Description:Aliyun.Sms"]);
smsSetting.AddDetail(
SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.Domain),
SettingDefinitionManager.Get(AliyunSettingNames.Sms.Domain),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.Domain, providerName, providerKey),
await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.Domain, providerName, providerKey),
ValueType.String,
providerName);
smsSetting.AddDetail(
SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.Version),
SettingDefinitionManager.Get(AliyunSettingNames.Sms.Version),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.Version, providerName, providerKey),
await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.Version, providerName, providerKey),
ValueType.String,
providerName);
smsSetting.AddDetail(
SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.ActionName),
SettingDefinitionManager.Get(AliyunSettingNames.Sms.ActionName),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.ActionName, providerName, providerKey),
await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.ActionName, providerName, providerKey),
ValueType.String,
providerName);
smsSetting.AddDetail(
SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.DefaultPhoneNumber),
SettingDefinitionManager.Get(AliyunSettingNames.Sms.DefaultPhoneNumber),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultPhoneNumber, providerName, providerKey),
await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.DefaultPhoneNumber, providerName, providerKey),
ValueType.String,
providerName);
smsSetting.AddDetail(
SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.DefaultSignName),
SettingDefinitionManager.Get(AliyunSettingNames.Sms.DefaultSignName),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultSignName, providerName, providerKey),
await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.DefaultSignName, providerName, providerKey),
ValueType.String,
providerName);
smsSetting.AddDetail(
SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.DefaultTemplateCode),
SettingDefinitionManager.Get(AliyunSettingNames.Sms.DefaultTemplateCode),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultTemplateCode, providerName, providerKey),
await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.DefaultTemplateCode, providerName, providerKey),
ValueType.String,
providerName);
smsSetting.AddDetail(
SettingDefinitionManager.Get(AliyunSmsSettingNames.Sms.VisableErrorToClient),
SettingDefinitionManager.Get(AliyunSettingNames.Sms.VisableErrorToClient),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(AliyunSmsSettingNames.Sms.VisableErrorToClient, providerName, providerKey),
await SettingManager.GetOrNullAsync(AliyunSettingNames.Sms.VisableErrorToClient, providerName, providerKey),
ValueType.Boolean,
providerName);

18
aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/en.json

@ -20,6 +20,22 @@
"DisplayName:DurationSeconds": "Duration Seconds,in seconds",
"Description:DurationSeconds": "Duration Seconds,in seconds",
"DisplayName:Policy": "Policy",
"Description:Policy": "Policy"
"Description:Policy": "Policy",
"DisplayName:Aliyun.Sms": "Sms",
"Description:Aliyun.Sms": "Sms",
"DisplayName:ActionName": "Action Name",
"Description:ActionName": "Action Name",
"DisplayName:DefaultSignName": "Default Sign Name",
"Description:DefaultSignName": "Default Sign Name",
"DisplayName:DefaultTemplateCode": "Default Template Code",
"Description:DefaultTemplateCode": "Default Template Code",
"DisplayName:DefaultPhoneNumber": "Default Phone Number",
"Description:DefaultPhoneNumber": "Default Phone Number",
"DisplayName:Domain": "Domain",
"Description:Domain": "Domain",
"DisplayName:Version": "Version",
"Description:Version": "Version",
"DisplayName:VisableErrorToClient": "Visable Error To Client",
"Description:VisableErrorToClient": "Visable Error To Client"
}
}

18
aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Localization/Resources/zh-Hans.json

@ -20,6 +20,22 @@
"DisplayName:DurationSeconds": "过期时间,单位为秒。",
"Description:DurationSeconds": "过期时间最小值为900秒,默认3600秒",
"DisplayName:Policy": "权限策略",
"Description:Policy": "生成STS Token时可以指定一个额外的权限策略,以进一步限制STS Token的权限"
"Description:Policy": "生成STS Token时可以指定一个额外的权限策略,以进一步限制STS Token的权限",
"DisplayName:Aliyun.Sms": "短信服务",
"Description:Aliyun.Sms": "阿里云短信服务",
"DisplayName:ActionName": "发送短信方法",
"Description:ActionName": "发送短信方法名称,详情见阿里云Sms服务",
"DisplayName:DefaultSignName": "默认短信签名",
"Description:DefaultSignName": "当用户未指定短信签名时的默认签名名称",
"DisplayName:DefaultTemplateCode": "默认短信模板号",
"Description:DefaultTemplateCode": "当用户未指定短信签名时的默认短信模板号",
"DisplayName:DefaultPhoneNumber": "默认接收短信手机号",
"Description:DefaultPhoneNumber": "当用户未指定短信接收方时的默认接收手机号码",
"DisplayName:Domain": "阿里云sms服务域名",
"Description:Domain": "阿里云sms服务域名",
"DisplayName:Version": "阿里云sms服务版本号",
"Description:Version": "阿里云sms服务版本号",
"DisplayName:VisableErrorToClient": "发送错误到客户端",
"Description:VisableErrorToClient": "当短信服务发送出现错误时是否发送错误详情到客户端"
}
}

36
aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Settings/AliyunSettingNames.cs

@ -43,5 +43,41 @@
/// </summary>
public const string Policy = Prefix + ".Policy";
}
/// <summary>
/// 短信服务
/// </summary>
public class Sms
{
public const string Prefix = AliyunSettingNames.Prefix + ".Sms";
/// <summary>
/// 阿里云sms服务域名
/// </summary>
public const string Domain = Prefix + ".Domain";
/// <summary>
/// 调用方法名称
/// </summary>
public const string ActionName = Prefix + ".ActionName";
/// <summary>
/// 默认版本号
/// </summary>
public const string Version = Prefix + ".Version";
/// <summary>
/// 默认签名
/// </summary>
public const string DefaultSignName = Prefix + ".DefaultSignName";
/// <summary>
/// 默认短信模板号
/// </summary>
public const string DefaultTemplateCode = Prefix + ".DefaultTemplateCode";
/// <summary>
/// 默认号码
/// </summary>
public const string DefaultPhoneNumber = Prefix + ".DefaultPhoneNumber";
/// <summary>
/// 展示错误给客户端
/// </summary>
public const string VisableErrorToClient = Prefix + ".VisableErrorToClient";
}
}
}

94
aspnet-core/modules/cloud-aliyun/LINGYUN.Abp.Aliyun/LINGYUN/Abp/Aliyun/Settings/AliyunSettingProvider.cs

@ -8,10 +8,11 @@ namespace LINGYUN.Abp.Aliyun.Settings
{
public override void Define(ISettingDefinitionContext context)
{
context.Add(CreateAliyunSettings());
context.Add(GetAuthorizationSettings());
context.Add(GetSmsSettings());
}
private SettingDefinition[] CreateAliyunSettings()
private SettingDefinition[] GetAuthorizationSettings()
{
return new SettingDefinition[]
{
@ -113,6 +114,95 @@ namespace LINGYUN.Abp.Aliyun.Settings
};
}
private SettingDefinition[] GetSmsSettings()
{
return new SettingDefinition[]
{
new SettingDefinition(
AliyunSettingNames.Sms.ActionName,
defaultValue: "SendSms",
displayName: L("DisplayName:ActionName"),
description: L("Description:ActionName"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSettingNames.Sms.DefaultSignName,
displayName: L("DisplayName:DefaultSignName"),
description: L("Description:DefaultSignName"),
isVisibleToClients: false,
isEncrypted: true
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSettingNames.Sms.DefaultTemplateCode,
displayName: L("DisplayName:DefaultTemplateCode"),
description: L("Description:DefaultTemplateCode"),
isVisibleToClients: false,
isEncrypted: true
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSettingNames.Sms.DefaultPhoneNumber,
displayName: L("DisplayName:DefaultPhoneNumber"),
description: L("Description:DefaultPhoneNumber"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSettingNames.Sms.Domain,
defaultValue: "dysmsapi.aliyuncs.com",
displayName: L("DisplayName:Domain"),
description: L("Description:Domain"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSettingNames.Sms.Version,
defaultValue: "2017-05-25",
displayName: L("DisplayName:Version"),
description: L("Description:Version"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSettingNames.Sms.VisableErrorToClient,
defaultValue: false.ToString(),
displayName: L("DisplayName:VisableErrorToClient"),
description: L("Description:VisableErrorToClient"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName)
};
}
private ILocalizableString L(string name)
{
return LocalizableString.Create<AliyunResource>(name);

8
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN.Abp.Sms.Tencent.csproj

@ -4,14 +4,6 @@
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="LINGYUN\Abp\Sms\Tencent\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="LINGYUN\Abp\Sms\Tencent\Localization\Resources\*.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Sms" Version="$(VoloAbpPackageVersion)" />
</ItemGroup>

12
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN/Abp/Sms/Tencent/Localization/Resources/en.json

@ -1,12 +0,0 @@
{
"culture": "en",
"texts": {
"DisplayName:TenantCloud.SmsSetting": "Sms Setting",
"DisplayName:AppId": "App Id",
"Description:AppId": "AppId applied on Tencent Cloud SMS control platform.",
"DisplayName:DefaultSignName": "Default Sign Name",
"Description:DefaultSignName": "Default signname if no signname is specified in the SMS message body",
"DisplayName:DefaultTemplateId": "Default Template Id",
"Description:DefaultTemplateId": "Default template id if the Template Id number is not specified in the SMS message body."
}
}

12
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN/Abp/Sms/Tencent/Localization/Resources/zh-Hans.json

@ -1,12 +0,0 @@
{
"culture": "zh-Hans",
"texts": {
"DisplayName:TenantCloud.SmsSetting": "短信设置",
"DisplayName:AppId": "应用Id",
"Description:AppId": "在腾讯云短信控制平台申请的应用标识",
"DisplayName:DefaultSignName": "默认签名",
"Description:DefaultSignName": "当短信消息体未指定签名时的默认签名",
"DisplayName:DefaultTemplateId": "默认模板",
"Description:DefaultTemplateId": "当短信消息体未指定模板号时的默认模板标识"
}
}

23
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN/Abp/Sms/Tencent/Settings/TencentCloudSmsSettingNames.cs

@ -1,23 +0,0 @@
using LINGYUN.Abp.Tencent.Settings;
namespace LINGYUN.Abp.Sms.Tencent.Settings
{
public static class TencentCloudSmsSettingNames
{
public const string Prefix = TencentCloudSettingNames.Prefix + ".Sms";
/// <summary>
/// 短信 SdkAppId
/// 在 短信控制台 添加应用后生成的实际 SdkAppId,示例如1400006666。
/// </summary>
public const string AppId = Prefix + ".Domain";
/// <summary>
/// 短信签名内容
/// </summary>
public const string DefaultSignName = Prefix + ".DefaultSignName";
/// <summary>
/// 默认短信模板 ID
/// </summary>
public const string DefaultTemplateId = Prefix + ".DefaultTemplateId";
}
}

12
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN/Abp/Sms/Tencent/TencentCloudSmsSender.cs

@ -1,5 +1,5 @@
using LINGYUN.Abp.Sms.Tencent.Settings;
using LINGYUN.Abp.Tencent;
using LINGYUN.Abp.Tencent;
using LINGYUN.Abp.Tencent.Settings;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using System;
@ -41,19 +41,19 @@ namespace LINGYUN.Abp.Sms.Tencent
public virtual async Task SendAsync(SmsMessage smsMessage)
{
var appId = await SettingProvider.GetOrNullAsync(TencentCloudSmsSettingNames.AppId);
var appId = await SettingProvider.GetOrNullAsync(TencentCloudSettingNames.Sms.AppId);
Check.NotNullOrWhiteSpace(appId, TencentCloudSmsSettingNames.AppId);
Check.NotNullOrWhiteSpace(appId, TencentCloudSettingNames.Sms.AppId);
// 统一使用 TemplateCode作为模板参数, 解决不一样的sms提供商参数差异
if (!smsMessage.Properties.TryGetValue("TemplateCode", out var templateId))
{
templateId = await SettingProvider.GetOrNullAsync(TencentCloudSmsSettingNames.DefaultTemplateId);
templateId = await SettingProvider.GetOrNullAsync(TencentCloudSettingNames.Sms.DefaultTemplateId);
}
if (!smsMessage.Properties.TryGetValue("SignName", out var signName))
{
signName = await SettingProvider.GetOrNullAsync(TencentCloudSmsSettingNames.DefaultSignName);
signName = await SettingProvider.GetOrNullAsync(TencentCloudSettingNames.Sms.DefaultSignName);
}
var request = new SendSmsRequest

3
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/FodyWeavers.xml

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

30
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/FodyWeavers.xsd

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

19
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN.Abp.Tencent.QQ.csproj

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<Import Project="..\..\..\configureawait.props" />
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="LINGYUN\Abp\Tencent\QQ\Localization\*.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Tencent\LINGYUN.Abp.Tencent.csproj" />
</ItemGroup>
</Project>

30
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/AbpTencentQQCacheItem.cs

@ -0,0 +1,30 @@
using System;
namespace LINGYUN.Abp.Tencent.QQ;
public class AbpTencentQQCacheItem
{
public const string CacheKeyFormat = "pn:{0},pk:{1}";
public string AppId { get; set; }
public string AppKey { get; set; }
public bool IsMobile { get; set; }
public AbpTencentQQCacheItem()
{
}
public AbpTencentQQCacheItem(
string appId,
string appKey,
bool isMobile = false)
{
AppId = appId;
AppKey = appKey;
IsMobile = isMobile;
}
public static string CalculateCacheKey(Guid? tenantId = null)
{
return string.Format(CacheKeyFormat, tenantId.HasValue ? tenantId.Value.ToString() : "global", "tenant-qq");
}
}

28
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/AbpTencentQQModule.cs

@ -0,0 +1,28 @@
using LINGYUN.Abp.Tencent.Localization;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.Tencent.QQ;
[DependsOn(typeof(AbpTencentCloudModule))]
public class AbpTencentQQModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpTencentQQModule>();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<TencentCloudResource>()
.AddVirtualJson("/LINGYUN/Abp/Tencent/QQ/Localization");
});
context.Services.AddAbpDynamicOptions<AbpTencentQQOptions, AbpTencentQQOptionsManager>();
}
}

23
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/AbpTencentQQOptions.cs

@ -0,0 +1,23 @@
namespace LINGYUN.Abp.Tencent.QQ;
public class AbpTencentQQOptions
{
/// <summary>
/// 在QQ互联上申请的AppId
/// </summary>
/// <remarks>
/// see: https://wiki.connect.qq.com/%e5%87%86%e5%a4%87%e5%b7%a5%e4%bd%9c_oauth2-0
/// </remarks>
public string AppId { get; set; }
/// <summary>
/// 在QQ互联上申请的AppKey
/// </summary>
/// <remarks>
/// see: https://wiki.connect.qq.com/%e5%87%86%e5%a4%87%e5%b7%a5%e4%bd%9c_oauth2-0
/// </remarks>
public string AppKey { get; set; }
/// <summary>
/// 是否移动端样式
/// </summary>
public bool IsMobile { get; set; }
}

24
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/AbpTencentQQOptionsFactory.cs

@ -0,0 +1,24 @@
using Microsoft.Extensions.Options;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace LINGYUN.Abp.Tencent.QQ
{
public class AbpTencentQQOptionsFactory : ITransientDependency
{
protected IOptions<AbpTencentQQOptions> Options { get; }
public AbpTencentQQOptionsFactory(
IOptions<AbpTencentQQOptions> options)
{
Options = options;
}
public virtual async Task<AbpTencentQQOptions> CreateAsync()
{
await Options.SetAsync();
return Options.Value;
}
}
}

57
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/AbpTencentQQOptionsManager.cs

@ -0,0 +1,57 @@
using LINGYUN.Abp.Tencent.QQ.Settings;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using System;
using System.Threading.Tasks;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Options;
using Volo.Abp.Settings;
namespace LINGYUN.Abp.Tencent.QQ;
public class AbpTencentQQOptionsManager : AbpDynamicOptionsManager<AbpTencentQQOptions>
{
protected IMemoryCache TencentCache { get; }
protected ICurrentTenant CurrentTenant { get; }
protected ISettingProvider SettingProvider { get; }
public AbpTencentQQOptionsManager(
IMemoryCache tencentCache,
ICurrentTenant currentTenant,
ISettingProvider settingProvider,
IOptionsFactory<AbpTencentQQOptions> factory)
: base(factory)
{
TencentCache = tencentCache;
CurrentTenant = currentTenant;
SettingProvider = settingProvider;
}
protected override async Task OverrideOptionsAsync(string name, AbpTencentQQOptions options)
{
var cacheItem = await GetCacheItemAsync();
options.AppId = cacheItem.AppId;
options.AppKey = cacheItem.AppKey;
options.IsMobile = cacheItem.IsMobile;
}
protected virtual async Task<AbpTencentQQCacheItem> GetCacheItemAsync()
{
var cacheKey = AbpTencentQQCacheItem.CalculateCacheKey(CurrentTenant.Id);
var cacheItem = await TencentCache.GetOrCreateAsync(
cacheKey,
async (cache) =>
{
var appId = await SettingProvider.GetOrNullAsync(TencentQQSettingNames.QQConnect.AppId);
var appKey = await SettingProvider.GetOrNullAsync(TencentQQSettingNames.QQConnect.AppKey);
var isMobile = await SettingProvider.IsTrueAsync(TencentQQSettingNames.QQConnect.IsMobile);
cache.SetAbsoluteExpiration(TimeSpan.FromMinutes(2d));
return new AbpTencentQQCacheItem(appId, appKey, isMobile);
});
return cacheItem;
}
}

13
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Localization/en.json

@ -0,0 +1,13 @@
{
"culture": "en",
"texts": {
"DisplayName:TenantCloud.QQConnect": "QQ Connect",
"Description:TenantCloud.QQConnect": "Access QQ Internet open platform",
"DisplayName:QQConnect.AppId": "AppId",
"Description:QQConnect.AppId": "The application identification necessary to access QQ login can be applied at QQ Interconnection Management Center.",
"DisplayName:QQConnect.AppKey": "AppKey",
"Description:QQConnect.AppKey": "When accessing user resources, it is used to verify the validity of the application and apply for it in QQ Interconnection Management Center.",
"DisplayName:QQConnect.IsMobile": "Whether to move the style",
"Description:QQConnect.IsMobile": "The style used for display is displayed as the style under PC by default."
}
}

13
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Localization/zh-Hans.json

@ -0,0 +1,13 @@
{
"culture": "zh-Hans",
"texts": {
"DisplayName:TenantCloud.QQConnect": "QQ互联",
"Description:TenantCloud.QQConnect": "接入QQ互联开放平台",
"DisplayName:QQConnect.AppId": "应用的唯一标识",
"Description:QQConnect.AppId": "接入QQ登录所必须的应用标识, 在QQ互联管理中心申请.",
"DisplayName:QQConnect.AppKey": "AppId对应的密钥",
"Description:QQConnect.AppKey": "访问用户资源时用来验证应用的合法性, 在QQ互联管理中心申请.",
"DisplayName:QQConnect.IsMobile": "是否移动端样式",
"Description:QQConnect.IsMobile": "用于展示的样式, 默认展示为PC下的样式."
}
}

50
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Sms.Tencent/LINGYUN/Abp/Sms/Tencent/Settings/TencentCloudSmsSettingProvider.cs → aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Settings/TencentQQSettingDefinitionProvider.cs

@ -1,60 +1,58 @@
using LINGYUN.Abp.Tencent.Localization;
using LINGYUN.Abp.Tencent.Localization;
using Volo.Abp.Localization;
using Volo.Abp.Settings;
namespace LINGYUN.Abp.Sms.Tencent.Settings
namespace LINGYUN.Abp.Tencent.QQ.Settings
{
public class TencentCloudSmsSettingProvider : SettingDefinitionProvider
public class TencentQQSettingDefinitionProvider : SettingDefinitionProvider
{
public override void Define(ISettingDefinitionContext context)
{
context.Add(CreateAliyunSettings());
context.Add(GetQQConnectSettings());
}
private SettingDefinition[] CreateAliyunSettings()
{
return new SettingDefinition[]
{
private SettingDefinition[] GetQQConnectSettings()
{
return new SettingDefinition[]
{
new SettingDefinition(
TencentCloudSmsSettingNames.AppId,
displayName: L("DisplayName:AppId"),
description: L("Description:AppId"),
TencentQQSettingNames.QQConnect.AppId, "",
L("DisplayName:QQConnect.AppId"),
L("Description:QQConnect.AppId"),
isVisibleToClients: false,
isEncrypted: true
)
isEncrypted: true)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
TencentCloudSmsSettingNames.DefaultSignName,
displayName: L("DisplayName:DefaultSignName"),
description: L("Description:DefaultSignName"),
TencentQQSettingNames.QQConnect.AppKey, "",
L("DisplayName:QQConnect.AppKey"),
L("Description:QQConnect.AppKey"),
isVisibleToClients: false,
isEncrypted: true
)
isEncrypted: true)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
TencentCloudSmsSettingNames.DefaultTemplateId,
displayName: L("DisplayName:DefaultTemplateId"),
description: L("Description:DefaultTemplateId"),
TencentQQSettingNames.QQConnect.IsMobile,
"false",
L("DisplayName:QQConnect.IsMobile"),
L("Description:QQConnect.IsMobile"),
isVisibleToClients: false,
isEncrypted: true
)
isEncrypted: false)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
};
TenantSettingValueProvider.ProviderName)
};
}
private ILocalizableString L(string name)
protected ILocalizableString L(string name)
{
return LocalizableString.Create<TencentCloudResource>(name);
}

16
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.QQ/LINGYUN/Abp/Tencent/QQ/Settings/TencentQQSettingNames.cs

@ -0,0 +1,16 @@
using LINGYUN.Abp.Tencent.Settings;
namespace LINGYUN.Abp.Tencent.QQ.Settings
{
public class TencentQQSettingNames
{
public static class QQConnect
{
private const string Prefix = TencentCloudSettingNames.Prefix + ".QQConnect";
public const string AppId = Prefix + ".AppId";
public const string AppKey = Prefix + ".AppKey";
public const string IsMobile = Prefix + ".IsMobile";
}
}
}

1
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN.Abp.Tencent.SettingManagement.csproj

@ -20,6 +20,7 @@
<ItemGroup>
<ProjectReference Include="..\..\settings\LINGYUN.Abp.SettingManagement.Application.Contracts\LINGYUN.Abp.SettingManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.Sms.Tencent\LINGYUN.Abp.Sms.Tencent.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.Tencent.QQ\LINGYUN.Abp.Tencent.QQ.csproj" />
<ProjectReference Include="..\LINGYUN.Abp.Tencent\LINGYUN.Abp.Tencent.csproj" />
</ItemGroup>

40
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent.SettingManagement/LINGYUN/Abp/Tencent/SettingManagement/TenantCloudSettingAppService.cs

@ -1,6 +1,6 @@
using LINGYUN.Abp.SettingManagement;
using LINGYUN.Abp.Sms.Tencent.Settings;
using LINGYUN.Abp.Tencent.Localization;
using LINGYUN.Abp.Tencent.QQ.Settings;
using LINGYUN.Abp.Tencent.Settings;
using System.Collections.Generic;
using System.Threading.Tasks;
@ -116,26 +116,52 @@ public class TenantCloudSettingAppService : ApplicationService, ITenantCloudSett
L["DisplayName:TenantCloud.SmsSetting"], L["Description:TenantCloud.SmsSetting"]);
smsSetting.AddDetail(
SettingDefinitionManager.Get(TencentCloudSmsSettingNames.AppId),
SettingDefinitionManager.Get(TencentCloudSettingNames.Sms.AppId),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(TencentCloudSmsSettingNames.AppId, providerName, providerKey),
await SettingManager.GetOrNullAsync(TencentCloudSettingNames.Sms.AppId, providerName, providerKey),
ValueType.String,
providerName);
smsSetting.AddDetail(
SettingDefinitionManager.Get(TencentCloudSmsSettingNames.DefaultTemplateId),
SettingDefinitionManager.Get(TencentCloudSettingNames.Sms.DefaultTemplateId),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(TencentCloudSmsSettingNames.DefaultTemplateId, providerName, providerKey),
await SettingManager.GetOrNullAsync(TencentCloudSettingNames.Sms.DefaultTemplateId, providerName, providerKey),
ValueType.String,
providerName);
smsSetting.AddDetail(
SettingDefinitionManager.Get(TencentCloudSmsSettingNames.DefaultSignName),
SettingDefinitionManager.Get(TencentCloudSettingNames.Sms.DefaultSignName),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(TencentCloudSmsSettingNames.DefaultSignName, providerName, providerKey),
await SettingManager.GetOrNullAsync(TencentCloudSettingNames.Sms.DefaultSignName, providerName, providerKey),
ValueType.String,
providerName);
#endregion
#region QQ互联
var qqSetting = settingGroup.AddSetting(
L["DisplayName:TenantCloud.QQConnect"], L["Description:TenantCloud.QQConnect"]);
qqSetting.AddDetail(
SettingDefinitionManager.Get(TencentQQSettingNames.QQConnect.AppId),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(TencentQQSettingNames.QQConnect.AppId, providerName, providerKey),
ValueType.String,
providerName);
qqSetting.AddDetail(
SettingDefinitionManager.Get(TencentQQSettingNames.QQConnect.AppKey),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(TencentQQSettingNames.QQConnect.AppKey, providerName, providerKey),
ValueType.String,
providerName);
qqSetting.AddDetail(
SettingDefinitionManager.Get(TencentQQSettingNames.QQConnect.IsMobile),
StringLocalizerFactory,
await SettingManager.GetOrNullAsync(TencentQQSettingNames.QQConnect.IsMobile, providerName, providerKey),
ValueType.Boolean,
providerName);
#endregion
settingGroups.AddGroup(settingGroup);
}

7
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Localization/Resources/en.json

@ -20,6 +20,13 @@
"Description:Timeout": "Connection timeout, in seconds (default: 60 seconds)",
"DisplayName:WebProxy": "Web Proxy",
"Description:WebProxy": "Proxy server, set when there are proxy servers in your environment.",
"DisplayName:TenantCloud.SmsSetting": "Sms Setting",
"DisplayName:AppId": "App Id",
"Description:AppId": "AppId applied on Tencent Cloud SMS control platform.",
"DisplayName:DefaultSignName": "Default Sign Name",
"Description:DefaultSignName": "Default signname if no signname is specified in the SMS message body",
"DisplayName:DefaultTemplateId": "Default Template Id",
"Description:DefaultTemplateId": "Default template id if the Template Id number is not specified in the SMS message body.",
"Region:Beijing": "North China (Beijing)",
"Region:Chengdu": "Southwest China (Chengdu)",
"Region:Chongqing": "Southwest China (Chongqing)",

7
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Localization/Resources/zh-Hans.json

@ -20,6 +20,13 @@
"Description:Timeout": "请求连接超时时间,单位为秒(默认60秒)",
"DisplayName:WebProxy": "代理服务器",
"Description:WebProxy": "代理服务器,当你的环境下有代理服务器时设定",
"DisplayName:TenantCloud.SmsSetting": "短信设置",
"DisplayName:AppId": "应用Id",
"Description:AppId": "在腾讯云短信控制平台申请的应用标识",
"DisplayName:DefaultSignName": "默认签名",
"Description:DefaultSignName": "当短信消息体未指定签名时的默认签名",
"DisplayName:DefaultTemplateId": "默认模板",
"Description:DefaultTemplateId": "当短信消息体未指定模板号时的默认模板标识",
"Region:Beijing": "华北地区(北京)",
"Region:Chengdu": "西南地区(成都)",
"Region:Chongqing": "西南地区(重庆)",

116
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Settings/TencentCloudSettingDefinitionProvider.cs

@ -9,19 +9,34 @@ public class TencentCloudSettingDefinitionProvider : SettingDefinitionProvider
{
public override void Define(ISettingDefinitionContext context)
{
context.Add(CreateTencentCloudSettings());
context.Add(GetBasicSettings());
context.Add(GetConnectionSettings());
context.Add(GetSmsSettings());
}
private SettingDefinition[] CreateTencentCloudSettings()
private SettingDefinition[] GetConnectionSettings()
{
return new SettingDefinition[]
{
new SettingDefinition(
TencentCloudSettingNames.Connection.HttpMethod,
// 默认 post
defaultValue: "POST",
displayName: L("DisplayName:HttpMethod"),
description: L("Description:HttpMethod"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
TencentCloudSettingNames.EndPoint,
// 腾讯云默认使用广州区域
defaultValue: "ap-guangzhou",
displayName: L("DisplayName:EndPoint"),
description: L("Description:EndPoint"),
TencentCloudSettingNames.Connection.Timeout,
// 默认 60秒
defaultValue: "60",
displayName: L("DisplayName:Timeout"),
description: L("Description:Timeout"),
isVisibleToClients: false
)
.WithProviders(
@ -30,9 +45,27 @@ public class TencentCloudSettingDefinitionProvider : SettingDefinitionProvider
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
TencentCloudSettingNames.SecretId,
displayName: L("DisplayName:SecretId"),
description: L("Description:SecretId"),
TencentCloudSettingNames.Connection.WebProxy,
displayName: L("DisplayName:WebProxy"),
description: L("Description:WebProxy"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
};
}
private SettingDefinition[] GetSmsSettings()
{
return new SettingDefinition[]
{
new SettingDefinition(
TencentCloudSettingNames.Sms.AppId,
displayName: L("DisplayName:AppId"),
description: L("Description:AppId"),
isVisibleToClients: false,
isEncrypted: true
)
@ -42,9 +75,9 @@ public class TencentCloudSettingDefinitionProvider : SettingDefinitionProvider
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
TencentCloudSettingNames.SecretKey,
displayName: L("DisplayName:SecretKey"),
description: L("Description:SecretKey"),
TencentCloudSettingNames.Sms.DefaultSignName,
displayName: L("DisplayName:DefaultSignName"),
description: L("Description:DefaultSignName"),
isVisibleToClients: false,
isEncrypted: true
)
@ -54,23 +87,30 @@ public class TencentCloudSettingDefinitionProvider : SettingDefinitionProvider
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
TencentCloudSettingNames.DurationSecond,
defaultValue: "600",
displayName: L("DisplayName:DurationSecond"),
description: L("Description:DurationSecond"),
isVisibleToClients: false
TencentCloudSettingNames.Sms.DefaultTemplateId,
displayName: L("DisplayName:DefaultTemplateId"),
description: L("Description:DefaultTemplateId"),
isVisibleToClients: false,
isEncrypted: true
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
};
}
private SettingDefinition[] GetBasicSettings()
{
return new SettingDefinition[]
{
new SettingDefinition(
TencentCloudSettingNames.Connection.HttpMethod,
// 默认 post
defaultValue: "POST",
displayName: L("DisplayName:HttpMethod"),
description: L("Description:HttpMethod"),
TencentCloudSettingNames.EndPoint,
// 腾讯云默认使用广州区域
defaultValue: "ap-guangzhou",
displayName: L("DisplayName:EndPoint"),
description: L("Description:EndPoint"),
isVisibleToClients: false
)
.WithProviders(
@ -79,12 +119,11 @@ public class TencentCloudSettingDefinitionProvider : SettingDefinitionProvider
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
TencentCloudSettingNames.Connection.Timeout,
// 默认 60秒
defaultValue: "60",
displayName: L("DisplayName:Timeout"),
description: L("Description:Timeout"),
isVisibleToClients: false
TencentCloudSettingNames.SecretId,
displayName: L("DisplayName:SecretId"),
description: L("Description:SecretId"),
isVisibleToClients: false,
isEncrypted: true
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
@ -92,9 +131,22 @@ public class TencentCloudSettingDefinitionProvider : SettingDefinitionProvider
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
TencentCloudSettingNames.Connection.WebProxy,
displayName: L("DisplayName:WebProxy"),
description: L("Description:WebProxy"),
TencentCloudSettingNames.SecretKey,
displayName: L("DisplayName:SecretKey"),
description: L("Description:SecretKey"),
isVisibleToClients: false,
isEncrypted: true
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
TencentCloudSettingNames.DurationSecond,
defaultValue: "600",
displayName: L("DisplayName:DurationSecond"),
description: L("Description:DurationSecond"),
isVisibleToClients: false
)
.WithProviders(

18
aspnet-core/modules/cloud-tencent/LINGYUN.Abp.Tencent/LINYUN/Abp/Tencent/Settings/TencentCloudSettingNames.cs

@ -44,4 +44,22 @@ public static class TencentCloudSettingNames
/// </summary>
public const string Timeout = Prefix + ".Timeout";
}
public static class Sms
{
private const string Prefix = TencentCloudSettingNames.Prefix + ".Sms";
/// <summary>
/// 短信 SdkAppId
/// 在 短信控制台 添加应用后生成的实际 SdkAppId,示例如1400006666。
/// </summary>
public const string AppId = Prefix + ".Domain";
/// <summary>
/// 短信签名内容
/// </summary>
public const string DefaultSignName = Prefix + ".DefaultSignName";
/// <summary>
/// 默认短信模板 ID
/// </summary>
public const string DefaultTemplateId = Prefix + ".DefaultTemplateId";
}
}

25
aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/AliyunSmsSender.cs

@ -2,10 +2,9 @@
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Http;
using LINGYUN.Abp.Aliyun;
using LINGYUN.Abp.Sms.Aliyun.Settings;
using LINGYUN.Abp.Aliyun.Settings;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -39,13 +38,13 @@ namespace LINGYUN.Abp.Sms.Aliyun
public virtual async Task SendAsync(SmsMessage smsMessage)
{
var domain = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.Domain);
var action = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.ActionName);
var version = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.Version);
var domain = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Sms.Domain);
var action = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Sms.ActionName);
var version = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Sms.Version);
Check.NotNullOrWhiteSpace(domain, AliyunSmsSettingNames.Sms.Domain);
Check.NotNullOrWhiteSpace(action, AliyunSmsSettingNames.Sms.ActionName);
Check.NotNullOrWhiteSpace(version, AliyunSmsSettingNames.Sms.Version);
Check.NotNullOrWhiteSpace(domain, AliyunSettingNames.Sms.Domain);
Check.NotNullOrWhiteSpace(action, AliyunSettingNames.Sms.ActionName);
Check.NotNullOrWhiteSpace(version, AliyunSettingNames.Sms.Version);
CommonRequest request = new CommonRequest
{
@ -68,7 +67,7 @@ namespace LINGYUN.Abp.Sms.Aliyun
var aliyunResponse = JsonSerializer.Deserialize<AliyunSmsResponse>(responseContent);
if (!aliyunResponse.IsSuccess())
{
if (await SettingProvider.IsTrueAsync(AliyunSmsSettingNames.Sms.VisableErrorToClient))
if (await SettingProvider.IsTrueAsync(AliyunSettingNames.Sms.VisableErrorToClient))
{
throw new UserFriendlyException(aliyunResponse.Code, aliyunResponse.Message);
}
@ -94,7 +93,7 @@ namespace LINGYUN.Abp.Sms.Aliyun
}
else
{
var defaultTemplateCode = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultTemplateCode);
var defaultTemplateCode = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Sms.DefaultTemplateCode);
Check.NotNullOrWhiteSpace(defaultTemplateCode, "TemplateCode");
request.AddQueryParameters("TemplateCode", defaultTemplateCode);
}
@ -109,7 +108,7 @@ namespace LINGYUN.Abp.Sms.Aliyun
}
else
{
var defaultSignName = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultSignName);
var defaultSignName = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Sms.DefaultSignName);
Check.NotNullOrWhiteSpace(defaultSignName, "SignName");
request.AddQueryParameters("SignName", defaultSignName);
}
@ -119,11 +118,11 @@ namespace LINGYUN.Abp.Sms.Aliyun
{
if (smsMessage.PhoneNumber.IsNullOrWhiteSpace())
{
var defaultPhoneNumber = await SettingProvider.GetOrNullAsync(AliyunSmsSettingNames.Sms.DefaultPhoneNumber);
var defaultPhoneNumber = await SettingProvider.GetOrNullAsync(AliyunSettingNames.Sms.DefaultPhoneNumber);
// check phone number length...
Check.NotNullOrWhiteSpace(
defaultPhoneNumber,
AliyunSmsSettingNames.Sms.DefaultPhoneNumber,
AliyunSettingNames.Sms.DefaultPhoneNumber,
maxLength: 11, minLength: 11);
request.AddQueryParameters("PhoneNumbers", defaultPhoneNumber);
}

16
aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/Localization/Resources/en.json

@ -1,22 +1,6 @@
{
"culture": "en",
"texts": {
"DisplayName:Aliyun.Sms": "Sms",
"Description:Aliyun.Sms": "Sms",
"DisplayName:ActionName": "Action Name",
"Description:ActionName": "Action Name",
"DisplayName:DefaultSignName": "Default Sign Name",
"Description:DefaultSignName": "Default Sign Name",
"DisplayName:DefaultTemplateCode": "Default Template Code",
"Description:DefaultTemplateCode": "Default Template Code",
"DisplayName:DefaultPhoneNumber": "Default Phone Number",
"Description:DefaultPhoneNumber": "Default Phone Number",
"DisplayName:Domain": "Domain",
"Description:Domain": "Domain",
"DisplayName:Version": "Version",
"Description:Version": "Version",
"DisplayName:VisableErrorToClient": "Visable Error To Client",
"Description:VisableErrorToClient": "Visable Error To Client",
"SendMessageFailed": "Text message sending failed:{0}",
"SMS_SIGNATURE_SCENE_ILLEGAL": "Signature scene used by SMS is illegal",
"DENY_IP_RANGE": "Region where source IP address is disabled",

16
aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/Localization/Resources/zh-Hans.json

@ -1,22 +1,6 @@
{
"culture": "zh-Hans",
"texts": {
"DisplayName:Aliyun.Sms": "短信服务",
"Description:Aliyun.Sms": "阿里云短信服务",
"DisplayName:ActionName": "发送短信方法",
"Description:ActionName": "发送短信方法名称,详情见阿里云Sms服务",
"DisplayName:DefaultSignName": "默认短信签名",
"Description:DefaultSignName": "当用户未指定短信签名时的默认签名名称",
"DisplayName:DefaultTemplateCode": "默认短信模板号",
"Description:DefaultTemplateCode": "当用户未指定短信签名时的默认短信模板号",
"DisplayName:DefaultPhoneNumber": "默认接收短信手机号",
"Description:DefaultPhoneNumber": "当用户未指定短信接收方时的默认接收手机号码",
"DisplayName:Domain": "阿里云sms服务域名",
"Description:Domain": "阿里云sms服务域名",
"DisplayName:Version": "阿里云sms服务版本号",
"Description:Version": "阿里云sms服务版本号",
"DisplayName:VisableErrorToClient": "发送错误到客户端",
"Description:VisableErrorToClient": "当短信服务发送出现错误时是否发送错误详情到客户端",
"SendMessageFailed": "发送短信错误:{0}",
"SMS_SIGNATURE_SCENE_ILLEGAL": "短信所使用签名场景非法",
"DENY_IP_RANGE": "源IP地址所在的地区被禁用",

43
aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/Settings/AliyunSmsSettingNames.cs

@ -1,43 +0,0 @@
using LINGYUN.Abp.Aliyun.Settings;
namespace LINGYUN.Abp.Sms.Aliyun.Settings
{
public static class AliyunSmsSettingNames
{
/// <summary>
/// 短信服务
/// </summary>
public class Sms
{
public const string Prefix = AliyunSettingNames.Prefix + ".Sms";
/// <summary>
/// 阿里云sms服务域名
/// </summary>
public const string Domain = Prefix + ".Domain";
/// <summary>
/// 调用方法名称
/// </summary>
public const string ActionName = Prefix + ".ActionName";
/// <summary>
/// 默认版本号
/// </summary>
public const string Version = Prefix + ".Version";
/// <summary>
/// 默认签名
/// </summary>
public const string DefaultSignName = Prefix + ".DefaultSignName";
/// <summary>
/// 默认短信模板号
/// </summary>
public const string DefaultTemplateCode = Prefix + ".DefaultTemplateCode";
/// <summary>
/// 默认号码
/// </summary>
public const string DefaultPhoneNumber = Prefix + ".DefaultPhoneNumber";
/// <summary>
/// 展示错误给客户端
/// </summary>
public const string VisableErrorToClient = Prefix + ".VisableErrorToClient";
}
}
}

109
aspnet-core/modules/common/LINGYUN.Abp.Sms.Aliyun/LINGYUN/Abp/Sms/Aliyun/Settings/AliyunSmsSettingProvider.cs

@ -1,109 +0,0 @@
using LINGYUN.Abp.Aliyun.Localization;
using Volo.Abp.Localization;
using Volo.Abp.Settings;
namespace LINGYUN.Abp.Sms.Aliyun.Settings
{
public class AliyunSmsSettingProvider : SettingDefinitionProvider
{
public override void Define(ISettingDefinitionContext context)
{
context.Add(CreateAliyunSettings());
}
private SettingDefinition[] CreateAliyunSettings()
{
return new SettingDefinition[]
{
new SettingDefinition(
AliyunSmsSettingNames.Sms.ActionName,
defaultValue: "SendSms",
displayName: L("DisplayName:ActionName"),
description: L("Description:ActionName"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSmsSettingNames.Sms.DefaultSignName,
displayName: L("DisplayName:DefaultSignName"),
description: L("Description:DefaultSignName"),
isVisibleToClients: false,
isEncrypted: true
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSmsSettingNames.Sms.DefaultTemplateCode,
displayName: L("DisplayName:DefaultTemplateCode"),
description: L("Description:DefaultTemplateCode"),
isVisibleToClients: false,
isEncrypted: true
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSmsSettingNames.Sms.DefaultPhoneNumber,
displayName: L("DisplayName:DefaultPhoneNumber"),
description: L("Description:DefaultPhoneNumber"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSmsSettingNames.Sms.Domain,
defaultValue: "dysmsapi.aliyuncs.com",
displayName: L("DisplayName:Domain"),
description: L("Description:Domain"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSmsSettingNames.Sms.Version,
defaultValue: "2017-05-25",
displayName: L("DisplayName:Version"),
description: L("Description:Version"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName),
new SettingDefinition(
AliyunSmsSettingNames.Sms.VisableErrorToClient,
defaultValue: false.ToString(),
displayName: L("DisplayName:VisableErrorToClient"),
description: L("Description:VisableErrorToClient"),
isVisibleToClients: false
)
.WithProviders(
DefaultValueSettingValueProvider.ProviderName,
ConfigurationSettingValueProvider.ProviderName,
GlobalSettingValueProvider.ProviderName,
TenantSettingValueProvider.ProviderName)
};
}
private ILocalizableString L(string name)
{
return LocalizableString.Create<AliyunResource>(name);
}
}
}

3
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/FodyWeavers.xml

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

30
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.LinkUser/FodyWeavers.xsd

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

3
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/FodyWeavers.xml

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

30
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/FodyWeavers.xsd

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

19
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/LINGYUN.Abp.IdentityServer.QQ.csproj

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
<Import Project="..\..\..\configureawait.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.IdentityServer.Domain" Version="$(VoloAbpPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\cloud-tencent\LINGYUN.Abp.Tencent.QQ\LINGYUN.Abp.Tencent.QQ.csproj" />
</ItemGroup>
</Project>

8
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/LINGYUN/Abp/IdentityServer/QQ/AbpIdentityServerQQConsts.cs

@ -0,0 +1,8 @@
namespace LINGYUN.Abp.IdentityServer.QQ;
public static class AbpIdentityServerQQConsts
{
public static string AuthenticationScheme { get; set; } = "QQ Connect";
public static string DisplayName { get; set; } = "QQ Connect";
public static string CallbackPath { get; set; } = "/signin-qq";
}

19
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/LINGYUN/Abp/IdentityServer/QQ/AbpIdentityServerQQModule.cs

@ -0,0 +1,19 @@
using LINGYUN.Abp.Tencent.QQ;
using Microsoft.AspNetCore.Authentication;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.IdentityServer;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.IdentityServer.QQ;
[DependsOn(typeof(AbpTencentQQModule))]
[DependsOn(typeof(AbpIdentityServerDomainModule))]
public class AbpIdentityServerQQModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services
.AddAuthentication()
.AddQQConnect();
}
}

31
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/LINGYUN/Abp/IdentityServer/QQ/AbpQQClaimTypes.cs

@ -0,0 +1,31 @@
namespace LINGYUN.Abp.WeChat.Security.Claims
{
/// <summary>
/// QQ互联身份类型,可以像 <see cref="Volo.Abp.Security.Claims.AbpClaimTypes"/> 自行配置
/// <br />
/// See: <see cref="https://wiki.connect.qq.com/get_user_info"/>
/// </summary>
public class AbpQQClaimTypes
{
/// <summary>
/// 用户的唯一标识
/// </summary>
public static string OpenId { get; set; } = "qq-openid"; // 可变更
/// <summary>
/// 用户昵称
/// </summary>
public static string NickName { get; set; } = "nickname";
/// <summary>
/// 性别。 如果获取不到则默认返回"男"
/// </summary>
public static string Gender { get; set; } = "gender";
/// <summary>
/// 用户头像, 取自字段: figureurl_qq_1
/// </summary>
/// <remarks>
/// 根据QQ互联文档, 40x40的头像是一定会存在的, 只取40x40的头像
/// see: https://wiki.connect.qq.com/get_user_info
/// </remarks>
public static string AvatarUrl { get; set; } = "avatar";
}
}

175
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/Microsoft/AspNetCore/Authentication/QQ/QQConnectOAuthHandler.cs

@ -0,0 +1,175 @@
using LINGYUN.Abp.Tencent.QQ;
using LINGYUN.Abp.WeChat.Security.Claims;
using Microsoft.AspNetCore.Authentication.OAuth;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Authentication.QQ
{
/// <summary>
/// QQ互联实现
/// </summary>
public class QQConnectOAuthHandler : OAuthHandler<QQConnectOAuthOptions>
{
protected AbpTencentQQOptionsFactory TencentQQOptionsFactory { get; }
public QQConnectOAuthHandler(
IOptionsMonitor<QQConnectOAuthOptions> options,
AbpTencentQQOptionsFactory tencentQQOptionsFactory,
ILoggerFactory logger,
UrlEncoder encoder,
ISystemClock clock)
: base(options, logger, encoder, clock)
{
TencentQQOptionsFactory = tencentQQOptionsFactory;
}
protected override async Task InitializeHandlerAsync()
{
var options = await TencentQQOptionsFactory.CreateAsync();
// 用配置项重写
Options.ClientId = options.AppId;
Options.ClientSecret = options.AppKey;
Options.IsMobile = options.IsMobile;
await base.InitializeHandlerAsync();
}
/// <summary>
/// 构建用户授权地址
/// </summary>
protected override string BuildChallengeUrl(AuthenticationProperties properties, string redirectUri)
{
var challengeUrl = base.BuildChallengeUrl(properties, redirectUri);
if (Options.IsMobile)
{
challengeUrl += "&display=mobile";
}
return challengeUrl;
}
/// <summary>
/// code换取access_token
/// </summary>
protected override async Task<OAuthTokenResponse> ExchangeCodeAsync(OAuthCodeExchangeContext context)
{
var address = QueryHelpers.AddQueryString(Options.TokenEndpoint, new Dictionary<string, string>()
{
{ "client_id", Options.ClientId },
{ "redirect_uri", context.RedirectUri },
{ "client_secret", Options.ClientSecret},
{ "code", context.Code},
{ "grant_type","authorization_code"}
});
var response = await Backchannel.GetAsync(address);
if (!response.IsSuccessStatusCode)
{
Logger.LogError("An error occurred while retrieving an access token: the remote server " +
"returned a {Status} response with the following payload: {Headers} {Body}.",
/* Status: */ response.StatusCode,
/* Headers: */ response.Headers.ToString(),
/* Body: */ await response.Content.ReadAsStringAsync());
return OAuthTokenResponse.Failed(new Exception("An error occurred while retrieving an access token."));
}
var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
if (!string.IsNullOrEmpty(payload.GetRootString("errcode")))
{
Logger.LogError("An error occurred while retrieving an access token: the remote server " +
"returned a {Status} response with the following payload: {Headers} {Body}.",
/* Status: */ response.StatusCode,
/* Headers: */ response.Headers.ToString(),
/* Body: */ await response.Content.ReadAsStringAsync());
return OAuthTokenResponse.Failed(new Exception("An error occurred while retrieving an access token."));
}
return OAuthTokenResponse.Success(payload);
}
protected override async Task<AuthenticationTicket> CreateTicketAsync(ClaimsIdentity identity, AuthenticationProperties properties, OAuthTokenResponse tokens)
{
var openIdEndpoint = Options.OpenIdEndpoint + "?access_token=" + tokens.AccessToken + "&fmt=json";
var openIdResponse = await Backchannel.GetAsync(openIdEndpoint, Context.RequestAborted);
openIdResponse.EnsureSuccessStatusCode();
var openIdPayload = JsonDocument.Parse(await openIdResponse.Content.ReadAsStringAsync());
var openId = openIdPayload.GetRootString("openid");
identity.AddClaim(new Claim(AbpQQClaimTypes.OpenId, openId, ClaimValueTypes.String, Options.ClaimsIssuer));
var address = QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary<string, string>
{
{"oauth_consumer_key", Options.ClientId},
{"access_token", tokens.AccessToken},
{"openid", openId}
});
var response = await Backchannel.GetAsync(address);
if (!response.IsSuccessStatusCode)
{
Logger.LogError("An error occurred while retrieving the user profile: the remote server " +
"returned a {Status} response with the following payload: {Headers} {Body}.",
/* Status: */ response.StatusCode,
/* Headers: */ response.Headers.ToString(),
/* Body: */ await response.Content.ReadAsStringAsync());
throw new HttpRequestException("An error occurred while retrieving user information.");
}
var userInfoPayload = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
var errorCode = userInfoPayload.GetRootString("ret");
if (!"0".Equals(errorCode))
{
// See: https://wiki.connect.qq.com/%e5%85%ac%e5%85%b1%e8%bf%94%e5%9b%9e%e7%a0%81%e8%af%b4%e6%98%8e
Logger.LogError("An error occurred while retrieving the user profile: the remote server " +
"returned code {Code} response with message: {Message}.",
errorCode,
userInfoPayload.GetRootString("msg"));
throw new HttpRequestException("An error occurred while retrieving user information.");
}
var nickName = userInfoPayload.GetRootString("nickname");
if (!nickName.IsNullOrWhiteSpace())
{
identity.AddClaim(new Claim(AbpQQClaimTypes.NickName, nickName, ClaimValueTypes.String, Options.ClaimsIssuer));
}
var gender = userInfoPayload.GetRootString("gender");
if (!gender.IsNullOrWhiteSpace())
{
identity.AddClaim(new Claim(AbpQQClaimTypes.Gender, gender, ClaimValueTypes.String, Options.ClaimsIssuer));
}
var avatarUrl = userInfoPayload.GetRootString("figureurl_qq_1");
if (!avatarUrl.IsNullOrWhiteSpace())
{
identity.AddClaim(new Claim(AbpQQClaimTypes.AvatarUrl, avatarUrl, ClaimValueTypes.String, Options.ClaimsIssuer));
}
var context = new OAuthCreatingTicketContext(
new ClaimsPrincipal(identity),
properties,
Context,
Scheme,
Options,
Backchannel,
tokens,
userInfoPayload.RootElement);
context.RunClaimActions();
await Events.CreatingTicket(context);
return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name);
}
}
}

47
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/Microsoft/AspNetCore/Authentication/QQ/QQConnectOAuthOptions.cs

@ -0,0 +1,47 @@
using LINGYUN.Abp.IdentityServer.QQ;
using LINGYUN.Abp.WeChat.Security.Claims;
using Microsoft.AspNetCore.Authentication.OAuth;
using Microsoft.AspNetCore.Http;
using System.Security.Claims;
namespace Microsoft.AspNetCore.Authentication.QQ
{
public class QQConnectOAuthOptions : OAuthOptions
{
/// <summary>
/// 是否移动端样式
/// </summary>
public bool IsMobile { get; set; }
/// <summary>
/// 获取用户OpenID_OAuth2.0
/// </summary>
public string OpenIdEndpoint { get; set; }
public QQConnectOAuthOptions()
{
// 用于防止初始化错误,会在OAuthHandler.InitializeHandlerAsync中进行重写
ClientId = "QQConnect";
ClientSecret = "QQConnect";
ClaimsIssuer = "connect.qq.com";
CallbackPath = new PathString(AbpIdentityServerQQConsts.CallbackPath);
AuthorizationEndpoint = "https://graph.qq.com/oauth2.0/authorize";
TokenEndpoint = "https://graph.qq.com/oauth2.0/token";
OpenIdEndpoint = "https://graph.qq.com/oauth2.0/me";
UserInformationEndpoint = "https://graph.qq.com/user/get_user_info";
Scope.Add("get_user_info");
// 这个原始的属性一定要写进去,框架关联判断是否绑定QQ
ClaimActions.MapJsonKey(ClaimTypes.NameIdentifier, "openid");
ClaimActions.MapJsonKey(ClaimTypes.Name, "nickname");
// 把自定义的身份标识写进令牌
ClaimActions.MapJsonKey(AbpQQClaimTypes.OpenId, "openid");
ClaimActions.MapJsonKey(AbpQQClaimTypes.NickName, "nickname");
ClaimActions.MapJsonKey(AbpQQClaimTypes.Gender, "gender");
ClaimActions.MapJsonKey(AbpQQClaimTypes.AvatarUrl, "figureurl_qq_1");
}
}
}

63
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/Microsoft/AspNetCore/Authentication/QQAuthenticationExtensions.cs

@ -0,0 +1,63 @@
using LINGYUN.Abp.IdentityServer.QQ;
using Microsoft.AspNetCore.Authentication.QQ;
using Microsoft.Extensions.DependencyInjection;
using System;
namespace Microsoft.AspNetCore.Authentication
{
public static class QQAuthenticationExtensions
{
/// <summary>
/// </summary>
public static AuthenticationBuilder AddQQConnect(
this AuthenticationBuilder builder)
{
return builder
.AddQQConnect(
AbpIdentityServerQQConsts.AuthenticationScheme,
AbpIdentityServerQQConsts.DisplayName,
options => { });
}
/// <summary>
/// </summary>
public static AuthenticationBuilder AddQQConnect(
this AuthenticationBuilder builder,
Action<QQOAuthOptions> configureOptions)
{
return builder
.AddQQConnect(
AbpIdentityServerQQConsts.AuthenticationScheme,
configureOptions);
}
/// <summary>
/// </summary>
public static AuthenticationBuilder AddQQConnect(
this AuthenticationBuilder builder,
string authenticationScheme,
Action<QQOAuthOptions> configureOptions)
{
return builder
.AddQQConnect(
authenticationScheme,
AbpIdentityServerQQConsts.DisplayName,
configureOptions);
}
/// <summary>
/// </summary>
public static AuthenticationBuilder AddQQConnect(
this AuthenticationBuilder builder,
string authenticationScheme,
string displayName,
Action<QQOAuthOptions> configureOptions)
{
return builder
.AddOAuth<QQOAuthOptions, QQOAuthHandler>(
authenticationScheme,
displayName,
configureOptions);
}
}
}

16
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/System/BytesExtensions.cs

@ -0,0 +1,16 @@
using System.Security.Cryptography;
namespace System
{
internal static class BytesExtensions
{
public static byte[] Sha1(this byte[] data)
{
using (var sha = SHA1.Create())
{
var hashBytes = sha.ComputeHash(data);
return hashBytes;
}
}
}
}

17
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/System/StringExtensions.cs

@ -0,0 +1,17 @@
using System.Security.Cryptography;
using System.Text;
namespace System
{
internal static class StringExtensions
{
public static byte[] Sha1(this string str)
{
using (var sha = SHA1.Create())
{
var hashBytes = sha.ComputeHash(Encoding.ASCII.GetBytes(str));
return hashBytes;
}
}
}
}

63
aspnet-core/modules/identityServer/LINGYUN.Abp.IdentityServer.QQ/System/Text/Json/JsonElementExtensions.cs

@ -0,0 +1,63 @@
using System.Collections.Generic;
namespace System.Text.Json
{
internal static class JsonElementExtensions
{
public static IEnumerable<string> GetRootStrings(this JsonDocument json, string key)
{
return json.RootElement.GetStrings(key);
}
public static IEnumerable<string> GetStrings(this JsonElement json, string key)
{
var result = new List<string>();
if (json.TryGetProperty(key, out JsonElement property) && property.ValueKind == JsonValueKind.Array)
{
foreach (var jsonProp in property.EnumerateArray())
{
result.Add(jsonProp.GetString());
}
}
return result;
}
public static string GetRootString(this JsonDocument json, string key, string defaultValue = "")
{
if (json.RootElement.TryGetProperty(key, out JsonElement property))
{
return property.GetString();
}
return defaultValue;
}
public static string GetString(this JsonElement json, string key, string defaultValue = "")
{
if (json.TryGetProperty(key, out JsonElement property))
{
return property.GetString();
}
return defaultValue;
}
public static int GetRootInt32(this JsonDocument json, string key, int defaultValue = 0)
{
if (json.RootElement.TryGetProperty(key, out JsonElement property) && property.TryGetInt32(out int value))
{
return value;
}
return defaultValue;
}
public static int GetInt32(this JsonElement json, string key, int defaultValue = 0)
{
if (json.TryGetProperty(key, out JsonElement property) && property.TryGetInt32(out int value))
{
return value;
}
return defaultValue;
}
}
}

2
aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs

@ -5,6 +5,7 @@ using LINGYUN.Abp.EventBus.CAP;
using LINGYUN.Abp.Identity.EntityFrameworkCore;
using LINGYUN.Abp.IdentityServer;
using LINGYUN.Abp.IdentityServer.EntityFrameworkCore;
using LINGYUN.Abp.IdentityServer.QQ;
using LINGYUN.Abp.IdentityServer.WeChat;
using LINGYUN.Abp.Localization.CultureMap;
using LINGYUN.Abp.MultiTenancy.DbFinder;
@ -52,6 +53,7 @@ namespace LY.MicroService.IdentityServer;
typeof(AbpIdentityServerEntityFrameworkCoreModule),
typeof(AbpIdentityServerSmsValidatorModule),
typeof(AbpIdentityServerWeChatModule),
typeof(AbpIdentityServerQQModule),
typeof(AbpPermissionManagementDomainIdentityModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),

1
aspnet-core/services/LY.MicroService.identityServer/LY.MicroService.IdentityServer.csproj

@ -52,6 +52,7 @@
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.EventBus.CAP\LINGYUN.Abp.EventBus.CAP.csproj" />
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Sms.Aliyun\LINGYUN.Abp.Sms.Aliyun.csproj" />
<ProjectReference Include="..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.EntityFrameworkCore\LINGYUN.Abp.IdentityServer.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.QQ\LINGYUN.Abp.IdentityServer.QQ.csproj" />
<ProjectReference Include="..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.SmsValidator\LINGYUN.Abp.IdentityServer.SmsValidator.csproj" />
<ProjectReference Include="..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.WeChat\LINGYUN.Abp.IdentityServer.WeChat.csproj" />
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.EntityFrameworkCore\LINGYUN.Abp.Identity.EntityFrameworkCore.csproj" />

2
aspnet-core/services/LY.MicroService.identityServer/Properties/launchSettings.json

@ -12,7 +12,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://127.0.0.1:44385;https://localhost:44386",
"applicationUrl": "http://127.0.0.1:44385;https://127.0.0.1:44386",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}

5
build/modules.dependencies.json

@ -24,7 +24,10 @@
"LINGYUN.Abp.RealTime.dll",
"LINGYUN.Abp.Notifications.dll",
"LINGYUN.Platform.Application.Contracts.dll",
"LINGYUN.Platform.Domain.Shared.dll"
"LINGYUN.Platform.Domain.Shared.dll",
"LINGYUN.Abp.Tencent.dll",
"LINGYUN.Abp.Tencent.QQ.dll",
"LINGYUN.Abp.Tencent.SettingManagement.dll"
]
},
{

Loading…
Cancel
Save