浏览代码

修改授权bug

master
王晓寒 1 个月前
父节点
当前提交
9191725458
共有 8 个文件被更改,包括 44 次插入31 次删除
  1. +2
    -2
      SafeCampus.API/SafeAuthActivate/App.config
  2. +25
    -15
      SafeCampus.API/SafeAuthActivate/Program.cs
  3. +2
    -2
      SafeCampus.API/SafeCampus.Core/Core.Development.json
  4. +3
    -3
      SafeCampus.API/SafeCampus.Web.Core/Controllers/System/Auth/ActivateAuthController.cs
  5. +9
    -6
      SafeCampus.API/SafeCampus.Web.Core/Filter/SystemAuthorizeMiddleware.cs
  6. +1
    -1
      SafeCampus.API/SafeCampus.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml.user
  7. +1
    -1
      SafeCampus.API/SafeCampus.Web.Entry/activation.config
  8. +1
    -1
      SafeCampus.API/SafeCampus.Web.Entry/appsettings.json

+ 2
- 2
SafeCampus.API/SafeAuthActivate/App.config 查看文件

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="SM2PublicKey" value="048A407FD953AD0318AAE08709EC6DF161BBB2A0A268DE20AFAC3C17131B046EEE6F1070F6DDC68066651F6BF6F2DC27ADFE11E78FDB4A042576F101E1BB999B0B"/>
<add key="SM2PrivateKey" value="76DDFE59DFA9FF27CA73EF1BC9BF02C473FE1FA7D181083BE828BF93E02CE9BC"/>
<add key="SM2PublicKey" value="04BD62406DF6789B1FBE8C457AECAE6D7C806CDB39316F190519905C24DF395E8952C47798D76ADECF8CA28C935702AFCDD9B17DE77121FA6448F0EDEFBD8365D6"/>
<add key="SM2PrivateKey" value="00F908E5ED9C2059A960E3A58056F69E0CF75299182CEB93B74CD1FDC633FCA0E5"/>
</appSettings>
</configuration>

+ 25
- 15
SafeCampus.API/SafeAuthActivate/Program.cs 查看文件

@@ -6,6 +6,9 @@ namespace SafeAuthActivate
{
static void Main(string[] args)
{
Console.WriteLine("===============AI监控预警分析平台授权程序==================");
Console.WriteLine("说明:\r\n1.首先部署好AI监控预警分析平台程序,浏览器打开程序首页\r\n2.运行授权器,将机器码输入到至注册器控制台程序中,输入到期时间,\r\n3.点击回车,将生成的注册码复制到激活码输入框中,并点击激活按钮。\r\n4.!!!!严重警告!!!!此软件禁止放在部署机上!!!!此软件严禁外传!!!!");
Console.WriteLine("=============================================================");
while (true)
{
try
@@ -14,25 +17,32 @@ namespace SafeAuthActivate
var time = "";
Console.Write("请输入机器码:");
var machineCode = Console.ReadLine();
var hardwareId = CryptogramUtil.Sm4Decrypt(CryptogramUtil.Sm2Decrypt(machineCode));
while (timeYZ)
if (string.IsNullOrEmpty(machineCode.Trim()))
{
Console.Write("请输入授权到期时间(例:2024-01-01):");
time = Console.ReadLine();
timeYZ = !DateTime.TryParse(time, out var activeTime);
if (timeYZ)
Console.WriteLine("机器码效验错误,请检查机器码正确性!");
}
else
{
var hardwareId = CryptogramUtil.Sm4Decrypt(CryptogramUtil.Sm2Decrypt(machineCode));
while (timeYZ)
{
Console.WriteLine("时间输入错误格式为【yyyy-MM-dd】(例:2024-01-01)");
Console.Write("请输入授权到期时间(例:2024-01-01):");
time = Console.ReadLine();
timeYZ = !DateTime.TryParse(time, out var activeTime);
if (timeYZ)
{
Console.WriteLine("时间输入错误格式为【yyyy-MM-dd】(例:2024-01-01)");
}
}
}

var code = CryptogramUtil.Sm2Encrypt(hardwareId + "$" + time);
Console.WriteLine("===============激活码生成成功请注意保存!=====================");
Console.WriteLine(code);
Console.WriteLine("==============================================================");
Console.Write("按任意键退出!");
Console.ReadLine();
Environment.Exit(0);
var code = CryptogramUtil.Sm2Encrypt(hardwareId + "$" + time);
Console.WriteLine("===============激活码生成成功请注意保存!=====================");
Console.WriteLine(code);
Console.WriteLine("==============================================================");
Console.Write("按任意键退出!");
Console.ReadLine();
Environment.Exit(0);
}
}
catch (Exception)
{


+ 2
- 2
SafeCampus.API/SafeCampus.Core/Core.Development.json 查看文件

@@ -3,8 +3,8 @@
"Cryptogram": {
//SM2国密配置
"SM2": {
"PublicKey": "048A407FD953AD0318AAE08709EC6DF161BBB2A0A268DE20AFAC3C17131B046EEE6F1070F6DDC68066651F6BF6F2DC27ADFE11E78FDB4A042576F101E1BB999B0B", //公钥
"PrivateKey": "76DDFE59DFA9FF27CA73EF1BC9BF02C473FE1FA7D181083BE828BF93E02CE9BC" //私钥
"PublicKey": "04BD62406DF6789B1FBE8C457AECAE6D7C806CDB39316F190519905C24DF395E8952C47798D76ADECF8CA28C935702AFCDD9B17DE77121FA6448F0EDEFBD8365D6", //公钥
"PrivateKey": "00F908E5ED9C2059A960E3A58056F69E0CF75299182CEB93B74CD1FDC633FCA0E5" //私钥
}
},
//日志配置


+ 3
- 3
SafeCampus.API/SafeCampus.Web.Core/Controllers/System/Auth/ActivateAuthController.cs 查看文件

@@ -46,16 +46,16 @@ public class ActivateAuthController : BaseController
var chaifen = yuanwen.Split('$');
if (chaifen.Length!=4)
{
throw Oops.Oh("激活信息不完整");
throw Oops.Oh("激活码错误!");
}
var isCorrect = DateTime.TryParse(chaifen[3],out var activeTime);
if (!isCorrect)
{
throw Oops.Oh("激活时间不正确");
throw Oops.Oh("激活码错误!");
}
if (chaifen[0] != await _machineUtil.GetProcessorId() || chaifen[1] != await _machineUtil.GetDiskId() || chaifen[2]!=await _machineUtil.GetMacAddress() || activeTime <= DateTime.Now)
{
throw Oops.Oh("激活信息不正确");
throw Oops.Oh("激活码错误!");
}
var filePath = Path.Combine(App.HostEnvironment.ContentRootPath, "activation.config");
await using StreamWriter writer = new StreamWriter(filePath);


+ 9
- 6
SafeCampus.API/SafeCampus.Web.Core/Filter/SystemAuthorizeMiddleware.cs 查看文件

@@ -40,13 +40,16 @@ public class SystemAuthorizeMiddleware
if (!string.IsNullOrEmpty(yuanwen2))
{
var chaifen = yuanwen2.Split('$');
var isCorrect = DateTime.TryParse(chaifen[3], out var activeTime);
if (chaifen.Length == 4 && isCorrect && chaifen[0] == await _machineUtil.GetProcessorId() && chaifen[1] == await _machineUtil.GetDiskId() &&
chaifen[2] == await _machineUtil.GetMacAddress() && activeTime > DateTime.Now)
if (chaifen.Length == 4)
{
// 调用下一个中间件
await _next(context);
return;
var isCorrect = DateTime.TryParse(chaifen[3], out var activeTime);
if (isCorrect && chaifen[0] == await _machineUtil.GetProcessorId() && chaifen[1] == await _machineUtil.GetDiskId() &&
chaifen[2] == await _machineUtil.GetMacAddress() && activeTime > DateTime.Now)
{
// 调用下一个中间件
await _next(context);
return;
}
}
}
msg = "授权已过期,请联系管理员授权";


+ 1
- 1
SafeCampus.API/SafeCampus.Web.Entry/Properties/PublishProfiles/FolderProfile.pubxml.user 查看文件

@@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project>
<PropertyGroup>
<_PublishTargetUrl>F:\Project\QJKJ\SafeCampus\SafeCampus.API\SafeCampus.Web.Entry\bin\Release\net6.0\publish\</_PublishTargetUrl>
<History>True|2024-12-09T05:47:34.5328594Z;True|2024-12-09T13:40:14.0307574+08:00;True|2024-12-09T13:37:06.9251645+08:00;True|2024-12-09T09:35:03.8007889+08:00;True|2024-12-05T17:55:26.3520105+08:00;True|2024-12-05T16:16:25.4547843+08:00;True|2024-12-05T15:40:26.7141856+08:00;True|2024-12-05T15:10:10.8427444+08:00;True|2024-12-04T17:22:28.7226032+08:00;True|2024-12-04T16:48:08.7253345+08:00;True|2024-12-04T13:36:58.9261836+08:00;True|2024-12-04T11:25:09.0287420+08:00;True|2024-12-04T10:49:03.6405687+08:00;True|2024-12-03T17:23:27.3622111+08:00;True|2024-12-03T17:04:39.8598677+08:00;True|2024-12-03T16:51:32.9879069+08:00;True|2024-12-03T16:43:48.1356230+08:00;True|2024-12-03T15:51:47.8248313+08:00;True|2024-11-22T11:28:53.1271820+08:00;True|2024-11-20T17:52:54.4158858+08:00;True|2024-11-20T17:26:43.3032818+08:00;True|2024-11-20T17:00:52.2470231+08:00;True|2024-11-20T13:48:46.8664181+08:00;True|2024-11-19T16:41:39.5873421+08:00;True|2024-11-19T16:11:53.2744549+08:00;True|2024-10-24T09:50:55.5191427+08:00;True|2024-10-24T09:34:12.7696084+08:00;True|2024-10-23T10:41:37.0558539+08:00;True|2024-10-23T09:28:31.4313071+08:00;True|2024-10-23T09:26:31.5501719+08:00;True|2024-10-23T09:23:51.0582343+08:00;True|2024-10-23T09:06:44.5849207+08:00;True|2024-10-22T13:08:17.1569031+08:00;True|2024-10-22T09:42:47.5945039+08:00;True|2024-10-21T17:29:20.3317104+08:00;True|2024-10-21T16:46:26.6984879+08:00;True|2024-10-21T10:12:44.0443975+08:00;True|2024-10-10T10:57:40.0075220+08:00;True|2024-10-10T10:02:41.0397715+08:00;True|2024-10-09T17:39:11.0140701+08:00;True|2024-10-09T17:18:07.5988076+08:00;True|2024-10-09T17:10:57.0818759+08:00;True|2024-10-09T17:08:07.1773134+08:00;True|2024-10-09T16:38:21.4832776+08:00;True|2024-10-09T16:31:58.3589164+08:00;True|2024-10-09T16:10:50.3337773+08:00;True|2024-10-09T10:39:55.8405182+08:00;True|2024-10-08T17:55:12.0035540+08:00;True|2024-10-08T16:48:00.5056466+08:00;True|2024-10-08T16:27:40.5071980+08:00;True|2024-10-08T16:24:26.2664694+08:00;True|2024-10-08T15:41:46.6016263+08:00;True|2024-09-30T17:07:19.0903067+08:00;True|2024-09-30T10:34:23.6203647+08:00;True|2024-09-29T14:44:27.0928205+08:00;True|2024-09-24T17:04:13.1154955+08:00;True|2024-09-23T14:58:29.0998917+08:00;True|2024-09-23T14:34:42.4664825+08:00;True|2024-09-23T14:34:14.9788969+08:00;True|2024-09-23T14:21:01.8969413+08:00;True|2024-09-23T14:17:25.6978104+08:00;True|2024-09-23T13:44:21.2948521+08:00;True|2024-09-23T13:42:29.2647186+08:00;True|2024-09-19T17:53:09.3428873+08:00;True|2024-09-19T17:47:47.8015573+08:00;True|2024-09-19T17:33:18.0038814+08:00;True|2024-09-19T17:13:16.6885326+08:00;True|2024-09-19T16:40:10.4911580+08:00;True|2024-09-19T15:32:43.5092007+08:00;True|2024-09-19T14:13:40.1278496+08:00;True|2024-09-19T11:00:03.7642790+08:00;True|2024-09-04T16:01:07.1761640+08:00;True|2024-09-04T15:47:33.3094448+08:00;True|2024-09-04T13:33:22.9396193+08:00;True|2024-08-30T13:27:03.2003529+08:00;True|2024-08-27T15:31:21.7026102+08:00;True|2024-08-20T11:12:26.7141701+08:00;True|2024-08-19T17:23:34.5703879+08:00;True|2024-08-19T15:55:28.3484786+08:00;True|2024-08-19T15:45:49.5623372+08:00;True|2024-08-19T14:56:17.7733738+08:00;True|2024-08-19T14:52:03.2782392+08:00;True|2024-08-19T14:10:57.7043528+08:00;True|2024-08-19T13:38:29.9236695+08:00;False|2024-08-19T13:29:18.8873264+08:00;True|2024-08-19T12:31:57.9280692+08:00;True|2024-08-19T11:50:36.7241244+08:00;True|2024-08-19T10:24:05.0018377+08:00;True|2024-08-19T10:23:30.0445364+08:00;True|2024-08-19T10:12:33.8316906+08:00;True|2024-08-19T10:10:48.0967630+08:00;True|2024-08-16T12:17:51.5743944+08:00;True|2024-08-16T11:36:15.1880346+08:00;True|2024-08-12T11:27:42.2864171+08:00;True|2024-08-09T14:54:42.9062124+08:00;True|2024-08-09T11:49:01.0339449+08:00;True|2024-08-09T11:43:21.9947939+08:00;True|2024-08-09T10:43:25.7641675+08:00;True|2024-08-08T15:23:17.0510180+08:00;True|2024-08-08T15:20:50.3450876+08:00;</History>
<History>True|2024-12-10T01:50:44.2129205Z;True|2024-12-10T09:37:03.1127511+08:00;True|2024-12-09T13:47:34.5328594+08:00;True|2024-12-09T13:40:14.0307574+08:00;True|2024-12-09T13:37:06.9251645+08:00;True|2024-12-09T09:35:03.8007889+08:00;True|2024-12-05T17:55:26.3520105+08:00;True|2024-12-05T16:16:25.4547843+08:00;True|2024-12-05T15:40:26.7141856+08:00;True|2024-12-05T15:10:10.8427444+08:00;True|2024-12-04T17:22:28.7226032+08:00;True|2024-12-04T16:48:08.7253345+08:00;True|2024-12-04T13:36:58.9261836+08:00;True|2024-12-04T11:25:09.0287420+08:00;True|2024-12-04T10:49:03.6405687+08:00;True|2024-12-03T17:23:27.3622111+08:00;True|2024-12-03T17:04:39.8598677+08:00;True|2024-12-03T16:51:32.9879069+08:00;True|2024-12-03T16:43:48.1356230+08:00;True|2024-12-03T15:51:47.8248313+08:00;True|2024-11-22T11:28:53.1271820+08:00;True|2024-11-20T17:52:54.4158858+08:00;True|2024-11-20T17:26:43.3032818+08:00;True|2024-11-20T17:00:52.2470231+08:00;True|2024-11-20T13:48:46.8664181+08:00;True|2024-11-19T16:41:39.5873421+08:00;True|2024-11-19T16:11:53.2744549+08:00;True|2024-10-24T09:50:55.5191427+08:00;True|2024-10-24T09:34:12.7696084+08:00;True|2024-10-23T10:41:37.0558539+08:00;True|2024-10-23T09:28:31.4313071+08:00;True|2024-10-23T09:26:31.5501719+08:00;True|2024-10-23T09:23:51.0582343+08:00;True|2024-10-23T09:06:44.5849207+08:00;True|2024-10-22T13:08:17.1569031+08:00;True|2024-10-22T09:42:47.5945039+08:00;True|2024-10-21T17:29:20.3317104+08:00;True|2024-10-21T16:46:26.6984879+08:00;True|2024-10-21T10:12:44.0443975+08:00;True|2024-10-10T10:57:40.0075220+08:00;True|2024-10-10T10:02:41.0397715+08:00;True|2024-10-09T17:39:11.0140701+08:00;True|2024-10-09T17:18:07.5988076+08:00;True|2024-10-09T17:10:57.0818759+08:00;True|2024-10-09T17:08:07.1773134+08:00;True|2024-10-09T16:38:21.4832776+08:00;True|2024-10-09T16:31:58.3589164+08:00;True|2024-10-09T16:10:50.3337773+08:00;True|2024-10-09T10:39:55.8405182+08:00;True|2024-10-08T17:55:12.0035540+08:00;True|2024-10-08T16:48:00.5056466+08:00;True|2024-10-08T16:27:40.5071980+08:00;True|2024-10-08T16:24:26.2664694+08:00;True|2024-10-08T15:41:46.6016263+08:00;True|2024-09-30T17:07:19.0903067+08:00;True|2024-09-30T10:34:23.6203647+08:00;True|2024-09-29T14:44:27.0928205+08:00;True|2024-09-24T17:04:13.1154955+08:00;True|2024-09-23T14:58:29.0998917+08:00;True|2024-09-23T14:34:42.4664825+08:00;True|2024-09-23T14:34:14.9788969+08:00;True|2024-09-23T14:21:01.8969413+08:00;True|2024-09-23T14:17:25.6978104+08:00;True|2024-09-23T13:44:21.2948521+08:00;True|2024-09-23T13:42:29.2647186+08:00;True|2024-09-19T17:53:09.3428873+08:00;True|2024-09-19T17:47:47.8015573+08:00;True|2024-09-19T17:33:18.0038814+08:00;True|2024-09-19T17:13:16.6885326+08:00;True|2024-09-19T16:40:10.4911580+08:00;True|2024-09-19T15:32:43.5092007+08:00;True|2024-09-19T14:13:40.1278496+08:00;True|2024-09-19T11:00:03.7642790+08:00;True|2024-09-04T16:01:07.1761640+08:00;True|2024-09-04T15:47:33.3094448+08:00;True|2024-09-04T13:33:22.9396193+08:00;True|2024-08-30T13:27:03.2003529+08:00;True|2024-08-27T15:31:21.7026102+08:00;True|2024-08-20T11:12:26.7141701+08:00;True|2024-08-19T17:23:34.5703879+08:00;True|2024-08-19T15:55:28.3484786+08:00;True|2024-08-19T15:45:49.5623372+08:00;True|2024-08-19T14:56:17.7733738+08:00;True|2024-08-19T14:52:03.2782392+08:00;True|2024-08-19T14:10:57.7043528+08:00;True|2024-08-19T13:38:29.9236695+08:00;False|2024-08-19T13:29:18.8873264+08:00;True|2024-08-19T12:31:57.9280692+08:00;True|2024-08-19T11:50:36.7241244+08:00;True|2024-08-19T10:24:05.0018377+08:00;True|2024-08-19T10:23:30.0445364+08:00;True|2024-08-19T10:12:33.8316906+08:00;True|2024-08-19T10:10:48.0967630+08:00;True|2024-08-16T12:17:51.5743944+08:00;True|2024-08-16T11:36:15.1880346+08:00;True|2024-08-12T11:27:42.2864171+08:00;True|2024-08-09T14:54:42.9062124+08:00;True|2024-08-09T11:49:01.0339449+08:00;True|2024-08-09T11:43:21.9947939+08:00;True|2024-08-09T10:43:25.7641675+08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

+ 1
- 1
SafeCampus.API/SafeCampus.Web.Entry/activation.config 查看文件

@@ -1 +1 @@
95d57b99ef8f7324c716380d8b5bcd48b36d8001fd9a536435c0bef458e331c25bd0abae598a42eda2f3a23ae3fb3a1057ffc94098c44c511e0a13c914f63c058770d91e5de256b46791df6c5b399b5d00a5632ca1816a38c4386b3ea60b0a6f8bb2825930b81fc9a3e164503c612569afd346868358586160611e3a65cd09d06407ff55295e1a0c53086a6f4809537aba14ab70d3c4b0680322dfea46d8b995fce361c5b5d585addef49d27d56349edbde775e1947ee16397d7aa002e54efcc8b206f50373a23817b37690abe792e2ddc03b7b873a668399f2862b49f8c8cc9af9149d369517e04b16151c91c6794801cb06dce5bb8f3952ec7f2048386d6a95bb936de588cf0f22494c70035b0ff9d395d3702618901b59b5181ba1a3d9f31e20bb545dd9dbf12d46b92a1f37d9c0df526c94087dc1145866224fde5b5be80c606f57db12aca9edbc092dd901337f5b570a57fd7ed6b69ea6a2092d739ada05
54aca00e64a212dd59daad739ab315bf6ef507e46b07185d8e88381af8bd04d9d3f198c9bfa80545fceec2168a32c7207f98cb0af57fa571a9b1815d9e3adfabf8bd1a82bce5300ffc9646d3c4206c345d6cc4aa40a8c122e725695fbced6f089cd8ff2d6713bc2837994349b3e64a15715d321d93e761f81b252db8816cbf677a5fbdf01be51652427819d5600248c3586103113679a1216d5a2830fd1046dee46a1bc821298936ba1b486533c069419365ffd70cedbbf37420cb25306e0042d84acef12eb7d73dc9b4922cf990c271b44d8c3268a7eec42df06447d7123d67d80b220101dc68a3f65e2ef95275b5ff4f46d5d9868babd9dbb86bd5b8072e7f231b28692a1c508c913ce539da82794de9711df2b3fca0e1e6b19b02dc8d98a13ca77489c7aa47061b4393cb5db6e9bdbc4d7de1a2c1113bbc5323a74149741276505834bca6129c551136e8a80dea5c

+ 1
- 1
SafeCampus.API/SafeCampus.Web.Entry/appsettings.json 查看文件

@@ -1,6 +1,6 @@
{
"AppSettings": {
"InjectSpecificationDocument": true, //是否开启swagger
"InjectSpecificationDocument": false, //是否开启swagger
"Urls": "http://0.0.0.0:5566" //监听地址
},
"AllowedHosts": "*",


正在加载...
取消
保存