mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2026-03-10 00:13:36 +08:00
refactor(wxapi): 重命名安全鉴权模式相关参数
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Constants
|
||||
{
|
||||
public static class SecurityApiAsymmetricAlgorithms
|
||||
public static class SecureApiAsymmetricAlgorithms
|
||||
{
|
||||
public const string RSA = "RSA";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace SKIT.FlurlHttpClient.Wechat.Api.Constants
|
||||
{
|
||||
public static class SecurityApiSymmetricAlgorithms
|
||||
public static class SecureApiSymmetricAlgorithms
|
||||
{
|
||||
public const string AES = "AES";
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Interceptors
|
||||
using SKIT.FlurlHttpClient.Internal;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api.Constants;
|
||||
|
||||
internal class WechatApiSecurityApiInterceptor : HttpInterceptor
|
||||
internal class WechatApiSecureApiInterceptor : HttpInterceptor
|
||||
{
|
||||
/**
|
||||
* REF:
|
||||
@@ -96,7 +96,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Interceptors
|
||||
private readonly string _asymmetricPrivateKey;
|
||||
private readonly Func<string, bool>? _customRequestPathMatcher;
|
||||
|
||||
public WechatApiSecurityApiInterceptor(string baseUrl, string appId, string symmetricAlg, string symmetricNum, string symmetricEncodingKey, string asymmetricAlg, string asymmetricNum, string asymmetricPrivateKey, Func<string, bool>? customRequestPathMatcher)
|
||||
public WechatApiSecureApiInterceptor(string baseUrl, string appId, string symmetricAlg, string symmetricNum, string symmetricEncodingKey, string asymmetricAlg, string asymmetricNum, string asymmetricPrivateKey, Func<string, bool>? customRequestPathMatcher)
|
||||
{
|
||||
_baseUrl = baseUrl.TrimEnd('/');
|
||||
_appId = appId;
|
||||
@@ -176,7 +176,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Interceptors
|
||||
string sData, sIV, sAuthTag;
|
||||
switch (_symmetricAlg)
|
||||
{
|
||||
case SecurityApiSymmetricAlgorithms.AES:
|
||||
case SecureApiSymmetricAlgorithms.AES:
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -203,7 +203,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Interceptors
|
||||
}
|
||||
break;
|
||||
|
||||
case SecurityApiSymmetricAlgorithms.SM4:
|
||||
case SecureApiSymmetricAlgorithms.SM4:
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -257,7 +257,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Interceptors
|
||||
|
||||
switch (_asymmetricAlg)
|
||||
{
|
||||
case SecurityApiAsymmetricAlgorithms.RSA:
|
||||
case SecureApiAsymmetricAlgorithms.RSA:
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -270,7 +270,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Interceptors
|
||||
}
|
||||
break;
|
||||
|
||||
case SecurityApiAsymmetricAlgorithms.SM2:
|
||||
case SecureApiAsymmetricAlgorithms.SM2:
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -359,7 +359,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Interceptors
|
||||
|
||||
switch (_symmetricAlg)
|
||||
{
|
||||
case SecurityApiSymmetricAlgorithms.AES:
|
||||
case SecureApiSymmetricAlgorithms.AES:
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -383,7 +383,7 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Interceptors
|
||||
}
|
||||
break;
|
||||
|
||||
case SecurityApiSymmetricAlgorithms.SM4:
|
||||
case SecureApiSymmetricAlgorithms.SM4:
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -41,18 +41,18 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
FlurlClient.BaseUrl = options.Endpoint ?? WechatApiEndpoints.DEFAULT;
|
||||
FlurlClient.WithTimeout(options.Timeout <= 0 ? Timeout.InfiniteTimeSpan : TimeSpan.FromMilliseconds(options.Timeout));
|
||||
|
||||
if (options.SecurityApiEnabled)
|
||||
if (options.SecureApiEnabled)
|
||||
{
|
||||
Interceptors.Add(new Interceptors.WechatApiSecurityApiInterceptor(
|
||||
Interceptors.Add(new Interceptors.WechatApiSecureApiInterceptor(
|
||||
baseUrl: FlurlClient.BaseUrl,
|
||||
appId: string.IsNullOrEmpty(options.SecurityApiAppId) ? options.AppId : options.SecurityApiAppId!,
|
||||
symmetricAlg: options.SecurityApiSymmetricAlgorithm!,
|
||||
symmetricNum: options.SecurityApiSymmetricNumber!,
|
||||
symmetricEncodingKey: options.SecurityApiSymmetricEncodingKey!,
|
||||
asymmetricAlg: options.SecurityApiAsymmetricAlgorithm!,
|
||||
asymmetricNum: options.SecurityApiAsymmetricNumber!,
|
||||
asymmetricPrivateKey: options.SecurityApiAsymmetricPrivateKey!,
|
||||
customRequestPathMatcher: options.SecurityApiCustomRequestPathMatcher
|
||||
appId: string.IsNullOrEmpty(options.SecureApiAppId) ? options.AppId : options.SecureApiAppId!,
|
||||
symmetricAlg: options.SecureApiSymmetricAlgorithm!,
|
||||
symmetricNum: options.SecureApiSymmetricNumber!,
|
||||
symmetricEncodingKey: options.SecureApiSymmetricEncodingKey!,
|
||||
asymmetricAlg: options.SecureApiAsymmetricAlgorithm!,
|
||||
asymmetricNum: options.SecureApiAsymmetricNumber!,
|
||||
asymmetricPrivateKey: options.SecureApiAsymmetricPrivateKey!,
|
||||
customRequestPathMatcher: options.SecureApiCustomRequestPathMatcher
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,52 +81,52 @@ namespace SKIT.FlurlHttpClient.Wechat.Api
|
||||
/// <summary>
|
||||
/// 获取或设置 API 安全鉴权模式是否开启。
|
||||
/// </summary>
|
||||
public bool SecurityApiEnabled { get; set; }
|
||||
public bool SecureApiEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 API 安全鉴权模式所使用的 AppId。如果不指定将使用 <see cref="AppId"/>。
|
||||
/// </summary>
|
||||
public string? SecurityApiAppId { get; set; }
|
||||
public string? SecureApiAppId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 API 安全鉴权模式对称加密算法。
|
||||
/// <para>
|
||||
/// 默认值:<see cref="Constants.SecurityApiSymmetricAlgorithms.AES"/>
|
||||
/// 默认值:<see cref="Constants.SecureApiSymmetricAlgorithms.AES"/>
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public string SecurityApiSymmetricAlgorithm { get; set; } = Constants.SecurityApiSymmetricAlgorithms.AES;
|
||||
public string SecureApiSymmetricAlgorithm { get; set; } = Constants.SecureApiSymmetricAlgorithms.AES;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 API 安全鉴权模式对称加密密钥编号。
|
||||
/// </summary>
|
||||
public string? SecurityApiSymmetricNumber { get; set; }
|
||||
public string? SecureApiSymmetricNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 API 安全鉴权模式对称加密密钥(经过 Base64 编码)。
|
||||
/// </summary>
|
||||
public string? SecurityApiSymmetricEncodingKey { get; set; }
|
||||
public string? SecureApiSymmetricEncodingKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 API 安全鉴权模式非对称加密算法。
|
||||
/// <para>
|
||||
/// 默认值:<see cref="Constants.SecurityApiAsymmetricAlgorithms.RSA"/>
|
||||
/// 默认值:<see cref="Constants.SecureApiAsymmetricAlgorithms.RSA"/>
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public string SecurityApiAsymmetricAlgorithm { get; set; } = Constants.SecurityApiAsymmetricAlgorithms.RSA;
|
||||
public string SecureApiAsymmetricAlgorithm { get; set; } = Constants.SecureApiAsymmetricAlgorithms.RSA;
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 API 安全鉴权模式非对称加密私钥编号。
|
||||
/// </summary>
|
||||
public string? SecurityApiAsymmetricNumber { get; set; }
|
||||
public string? SecureApiAsymmetricNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 API 安全鉴权模式非对称加密私钥。
|
||||
/// </summary>
|
||||
public string? SecurityApiAsymmetricPrivateKey { get; set; }
|
||||
public string? SecureApiAsymmetricPrivateKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置 API 安全鉴权模式自定义请求路径匹配器。如果不指定将只匹配关键 API。
|
||||
/// </summary>
|
||||
public Func<string, bool>? SecurityApiCustomRequestPathMatcher { get; set; }
|
||||
public Func<string, bool>? SecureApiCustomRequestPathMatcher { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user