This commit is contained in:
zpc 2025-09-11 18:08:57 +08:00
parent 7160ac1f1a
commit 089d7fe323
4 changed files with 65 additions and 5 deletions

View File

@ -155,6 +155,35 @@ namespace CoreCms.Net.Auth
var signingKey = new SymmetricSecurityKey(keyByteArray);
var issuer = AppSettingsConstVars.JwtConfigIssuer;
var audience = AppSettingsConstVars.JwtConfigAudience;
// 👇 下面是你应该添加的打印代码,用于调试
Console.WriteLine("[JWT Debug] JwtConfigSecretKey 配置读取开始 =====================");
// 1. 打印密钥的长度(帮助判断是否为空或过短)
Console.WriteLine($"[JWT Debug] JwtConfigSecretKey 长度: {symmetricKeyAsBase64.Length}");
// 2. 打印密钥的前 5 个字符(避免泄露全部密钥,但可以用于对比)
if (!string.IsNullOrEmpty(symmetricKeyAsBase64) && symmetricKeyAsBase64.Length >= 5)
{
Console.WriteLine($"[JWT Debug] JwtConfigSecretKey 前5位: '{symmetricKeyAsBase64.Substring(0, 5)}...'");
}
else
{
Console.WriteLine($"[JWT Debug] JwtConfigSecretKey 前5位: (太短或为空)");
}
// 3. 打印密钥的 SHA256 哈希值(可用于绝对安全地对比密钥是否一致,不会泄露原文)
try
{
var sha256Hash = System.Security.Cryptography.SHA256.HashData(keyByteArray);
var hashString = BitConverter.ToString(sha256Hash).Replace("-", "").ToLower();
Console.WriteLine($"[JWT Debug] JwtConfigSecretKey SHA256 哈希值: {hashString},明文:{symmetricKeyAsBase64}");
}
catch (Exception ex)
{
Console.WriteLine($"[JWT Debug] 计算密钥哈希时出错: {ex.Message}");
}
Console.WriteLine("[JWT Debug] JwtConfigSecretKey 配置读取结束 =====================");
var signingCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256);

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar.Extensions;
namespace CoreCms.Net.Configuration
@ -63,8 +64,10 @@ namespace CoreCms.Net.Configuration
#region Jwt授权配置================================================================================
public static readonly string JwtConfigSecretKey = AppSettingsHelper.GetContent("JwtConfig", "SecretKey") + AppSettingsHelper.GetMachineRandomKey(DbSqlConnection + AppSettingsHelper.GetMACIp(true));
public static readonly string JwtConfigSecretKey = !string.IsNullOrEmpty(AppSettingsHelper.GetContent("JwtConfig", "SecretKey")) ? AppSettingsHelper.GetContent("JwtConfig", "SecretKey") : AppSettingsHelper.GetMachineRandomKey(DbSqlConnection + AppSettingsHelper.GetMACIp(true));
public static readonly string JwtConfigIssuer = !string.IsNullOrEmpty(AppSettingsHelper.GetContent("JwtConfig", "Issuer")) ? AppSettingsHelper.GetContent("JwtConfig", "Issuer") : AppSettingsHelper.GetHostName();
public static readonly string JwtConfigAudience = AppSettingsHelper.GetContent("JwtConfig", "Audience");
#endregion

View File

@ -49,6 +49,8 @@ using DotLiquid.Util;
using System.IO;
using System.Text.RegularExpressions;
using CoreCms.Net.Model.ViewModels.User;
using CoreCms.Net.Repository.UnitOfWork;
using CoreCms.Net.IRepository.UnitOfWork;
namespace CoreCms.Net.Web.WebApi.Controllers
{
@ -125,7 +127,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
, ICoreCmsSettingServices settingServices
, ICoreCmsServicesServices servicesServices
, IOptions<WeChatOptions> weChatOptions
, ICoreCmsUserServicesOrderServices userServicesOrderServices, ICoreCmsUserServicesTicketServices userServicesTicketServices, ICoreCmsStoreServices storeServices, ICoreCmsCouponServices couponServices, ICoreCmsOrderServices orderServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, IToolsServices toolsServices, ICoreCmsUserBlacklistServices coreCmsUserBlacklistServices, SqlSugarScope dbBase)
, ICoreCmsUserServicesOrderServices userServicesOrderServices, ICoreCmsUserServicesTicketServices userServicesTicketServices, ICoreCmsStoreServices storeServices, ICoreCmsCouponServices couponServices, ICoreCmsOrderServices orderServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, IToolsServices toolsServices, ICoreCmsUserBlacklistServices coreCmsUserBlacklistServices, IUnitOfWork unitOfWork)
{
_user = user;
_userWeChatInfoServices = userWeChatInfoServices;
@ -160,7 +162,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
_weChatOptions = weChatOptions.Value;
_toolsServices = toolsServices;
_coreCmsUserBlacklistServices = coreCmsUserBlacklistServices;
_dbBase = dbBase;
_dbBase = unitOfWork.GetDbClient();
}
/// <summary>
/// wx.login登陆成功之后发送的请求

View File

@ -776,9 +776,15 @@
<param name="size">页大小</param>
<returns></returns>
</member>
<member name="M:CoreCms.Net.Web.WebApi.Controllers.SQController.GetMyUseReservation">
<summary>
获取正在进行的预约
</summary>
<returns></returns>
</member>
<member name="M:CoreCms.Net.Web.WebApi.Controllers.SQController.GetReservationList(System.Int32,System.Int32)">
<summary>
首页预约列表
</summary>
<param name="pageIndex"></param>
<param name="pageSize"></param>
@ -884,7 +890,7 @@
用户操作事件
</summary>
</member>
<member name="M:CoreCms.Net.Web.WebApi.Controllers.UserController.#ctor(CoreCms.Net.Auth.HttpContextUser.IHttpContextUser,CoreCms.Net.IServices.ICoreCmsUserWeChatInfoServices,CoreCms.Net.IServices.ICoreCmsUserServices,CoreCms.Net.Auth.Policys.PermissionRequirement,CoreCms.Net.IServices.ICoreCmsSmsServices,CoreCms.Net.IServices.ICoreCmsUserGradeServices,CoreCms.Net.IServices.ICoreCmsUserLogServices,Microsoft.AspNetCore.Http.IHttpContextAccessor,CoreCms.Net.IServices.ICoreCmsGoodsServices,CoreCms.Net.IServices.ICoreCmsGoodsBrowsingServices,CoreCms.Net.IServices.ICoreCmsCartServices,CoreCms.Net.IServices.ICoreCmsGoodsCollectionServices,CoreCms.Net.IServices.ICoreCmsUserShipServices,CoreCms.Net.IServices.ICoreCmsAreaServices,CoreCms.Net.IServices.ICoreCmsBillPaymentsServices,CoreCms.Net.IServices.ICoreCmsGoodsCommentServices,CoreCms.Net.IServices.ICoreCmsUserBankCardServices,CoreCms.Net.IServices.ICoreCmsUserTocashServices,CoreCms.Net.IServices.ICoreCmsUserBalanceServices,CoreCms.Net.IServices.ICoreCmsInvoiceServices,CoreCms.Net.IServices.ICoreCmsUserPointLogServices,CoreCms.Net.IServices.ICoreCmsShareServices,CoreCms.Net.IServices.ICoreCmsSettingServices,CoreCms.Net.IServices.ICoreCmsServicesServices,Microsoft.Extensions.Options.IOptions{CoreCms.Net.WeChat.Service.Options.WeChatOptions},CoreCms.Net.IServices.ICoreCmsUserServicesOrderServices,CoreCms.Net.IServices.ICoreCmsUserServicesTicketServices,CoreCms.Net.IServices.ICoreCmsStoreServices,CoreCms.Net.IServices.ICoreCmsCouponServices,CoreCms.Net.IServices.ICoreCmsOrderServices,CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory,CoreCms.Net.IServices.IToolsServices)">
<member name="M:CoreCms.Net.Web.WebApi.Controllers.UserController.#ctor(CoreCms.Net.Auth.HttpContextUser.IHttpContextUser,CoreCms.Net.IServices.ICoreCmsUserWeChatInfoServices,CoreCms.Net.IServices.ICoreCmsUserServices,CoreCms.Net.Auth.Policys.PermissionRequirement,CoreCms.Net.IServices.ICoreCmsSmsServices,CoreCms.Net.IServices.ICoreCmsUserGradeServices,CoreCms.Net.IServices.ICoreCmsUserLogServices,Microsoft.AspNetCore.Http.IHttpContextAccessor,CoreCms.Net.IServices.ICoreCmsGoodsServices,CoreCms.Net.IServices.ICoreCmsGoodsBrowsingServices,CoreCms.Net.IServices.ICoreCmsCartServices,CoreCms.Net.IServices.ICoreCmsGoodsCollectionServices,CoreCms.Net.IServices.ICoreCmsUserShipServices,CoreCms.Net.IServices.ICoreCmsAreaServices,CoreCms.Net.IServices.ICoreCmsBillPaymentsServices,CoreCms.Net.IServices.ICoreCmsGoodsCommentServices,CoreCms.Net.IServices.ICoreCmsUserBankCardServices,CoreCms.Net.IServices.ICoreCmsUserTocashServices,CoreCms.Net.IServices.ICoreCmsUserBalanceServices,CoreCms.Net.IServices.ICoreCmsInvoiceServices,CoreCms.Net.IServices.ICoreCmsUserPointLogServices,CoreCms.Net.IServices.ICoreCmsShareServices,CoreCms.Net.IServices.ICoreCmsSettingServices,CoreCms.Net.IServices.ICoreCmsServicesServices,Microsoft.Extensions.Options.IOptions{CoreCms.Net.WeChat.Service.Options.WeChatOptions},CoreCms.Net.IServices.ICoreCmsUserServicesOrderServices,CoreCms.Net.IServices.ICoreCmsUserServicesTicketServices,CoreCms.Net.IServices.ICoreCmsStoreServices,CoreCms.Net.IServices.ICoreCmsCouponServices,CoreCms.Net.IServices.ICoreCmsOrderServices,CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory,CoreCms.Net.IServices.IToolsServices,CoreCms.Net.IServices.ICoreCmsUserBlacklistServices,CoreCms.Net.IRepository.UnitOfWork.IUnitOfWork)">
<summary>
构造函数
</summary>
@ -1281,6 +1287,26 @@
</summary>
<returns></returns>
</member>
<member name="M:CoreCms.Net.Web.WebApi.Controllers.UserController.GetMyBlackList">
<summary>
获取黑名单列表
</summary>
<returns></returns>
</member>
<member name="M:CoreCms.Net.Web.WebApi.Controllers.UserController.AddUserBlack(CoreCms.Net.Model.FromBody.FMIntId)">
<summary>
添加黑名单
</summary>
<param name="entity"></param>
<returns></returns>
</member>
<member name="M:CoreCms.Net.Web.WebApi.Controllers.UserController.CancelUserBlack(CoreCms.Net.Model.FromBody.FMIntId)">
<summary>
取消拉黑名单
</summary>
<param name="entity"></param>
<returns></returns>
</member>
<member name="T:CoreCms.Net.Web.WebApi.Controllers.WeChatAppletsMessageController">
<summary>
微信小程序消息订阅接口