增加PostgreSQL支持;

修复DES加密
This commit is contained in:
yubaolee 2023-02-16 21:45:01 +08:00
parent 3890aa3fba
commit e0c8c46c9b
12 changed files with 1724 additions and 89 deletions

View File

@ -11,6 +11,7 @@
public const string DBTYPE_SQLSERVER = "SqlServer"; //sql server
public const string DBTYPE_MYSQL = "MySql"; //mysql
public const string DBTYPE_PostgreSQL = "PostgreSQL"; //PostgreSQL
public const string DBTYPE_ORACLE = "Oracle"; //oracle

View File

@ -7,7 +7,6 @@ namespace Infrastructure.Extensions
{
public static class SecurityEncDecryptExtensions
{
private static byte[] Keys = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
/// <summary>
/// DES加密字符串
@ -24,7 +23,7 @@ namespace Infrastructure.Extensions
byte[] rgbIV = Keys;
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
using (var DCSP = Aes.Create())
using (var DCSP = DES.Create())
{
using (MemoryStream mStream = new MemoryStream())
{
@ -41,7 +40,6 @@ namespace Infrastructure.Extensions
{
throw new Exception("密码加密异常" + ex.Message);
}
}
/// <summary>
@ -56,7 +54,7 @@ namespace Infrastructure.Extensions
byte[] rgbKey = Encoding.UTF8.GetBytes(decryptKey.Substring(0, 16));
byte[] rgbIV = Keys;
byte[] inputByteArray = Convert.FromBase64String(decryptString.Replace('_', '+').Replace('~', '/'));
using (var DCSP = Aes.Create())
using (var DCSP = DES.Create())
{
using (MemoryStream mStream = new MemoryStream())
{
@ -69,8 +67,8 @@ namespace Infrastructure.Extensions
}
}
}
}
public static bool TryDecryptDES(this string decryptString, string decryptKey, out string result)
{
result = "";

View File

@ -1,12 +1,15 @@
using Infrastructure;
using OpenAuth.App;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using Infrastructure;
using Microsoft.AspNetCore.Mvc;
using OpenAuth.App;
using OpenAuth.App.Interface;
using OpenAuth.App.Response;
using OpenAuth.Repository.Domain;
using System.Collections.Generic;
namespace OpenAuth.Mvc.Controllers
{

View File

@ -1,8 +1,10 @@
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using OpenAuth.App;
using OpenAuth.App.Interface;
using OpenAuth.Repository.Domain;

View File

@ -15,7 +15,7 @@
"SSOPassport": "http://localhost:52789",
"Version": "demo",
"DbTypes": {
"OpenAuthDBContext":"MySql" //SqlServerMySqlOracle
"OpenAuthDBContext":"MySql" //SqlServerMySqlOraclePostgreSQL
},
"RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123", //redis
"HttpHost": "http://*:1802" //

View File

@ -9,6 +9,7 @@
"ConnectionStrings": {
"OpenAuthDBContext": "Data Source=.;Initial Catalog=OpenAuthDB;User=sa;Password=000000"
//"OpenAuthDBContext": "server=127.0.0.1;user id=root;database=openauthdb;password=000000" //my sql
//"OpenAuthDBContext": "Host=localhost;Port=5432;Database=OpenAuth;Username=postgres;Password=123;" //PostgreSQL
},
"AppSetting": {
//"IdentityServerUrl": "http://localhost:12796", //IdentityServerOAuth
@ -16,7 +17,7 @@
"SSOPassport": "http://localhost:52789",
"Version": "1.0", //demopost
"DbTypes": {
"OpenAuthDBContext":"SqlServer" //SqlServerMySqlOracle
"OpenAuthDBContext": "SqlServer" //SqlServerMySqlOraclePostgreSQL
},
"RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123", //redis
"HttpHost": "http://*:1802" //

View File

@ -16,6 +16,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.10" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="MySql.Data" Version="8.0.13" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.10" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />

View File

@ -1,14 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Infrastructure;
using Infrastructure.Extensions;
using Infrastructure.Utilities;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.QueryObj;
@ -65,6 +67,10 @@ namespace OpenAuth.Repository
{
optionsBuilder.UseMySql(connect, new MySqlServerVersion(new Version(8, 0, 11)));
}
else if(dbType == Define.DBTYPE_PostgreSQL) //PostgreSQL
{
optionsBuilder.UseNpgsql(connect);
}
else
{
optionsBuilder.UseOracle(connect, options => options.UseOracleSQLCompatibility("11"));

View File

@ -27,7 +27,6 @@ namespace OpenAuth.WebApi.Model
{new OpenApiTag {Name = controllerActionDescriptor.ControllerName}};
}
}
}
}
}

View File

@ -15,7 +15,7 @@
"IdentityServerUrl": "", //IdentityServerOAuth
//"IdentityServerUrl": "http://demo.openauth.net.cn:12796", //IdentityServerOAuth
"DbTypes": {
"OpenAuthDBContext":"MySql" //SqlServerMySqlOracle
"OpenAuthDBContext":"MySql" //SqlServerMySqlOraclePostgreSQL
},
"UploadPath": "", //
"RedisConf": "your_redis_server:6379,password=your_redis_password", //redis

View File

@ -7,7 +7,9 @@
"AllowedHosts": "*",
"DataProtection": "temp-keys/",
"ConnectionStrings": {
"OpenAuthDBContext": "Data Source=.;Initial Catalog=OpenAuthPro;User=sa;Password=000000"
"OpenAuthDBContext": "Data Source=.;Initial Catalog=OpenAuthDB;User=sa;Password=000000"
//"OpenAuthDBContext": "server=127.0.0.1;user id=root;database=openauthdb;password=000000" //my sql
//"OpenAuthDBContext": "Host=localhost;Port=5432;Database=OpenAuth;Username=postgres;Password=123;" //PostgreSQL
//"OpenAuthDBContext2": "DATA SOURCE=192.168.0.118:1521/YUBAO;PASSWORD=000000;Validate Connection=true;PERSIST SECURITY INFO=True;USER ID=yubaolee;" //Oracle
//"OpenAuthDBContext3": "server=127.0.0.1;user id=root;database=openauthpro;password=000000" //my sql
},
@ -15,7 +17,8 @@
"IdentityServerUrl": "", //IdentityServerOAuth
// "IdentityServerUrl": "http://localhost:12796", //IdentityServerOAuth
"DbTypes": {
"OpenAuthDBContext":"SqlServer" //SqlServerMySqlOracle
"OpenAuthDBContext": "SqlServer" //SqlServerMySqlOraclePostgreSQL
// "OpenAuthDBContext":"PostgreSQL"
// ,"OpenAuthDBContext2":"Oracle"
// ,"OpenAuthDBContext3":"MySql"
},

File diff suppressed because it is too large Load Diff