mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 10:08:04 +08:00
增加PostgreSQL支持;
修复DES加密
This commit is contained in:
@@ -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
|
||||
{
|
||||
@@ -19,13 +22,13 @@ namespace OpenAuth.Mvc.Controllers
|
||||
}
|
||||
|
||||
// GET: /ModuleManager/
|
||||
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ActionResult Assign()
|
||||
{
|
||||
return View();
|
||||
@@ -41,7 +44,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
var modules = _app.LoadForRole(firstId);
|
||||
return JsonHelper.Instance.Serialize(modules);
|
||||
}
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// 获取角色已经分配的字段
|
||||
/// </summary>
|
||||
/// <param name="roleId">角色id</param>
|
||||
@@ -53,19 +56,19 @@ namespace OpenAuth.Mvc.Controllers
|
||||
try
|
||||
{
|
||||
var props = _app.LoadPropertiesForRole(roleId, moduleCode);
|
||||
var data = new Response<IEnumerable<string>>
|
||||
var data = new Response<IEnumerable<string>>
|
||||
{
|
||||
Result = props.ToList(),
|
||||
};
|
||||
return JsonHelper.Instance.Serialize(data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch(Exception ex)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(new Response
|
||||
{
|
||||
Message =ex.Message,
|
||||
Code = 500,
|
||||
});
|
||||
{
|
||||
Message = ex.Message,
|
||||
Code = 500,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +89,8 @@ namespace OpenAuth.Mvc.Controllers
|
||||
public string LoadAuthorizedMenus(string modulecode)
|
||||
{
|
||||
var user = _authUtil.GetCurrentUser();
|
||||
var module = user.Modules.First(u =>u.Code == modulecode);
|
||||
if (module != null)
|
||||
var module = user.Modules.First(u => u.Code == modulecode);
|
||||
if(module != null)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(module.Elements);
|
||||
|
||||
@@ -100,31 +103,31 @@ namespace OpenAuth.Mvc.Controllers
|
||||
|
||||
//添加模块
|
||||
[HttpPost]
|
||||
|
||||
|
||||
public string Add(Module model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.Add(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch(Exception ex)
|
||||
{
|
||||
Result.Code = 500;
|
||||
Result.Message = ex.InnerException?.Message??ex.Message;
|
||||
Result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(Result);
|
||||
}
|
||||
|
||||
//修改模块
|
||||
[HttpPost]
|
||||
|
||||
|
||||
public string Update(Module model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch(Exception ex)
|
||||
{
|
||||
Result.Code = 500;
|
||||
Result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
@@ -139,7 +142,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
_app.Delete(ids);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch(Exception e)
|
||||
{
|
||||
Result.Code = 500;
|
||||
Result.Message = e.InnerException?.Message ?? e.Message;
|
||||
@@ -160,7 +163,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
var user = _authUtil.GetCurrentUser();
|
||||
|
||||
var module = user.Modules.Single(u => u.Id == moduleId);
|
||||
|
||||
|
||||
var data = new TableData
|
||||
{
|
||||
data = module.Elements,
|
||||
@@ -171,14 +174,14 @@ namespace OpenAuth.Mvc.Controllers
|
||||
|
||||
//添加菜单
|
||||
[HttpPost]
|
||||
|
||||
|
||||
public string AddMenu(ModuleElement model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.AddMenu(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch(Exception ex)
|
||||
{
|
||||
Result.Code = 500;
|
||||
Result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
@@ -188,14 +191,14 @@ namespace OpenAuth.Mvc.Controllers
|
||||
|
||||
//添加菜单
|
||||
[HttpPost]
|
||||
|
||||
|
||||
public string UpdateMenu(ModuleElement model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_app.UpdateMenu(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch(Exception ex)
|
||||
{
|
||||
Result.Code = 500;
|
||||
Result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||
@@ -214,7 +217,7 @@ namespace OpenAuth.Mvc.Controllers
|
||||
{
|
||||
_app.DelMenu(ids);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch(Exception e)
|
||||
{
|
||||
Result.Code = 500;
|
||||
Result.Message = e.InnerException?.Message ?? e.Message;
|
||||
@@ -223,6 +226,6 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return JsonHelper.Instance.Serialize(Result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -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;
|
||||
@@ -27,12 +29,12 @@ namespace OpenAuth.Mvc.Models
|
||||
|
||||
//添加有允许匿名的Action,可以不用登录访问,如Login/Index
|
||||
var anonymous = description.MethodInfo.GetCustomAttribute(typeof(AllowAnonymousAttribute));
|
||||
if (anonymous != null)
|
||||
if(anonymous != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_authUtil.CheckLogin())
|
||||
if(!_authUtil.CheckLogin())
|
||||
{
|
||||
context.Result = new RedirectResult("/Login/Index");
|
||||
return;
|
||||
@@ -43,7 +45,7 @@ namespace OpenAuth.Mvc.Models
|
||||
//如果是ajax请求的,跳过模块授权认证
|
||||
var headers = context.HttpContext.Request.Headers;
|
||||
var xreq = headers.ContainsKey("x-requested-with");
|
||||
if (xreq && headers["x-requested-with"] == "XMLHttpRequest")
|
||||
if(xreq && headers["x-requested-with"] == "XMLHttpRequest")
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -51,22 +53,22 @@ namespace OpenAuth.Mvc.Models
|
||||
var Controllername = description.ControllerName.ToLower();
|
||||
var Actionname = description.ActionName.ToLower();
|
||||
//控制器白名单,在该名单中的控制器,需要登录,但不需要授权
|
||||
var whiteController = new[] {"usersession","home","redirects"};
|
||||
if (whiteController.Contains(Controllername))
|
||||
var whiteController = new[] { "usersession", "home", "redirects" };
|
||||
if(whiteController.Contains(Controllername))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//URL白名单
|
||||
var whiteurls = new[] {"usermanager/changepassword", "usermanager/profile"};
|
||||
if (whiteurls.Contains(Controllername + "/" + Actionname))
|
||||
var whiteurls = new[] { "usermanager/changepassword", "usermanager/profile" };
|
||||
if(whiteurls.Contains(Controllername + "/" + Actionname))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var currentModule = _authUtil.GetCurrentUser().Modules.FirstOrDefault(u => u.Url.ToLower().Contains(Controllername));
|
||||
//当前登录用户没有Action记录
|
||||
if (currentModule == null)
|
||||
if(currentModule == null)
|
||||
{
|
||||
context.Result = new RedirectResult("/Error/Auth");
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@
|
||||
"SSOPassport": "http://localhost:52789",
|
||||
"Version": "demo",
|
||||
"DbTypes": {
|
||||
"OpenAuthDBContext":"MySql" //数据库类型:SqlServer、MySql、Oracle
|
||||
"OpenAuthDBContext":"MySql" //数据库类型:SqlServer、MySql、Oracle、PostgreSQL
|
||||
},
|
||||
"RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123", //redis配置
|
||||
"HttpHost": "http://*:1802" //启动绑定地址及端口
|
||||
|
@@ -7,8 +7,9 @@
|
||||
"AllowedHosts": "*",
|
||||
"DataProtection": "temp-keys/",
|
||||
"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": "Host=localhost;Port=5432;Database=OpenAuth;Username=postgres;Password=123;" //PostgreSQL
|
||||
},
|
||||
"AppSetting": {
|
||||
//"IdentityServerUrl": "http://localhost:12796", //IdentityServer服务器地址。如果为空,则不启用OAuth认证
|
||||
@@ -16,7 +17,7 @@
|
||||
"SSOPassport": "http://localhost:52789",
|
||||
"Version": "1.0", //如果为demo,则可以防止post提交
|
||||
"DbTypes": {
|
||||
"OpenAuthDBContext":"SqlServer" //数据库类型:SqlServer、MySql、Oracle
|
||||
"OpenAuthDBContext": "SqlServer" //数据库类型:SqlServer、MySql、Oracle、PostgreSQL
|
||||
},
|
||||
"RedisConf": "redistest.cq-p.com.cn:8001,password=share_redis@123", //redis配置
|
||||
"HttpHost": "http://*:1802" //启动绑定地址及端口
|
||||
|
Reference in New Issue
Block a user