mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-17 01:46:30 +08:00
Merge branch 'main' of https://gitee.com/dotnetchina/OpenAuth.Net
This commit is contained in:
commit
f18cf9ecc5
@ -3,7 +3,7 @@
|
|||||||
public static class Define
|
public static class Define
|
||||||
{
|
{
|
||||||
public static string USERROLE = "UserRole"; //用户角色关联KEY
|
public static string USERROLE = "UserRole"; //用户角色关联KEY
|
||||||
public const string ROLERESOURCE= "RoleResource"; //角色资源关联KEY
|
public const string ROLERESOURCE = "RoleResource"; //角色资源关联KEY
|
||||||
public const string USERORG = "UserOrg"; //用户机构关联KEY
|
public const string USERORG = "UserOrg"; //用户机构关联KEY
|
||||||
public const string ROLEELEMENT = "RoleElement"; //角色菜单关联KEY
|
public const string ROLEELEMENT = "RoleElement"; //角色菜单关联KEY
|
||||||
public const string ROLEMODULE = "RoleModule"; //角色模块关联KEY
|
public const string ROLEMODULE = "RoleModule"; //角色模块关联KEY
|
||||||
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
public const string DBTYPE_SQLSERVER = "SqlServer"; //sql server
|
public const string DBTYPE_SQLSERVER = "SqlServer"; //sql server
|
||||||
public const string DBTYPE_MYSQL = "MySql"; //mysql
|
public const string DBTYPE_MYSQL = "MySql"; //mysql
|
||||||
|
public const string DBTYPE_PostgreSQL = "PostgreSQL"; //PostgreSQL
|
||||||
public const string DBTYPE_ORACLE = "Oracle"; //oracle
|
public const string DBTYPE_ORACLE = "Oracle"; //oracle
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ namespace Infrastructure.Extensions
|
|||||||
{
|
{
|
||||||
public static class SecurityEncDecryptExtensions
|
public static class SecurityEncDecryptExtensions
|
||||||
{
|
{
|
||||||
|
|
||||||
private static byte[] Keys = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
|
private static byte[] Keys = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F };
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// DES加密字符串
|
/// DES加密字符串
|
||||||
@ -24,7 +23,7 @@ namespace Infrastructure.Extensions
|
|||||||
byte[] rgbIV = Keys;
|
byte[] rgbIV = Keys;
|
||||||
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
|
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
|
||||||
|
|
||||||
using (var DCSP = Aes.Create())
|
using (var DCSP = DES.Create())
|
||||||
{
|
{
|
||||||
using (MemoryStream mStream = new MemoryStream())
|
using (MemoryStream mStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
@ -41,7 +40,6 @@ namespace Infrastructure.Extensions
|
|||||||
{
|
{
|
||||||
throw new Exception("密码加密异常" + ex.Message);
|
throw new Exception("密码加密异常" + ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -56,7 +54,7 @@ namespace Infrastructure.Extensions
|
|||||||
byte[] rgbKey = Encoding.UTF8.GetBytes(decryptKey.Substring(0, 16));
|
byte[] rgbKey = Encoding.UTF8.GetBytes(decryptKey.Substring(0, 16));
|
||||||
byte[] rgbIV = Keys;
|
byte[] rgbIV = Keys;
|
||||||
byte[] inputByteArray = Convert.FromBase64String(decryptString.Replace('_', '+').Replace('~', '/'));
|
byte[] inputByteArray = Convert.FromBase64String(decryptString.Replace('_', '+').Replace('~', '/'));
|
||||||
using (var DCSP = Aes.Create())
|
using (var DCSP = DES.Create())
|
||||||
{
|
{
|
||||||
using (MemoryStream mStream = new MemoryStream())
|
using (MemoryStream mStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
@ -69,8 +67,8 @@ namespace Infrastructure.Extensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool TryDecryptDES(this string decryptString, string decryptKey, out string result)
|
public static bool TryDecryptDES(this string decryptString, string decryptKey, out string result)
|
||||||
{
|
{
|
||||||
result = "";
|
result = "";
|
||||||
|
@ -40,7 +40,9 @@ namespace OpenAuth.App
|
|||||||
objs = objs.Where(u => u.ColumnName.Contains(request.key));
|
objs = objs.Where(u => u.ColumnName.Contains(request.key));
|
||||||
}
|
}
|
||||||
|
|
||||||
result.data =await objs.OrderBy(u => u.ColumnName)
|
result.data =await objs.OrderByDescending(u => u.IsList)
|
||||||
|
.ThenBy(u=>u.Sort)
|
||||||
|
.ThenBy(u =>u.ColumnName)
|
||||||
.Skip((request.page - 1) * request.limit)
|
.Skip((request.page - 1) * request.limit)
|
||||||
.Take(request.limit).ToListAsync();
|
.Take(request.limit).ToListAsync();
|
||||||
result.count =await objs.CountAsync();
|
result.count =await objs.CountAsync();
|
||||||
|
@ -69,6 +69,7 @@ namespace OpenAuth.App
|
|||||||
var user = _auth.GetCurrentUser().User;
|
var user = _auth.GetCurrentUser().User;
|
||||||
UnitWork.Update<Category>(u => u.Id == obj.Id, u => new Category
|
UnitWork.Update<Category>(u => u.Id == obj.Id, u => new Category
|
||||||
{
|
{
|
||||||
|
Name = obj.Name,
|
||||||
Enable = obj.Enable,
|
Enable = obj.Enable,
|
||||||
DtValue = obj.DtValue,
|
DtValue = obj.DtValue,
|
||||||
DtCode = obj.DtCode,
|
DtCode = obj.DtCode,
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
using Infrastructure;
|
using System;
|
||||||
using OpenAuth.App;
|
using System.Collections.Generic;
|
||||||
using System;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
using Infrastructure;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
using OpenAuth.App;
|
||||||
using OpenAuth.App.Interface;
|
using OpenAuth.App.Interface;
|
||||||
using OpenAuth.App.Response;
|
using OpenAuth.App.Response;
|
||||||
using OpenAuth.Repository.Domain;
|
using OpenAuth.Repository.Domain;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace OpenAuth.Mvc.Controllers
|
namespace OpenAuth.Mvc.Controllers
|
||||||
{
|
{
|
||||||
@ -41,7 +44,7 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
var modules = _app.LoadForRole(firstId);
|
var modules = _app.LoadForRole(firstId);
|
||||||
return JsonHelper.Instance.Serialize(modules);
|
return JsonHelper.Instance.Serialize(modules);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取角色已经分配的字段
|
/// 获取角色已经分配的字段
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="roleId">角色id</param>
|
/// <param name="roleId">角色id</param>
|
||||||
@ -53,19 +56,19 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var props = _app.LoadPropertiesForRole(roleId, moduleCode);
|
var props = _app.LoadPropertiesForRole(roleId, moduleCode);
|
||||||
var data = new Response<IEnumerable<string>>
|
var data = new Response<IEnumerable<string>>
|
||||||
{
|
{
|
||||||
Result = props.ToList(),
|
Result = props.ToList(),
|
||||||
};
|
};
|
||||||
return JsonHelper.Instance.Serialize(data);
|
return JsonHelper.Instance.Serialize(data);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
return JsonHelper.Instance.Serialize(new Response
|
return JsonHelper.Instance.Serialize(new Response
|
||||||
{
|
{
|
||||||
Message =ex.Message,
|
Message = ex.Message,
|
||||||
Code = 500,
|
Code = 500,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,8 +89,8 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
public string LoadAuthorizedMenus(string modulecode)
|
public string LoadAuthorizedMenus(string modulecode)
|
||||||
{
|
{
|
||||||
var user = _authUtil.GetCurrentUser();
|
var user = _authUtil.GetCurrentUser();
|
||||||
var module = user.Modules.First(u =>u.Code == modulecode);
|
var module = user.Modules.First(u => u.Code == modulecode);
|
||||||
if (module != null)
|
if(module != null)
|
||||||
{
|
{
|
||||||
return JsonHelper.Instance.Serialize(module.Elements);
|
return JsonHelper.Instance.Serialize(module.Elements);
|
||||||
|
|
||||||
@ -107,10 +110,10 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
{
|
{
|
||||||
_app.Add(model);
|
_app.Add(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
Result.Code = 500;
|
Result.Code = 500;
|
||||||
Result.Message = ex.InnerException?.Message??ex.Message;
|
Result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
}
|
}
|
||||||
return JsonHelper.Instance.Serialize(Result);
|
return JsonHelper.Instance.Serialize(Result);
|
||||||
}
|
}
|
||||||
@ -124,7 +127,7 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
{
|
{
|
||||||
_app.Update(model);
|
_app.Update(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
Result.Code = 500;
|
Result.Code = 500;
|
||||||
Result.Message = ex.InnerException?.Message ?? ex.Message;
|
Result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
@ -139,7 +142,7 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
{
|
{
|
||||||
_app.Delete(ids);
|
_app.Delete(ids);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
Result.Code = 500;
|
Result.Code = 500;
|
||||||
Result.Message = e.InnerException?.Message ?? e.Message;
|
Result.Message = e.InnerException?.Message ?? e.Message;
|
||||||
@ -178,7 +181,7 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
{
|
{
|
||||||
_app.AddMenu(model);
|
_app.AddMenu(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
Result.Code = 500;
|
Result.Code = 500;
|
||||||
Result.Message = ex.InnerException?.Message ?? ex.Message;
|
Result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
@ -195,7 +198,7 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
{
|
{
|
||||||
_app.UpdateMenu(model);
|
_app.UpdateMenu(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
Result.Code = 500;
|
Result.Code = 500;
|
||||||
Result.Message = ex.InnerException?.Message ?? ex.Message;
|
Result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
@ -214,7 +217,7 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
{
|
{
|
||||||
_app.DelMenu(ids);
|
_app.DelMenu(ids);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
Result.Code = 500;
|
Result.Code = 500;
|
||||||
Result.Message = e.InnerException?.Message ?? e.Message;
|
Result.Message = e.InnerException?.Message ?? e.Message;
|
||||||
|
@ -140,6 +140,10 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(moduleCode))
|
||||||
|
{
|
||||||
|
throw new Exception("模块标识为空,不能分配可见字段");
|
||||||
|
}
|
||||||
var list = _authStrategyContext.GetTableColumns(moduleCode);
|
var list = _authStrategyContext.GetTableColumns(moduleCode);
|
||||||
return JsonHelper.Instance.Serialize(new TableData
|
return JsonHelper.Instance.Serialize(new TableData
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
|
||||||
using OpenAuth.App;
|
using OpenAuth.App;
|
||||||
using OpenAuth.App.Interface;
|
using OpenAuth.App.Interface;
|
||||||
using OpenAuth.Repository.Domain;
|
using OpenAuth.Repository.Domain;
|
||||||
@ -27,12 +29,12 @@ namespace OpenAuth.Mvc.Models
|
|||||||
|
|
||||||
//添加有允许匿名的Action,可以不用登录访问,如Login/Index
|
//添加有允许匿名的Action,可以不用登录访问,如Login/Index
|
||||||
var anonymous = description.MethodInfo.GetCustomAttribute(typeof(AllowAnonymousAttribute));
|
var anonymous = description.MethodInfo.GetCustomAttribute(typeof(AllowAnonymousAttribute));
|
||||||
if (anonymous != null)
|
if(anonymous != null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_authUtil.CheckLogin())
|
if(!_authUtil.CheckLogin())
|
||||||
{
|
{
|
||||||
context.Result = new RedirectResult("/Login/Index");
|
context.Result = new RedirectResult("/Login/Index");
|
||||||
return;
|
return;
|
||||||
@ -43,7 +45,7 @@ namespace OpenAuth.Mvc.Models
|
|||||||
//如果是ajax请求的,跳过模块授权认证
|
//如果是ajax请求的,跳过模块授权认证
|
||||||
var headers = context.HttpContext.Request.Headers;
|
var headers = context.HttpContext.Request.Headers;
|
||||||
var xreq = headers.ContainsKey("x-requested-with");
|
var xreq = headers.ContainsKey("x-requested-with");
|
||||||
if (xreq && headers["x-requested-with"] == "XMLHttpRequest")
|
if(xreq && headers["x-requested-with"] == "XMLHttpRequest")
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -51,22 +53,22 @@ namespace OpenAuth.Mvc.Models
|
|||||||
var Controllername = description.ControllerName.ToLower();
|
var Controllername = description.ControllerName.ToLower();
|
||||||
var Actionname = description.ActionName.ToLower();
|
var Actionname = description.ActionName.ToLower();
|
||||||
//控制器白名单,在该名单中的控制器,需要登录,但不需要授权
|
//控制器白名单,在该名单中的控制器,需要登录,但不需要授权
|
||||||
var whiteController = new[] {"usersession","home","redirects"};
|
var whiteController = new[] { "usersession", "home", "redirects" };
|
||||||
if (whiteController.Contains(Controllername))
|
if(whiteController.Contains(Controllername))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//URL白名单
|
//URL白名单
|
||||||
var whiteurls = new[] {"usermanager/changepassword", "usermanager/profile"};
|
var whiteurls = new[] { "usermanager/changepassword", "usermanager/profile" };
|
||||||
if (whiteurls.Contains(Controllername + "/" + Actionname))
|
if(whiteurls.Contains(Controllername + "/" + Actionname))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentModule = _authUtil.GetCurrentUser().Modules.FirstOrDefault(u => u.Url.ToLower().Contains(Controllername));
|
var currentModule = _authUtil.GetCurrentUser().Modules.FirstOrDefault(u => u.Url.ToLower().Contains(Controllername));
|
||||||
//当前登录用户没有Action记录
|
//当前登录用户没有Action记录
|
||||||
if (currentModule == null)
|
if(currentModule == null)
|
||||||
{
|
{
|
||||||
context.Result = new RedirectResult("/Error/Auth");
|
context.Result = new RedirectResult("/Error/Auth");
|
||||||
}
|
}
|
||||||
|
@ -41,4 +41,4 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript" src="/layui/layui.js"></script>
|
<script type="text/javascript" src="/layui/layui.js"></script>
|
||||||
<script type="text/javascript" src="/userJs/assignModule.js?v=3.3"></script>
|
<script type="text/javascript" src="/userJs/assignModule.js?v=3.4"></script>
|
@ -15,7 +15,7 @@
|
|||||||
"SSOPassport": "http://localhost:52789",
|
"SSOPassport": "http://localhost:52789",
|
||||||
"Version": "demo",
|
"Version": "demo",
|
||||||
"DbTypes": {
|
"DbTypes": {
|
||||||
"OpenAuthDBContext":"MySql" //数据库类型:SqlServer、MySql、Oracle
|
"OpenAuthDBContext":"MySql" //数据库类型:SqlServer、MySql、Oracle、PostgreSQL
|
||||||
},
|
},
|
||||||
"RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123", //redis配置
|
"RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123", //redis配置
|
||||||
"HttpHost": "http://*:1802" //启动绑定地址及端口
|
"HttpHost": "http://*:1802" //启动绑定地址及端口
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"DataProtection": "temp-keys/",
|
"DataProtection": "temp-keys/",
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"OpenAuthDBContext": "Data Source=.;Initial Catalog=OpenAuthDB;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": "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": {
|
"AppSetting": {
|
||||||
//"IdentityServerUrl": "http://localhost:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
|
//"IdentityServerUrl": "http://localhost:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
|
||||||
@ -16,7 +17,7 @@
|
|||||||
"SSOPassport": "http://localhost:52789",
|
"SSOPassport": "http://localhost:52789",
|
||||||
"Version": "1.0", //如果为demo,则可以防止post提交
|
"Version": "1.0", //如果为demo,则可以防止post提交
|
||||||
"DbTypes": {
|
"DbTypes": {
|
||||||
"OpenAuthDBContext":"SqlServer" //数据库类型:SqlServer、MySql、Oracle
|
"OpenAuthDBContext": "SqlServer" //数据库类型:SqlServer、MySql、Oracle、PostgreSQL
|
||||||
},
|
},
|
||||||
"RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123", //redis配置
|
"RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123", //redis配置
|
||||||
"HttpHost": "http://*:1802" //启动绑定地址及端口
|
"HttpHost": "http://*:1802" //启动绑定地址及端口
|
||||||
|
@ -243,9 +243,9 @@ layui.config({
|
|||||||
console.log(obj.type); //如果触发的是全选,则为:all,如果触发的是单选,则为:one
|
console.log(obj.type); //如果触发的是全选,则为:all,如果触发的是单选,则为:one
|
||||||
var ids=[];
|
var ids=[];
|
||||||
if(obj.type=="all"){
|
if(obj.type=="all"){
|
||||||
ids = layui.table.checkStatus('propList').data.map(function (m) { return m.Key; });
|
ids = layui.table.checkStatus('propList').data.map(function (m) { return m.ColumnName; });
|
||||||
}else{
|
}else{
|
||||||
ids =[obj.data.Key]
|
ids =[obj.data.ColumnName]
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = "/AccessObjs/AssignDataProperty";
|
var url = "/AccessObjs/AssignDataProperty";
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.10" />
|
||||||
<PackageReference Include="Moq" Version="4.13.1" />
|
<PackageReference Include="Moq" Version="4.13.1" />
|
||||||
<PackageReference Include="MySql.Data" Version="8.0.13" />
|
<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="NUnit" Version="3.13.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using Infrastructure.Extensions;
|
using Infrastructure.Extensions;
|
||||||
using Infrastructure.Utilities;
|
using Infrastructure.Utilities;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
using OpenAuth.Repository.Domain;
|
using OpenAuth.Repository.Domain;
|
||||||
using OpenAuth.Repository.QueryObj;
|
using OpenAuth.Repository.QueryObj;
|
||||||
|
|
||||||
@ -47,7 +49,7 @@ namespace OpenAuth.Repository
|
|||||||
|
|
||||||
var tenantId = _httpContextAccessor.GetTenantId();
|
var tenantId = _httpContextAccessor.GetTenantId();
|
||||||
string connect = _configuration.GetConnectionString(tenantId);
|
string connect = _configuration.GetConnectionString(tenantId);
|
||||||
if (string.IsNullOrEmpty(connect))
|
if(string.IsNullOrEmpty(connect))
|
||||||
{
|
{
|
||||||
throw new Exception($"未能找到租户{tenantId}对应的连接字符串信息");
|
throw new Exception($"未能找到租户{tenantId}对应的连接字符串信息");
|
||||||
}
|
}
|
||||||
@ -56,19 +58,23 @@ namespace OpenAuth.Repository
|
|||||||
var dbtypes = _configuration.GetSection("AppSetting:DbTypes").GetChildren()
|
var dbtypes = _configuration.GetSection("AppSetting:DbTypes").GetChildren()
|
||||||
.ToDictionary(x => x.Key, x => x.Value);
|
.ToDictionary(x => x.Key, x => x.Value);
|
||||||
|
|
||||||
var dbType = dbtypes[tenantId];
|
var dbType = dbtypes[tenantId];
|
||||||
if (dbType == Define.DBTYPE_SQLSERVER)
|
if(dbType == Define.DBTYPE_SQLSERVER)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer(connect);
|
optionsBuilder.UseSqlServer(connect);
|
||||||
}
|
}
|
||||||
else if(dbType == Define.DBTYPE_MYSQL) //mysql
|
else if(dbType == Define.DBTYPE_MYSQL) //mysql
|
||||||
{
|
{
|
||||||
optionsBuilder.UseMySql(connect, new MySqlServerVersion(new Version(8, 0, 11)));
|
optionsBuilder.UseMySql(connect, new MySqlServerVersion(new Version(8, 0, 11)));
|
||||||
}
|
}
|
||||||
else
|
else if(dbType == Define.DBTYPE_PostgreSQL) //PostgreSQL
|
||||||
{
|
{
|
||||||
optionsBuilder.UseOracle(connect,options =>options.UseOracleSQLCompatibility("11"));
|
optionsBuilder.UseNpgsql(connect);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
optionsBuilder.UseOracle(connect, options => options.UseOracleSQLCompatibility("11"));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace OpenAuth.WebApi.Model
|
|||||||
.Cast<ApiExplorerSettingsAttribute>().FirstOrDefault();
|
.Cast<ApiExplorerSettingsAttribute>().FirstOrDefault();
|
||||||
if (apiExplorerSettings != null && !string.IsNullOrWhiteSpace(apiExplorerSettings.GroupName))
|
if (apiExplorerSettings != null && !string.IsNullOrWhiteSpace(apiExplorerSettings.GroupName))
|
||||||
{
|
{
|
||||||
operation.Tags = new List<OpenApiTag> {new OpenApiTag {Name = apiExplorerSettings.GroupName}};
|
operation.Tags = new List<OpenApiTag> { new OpenApiTag { Name = apiExplorerSettings.GroupName } };
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -27,7 +27,6 @@ namespace OpenAuth.WebApi.Model
|
|||||||
{new OpenApiTag {Name = controllerActionDescriptor.ControllerName}};
|
{new OpenApiTag {Name = controllerActionDescriptor.ControllerName}};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,7 @@
|
|||||||
"IdentityServerUrl": "", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
|
"IdentityServerUrl": "", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
|
||||||
//"IdentityServerUrl": "http://demo.openauth.net.cn:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
|
//"IdentityServerUrl": "http://demo.openauth.net.cn:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
|
||||||
"DbTypes": {
|
"DbTypes": {
|
||||||
"OpenAuthDBContext":"MySql" //数据库类型:SqlServer、MySql、Oracle
|
"OpenAuthDBContext":"MySql" //数据库类型:SqlServer、MySql、Oracle、PostgreSQL
|
||||||
},
|
},
|
||||||
"UploadPath": "", //附件上传的路径,如果为空则保存在站点根目录
|
"UploadPath": "", //附件上传的路径,如果为空则保存在站点根目录
|
||||||
"RedisConf": "your_redis_server:6379,password=your_redis_password", //redis配置信息
|
"RedisConf": "your_redis_server:6379,password=your_redis_password", //redis配置信息
|
||||||
|
@ -7,20 +7,23 @@
|
|||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"DataProtection": "temp-keys/",
|
"DataProtection": "temp-keys/",
|
||||||
"ConnectionStrings": {
|
"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
|
//"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
|
//"OpenAuthDBContext3": "server=127.0.0.1;user id=root;database=openauthpro;password=000000" //my sql
|
||||||
},
|
},
|
||||||
"AppSetting": {
|
"AppSetting": {
|
||||||
"IdentityServerUrl": "", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
|
"IdentityServerUrl": "", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
|
||||||
// "IdentityServerUrl": "http://localhost:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
|
// "IdentityServerUrl": "http://localhost:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
|
||||||
"DbTypes": {
|
"DbTypes": {
|
||||||
"OpenAuthDBContext":"SqlServer" //数据库类型:SqlServer、MySql、Oracle
|
"OpenAuthDBContext": "SqlServer" //数据库类型:SqlServer、MySql、Oracle、PostgreSQL
|
||||||
// ,"OpenAuthDBContext2":"Oracle"
|
// "OpenAuthDBContext":"PostgreSQL"
|
||||||
// ,"OpenAuthDBContext3":"MySql"
|
// ,"OpenAuthDBContext2":"Oracle"
|
||||||
|
// ,"OpenAuthDBContext3":"MySql"
|
||||||
},
|
},
|
||||||
"UploadPath": "", //附件上传的路径,如果为空则保存在站点根目录
|
"UploadPath": "", //附件上传的路径,如果为空则保存在站点根目录
|
||||||
"RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123", //redis配置
|
"RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123", //redis配置
|
||||||
"HttpHost": "http://*:52789" //启动绑定地址及端口
|
"HttpHost": "http://*:52789" //启动绑定地址及端口
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1621
postgresql初始化备份/db_back.sql
Normal file
1621
postgresql初始化备份/db_back.sql
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user