大版本更新
This commit is contained in:
@@ -13,15 +13,15 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
public static IServiceCollection AddAuthorizationService(this IServiceCollection services)
|
||||
{
|
||||
//services.AddAuthorization(options =>
|
||||
//{
|
||||
// options.AddPolicy(PolicyName.Menu, polic =>
|
||||
// {
|
||||
// polic.AddRequirements(new CustomAuthorizationRequirement(PolicyEnum.MenuPermissions));
|
||||
// });
|
||||
//});
|
||||
services.AddAuthorization(options =>
|
||||
{
|
||||
options.AddPolicy(PolicyName.Sid, polic =>
|
||||
{
|
||||
polic.AddRequirements(new CustomAuthorizationRequirement(PolicyEnum.MenuPermissions));
|
||||
});
|
||||
});
|
||||
|
||||
//services.AddSingleton<IAuthorizationHandler, CustomAuthorizationHandler>();
|
||||
services.AddSingleton<IAuthorizationHandler, CustomAuthorizationHandler>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Yi.Framework.Common.IOCOptions;
|
||||
using Yi.Framework.Model;
|
||||
|
||||
namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
@@ -20,6 +21,11 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
#endregion
|
||||
services.AddSingleton(new Appsettings(configuration));
|
||||
|
||||
#region
|
||||
//数据库连接字符串
|
||||
#endregion
|
||||
services.Configure<SqlConnOptions>(Appsettings.appConfiguration("DbConn"));
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,11 +27,9 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = true,//是否验证Issuer
|
||||
ValidateIssuer = true,//是否验证Issuer
|
||||
ValidateAudience = true,//是否验证Audience
|
||||
ValidateLifetime = true,//是否验证失效时间
|
||||
|
||||
|
||||
ValidateIssuerSigningKey = true,//是否验证SecurityKey
|
||||
ValidAudience = jwtOptions.Audience,//Audience
|
||||
ValidIssuer = jwtOptions.Issuer,//Issuer,这两项和前面签发jwt的设置一致
|
||||
|
||||
@@ -12,11 +12,36 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
public static void AddSqlsugarServer(this IServiceCollection services)
|
||||
{
|
||||
DbType dbType;
|
||||
var slavaConFig = new List<SlaveConnectionConfig>();
|
||||
if (Appsettings.appBool("MutiDB_Enabled"))
|
||||
{
|
||||
var readCon = Appsettings.app<List<string>>("DbConn", "ReadUrl");
|
||||
|
||||
readCon.ForEach(s => {
|
||||
slavaConFig.Add(new SlaveConnectionConfig() { ConnectionString = s });
|
||||
});
|
||||
}
|
||||
|
||||
switch (Appsettings.app("DbSelect"))
|
||||
{
|
||||
case "Mysql": dbType = DbType.MySql; break;
|
||||
case "Sqlite": dbType = DbType.Sqlite; break;
|
||||
case "Sqlserver": dbType = DbType.SqlServer; break;
|
||||
case "Oracle": dbType = DbType.Oracle; break;
|
||||
default:throw new Exception("DbSelect配置写的TM是个什么东西?");
|
||||
}
|
||||
SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
DbType = SqlSugar.DbType.MySql,
|
||||
DbType = dbType,
|
||||
ConnectionString = Appsettings.app("DbConn", "WriteUrl"),
|
||||
IsAutoCloseConnection = true
|
||||
IsAutoCloseConnection = true,
|
||||
MoreSettings = new ConnMoreSettings()
|
||||
{
|
||||
DisableNvarchar = true
|
||||
},
|
||||
SlaveConnectionConfigs = slavaConFig,
|
||||
|
||||
},
|
||||
db =>
|
||||
{
|
||||
@@ -31,7 +56,6 @@ namespace Yi.Framework.WebCore.MiddlewareExtend
|
||||
{
|
||||
//entityInfo.SetValue(new Guid(httpcontext.Request.Headers["Id"].ToString()));
|
||||
}
|
||||
|
||||
if (entityInfo.PropertyName == "TenantId")
|
||||
{
|
||||
//entityInfo.SetValue(new Guid(httpcontext.Request.Headers["TenantId"].ToString()));
|
||||
|
||||
Reference in New Issue
Block a user