build: 移除对 Longbow.Configuration 的依赖
This commit is contained in:
parent
e16385ddd2
commit
6fa34c7500
|
@ -10,7 +10,6 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.2-beta4" />
|
||||
<PackageReference Include="Longbow.Logging" Version="3.0.2-beta1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.0.0-preview8.19405.7" />
|
||||
<PackageReference Include="Sentry.AspNetCore" Version="2.0.0-beta4" />
|
||||
|
|
|
@ -53,7 +53,6 @@ namespace Bootstrap.Admin
|
|||
});
|
||||
services.AddLogging(logging => logging.AddFileLogger().AddDBLogger(ExceptionsHelper.Log));
|
||||
services.AddCors();
|
||||
services.AddConfigurationManager();
|
||||
services.AddCacheManager();
|
||||
services.AddDbAdapter();
|
||||
services.AddIPLocator(DictHelper.ConfigIPLocator);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security" Version="3.0.0" />
|
||||
<PackageReference Include="Longbow.Configuration" Version="3.0.0" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.9.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Bootstrap.Security;
|
||||
using Longbow.Configuration;
|
||||
using Bootstrap.Security.Mvc;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization;
|
||||
|
@ -31,7 +31,7 @@ namespace Bootstrap.DataAccess.MongoDB
|
|||
if (!_register)
|
||||
{
|
||||
_register = true;
|
||||
ChangeToken.OnChange(() => ConfigurationManager.AppSettings.GetReloadToken(), () => _db = null);
|
||||
ChangeToken.OnChange(() => BootstrapAppContext.Configuration.GetReloadToken(), () => _db = null);
|
||||
InitClassMap();
|
||||
}
|
||||
if (_db == null)
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="3.0.1-beta2" />
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="3.0.1-beta3" />
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.2-beta5" />
|
||||
<PackageReference Include="Longbow" Version="3.0.0" />
|
||||
<PackageReference Include="Longbow.Cache" Version="3.0.0" />
|
||||
<PackageReference Include="Longbow.Configuration" Version="3.0.0" />
|
||||
<PackageReference Include="Longbow.Data" Version="3.0.0" />
|
||||
<PackageReference Include="Longbow.GiteeAuth" Version="3.0.0" />
|
||||
<PackageReference Include="Longbow.GitHubAuth" Version="3.0.0" />
|
||||
<PackageReference Include="Longbow.Cache" Version="3.0.1-beta1" />
|
||||
<PackageReference Include="Longbow.Data" Version="3.0.1-beta1" />
|
||||
<PackageReference Include="Longbow.GiteeAuth" Version="3.0.1-beta1" />
|
||||
<PackageReference Include="Longbow.GitHubAuth" Version="3.0.1-beta1" />
|
||||
<PackageReference Include="Longbow.OAuth" Version="3.0.1" />
|
||||
<PackageReference Include="Longbow.PetaPoco" Version="1.0.2" />
|
||||
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Bootstrap.Security;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Bootstrap.Security.Mvc;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Configuration;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -45,7 +45,7 @@ namespace Bootstrap.DataAccess
|
|||
if (menu != null && menu.Category == "0") return true;
|
||||
|
||||
// 演示系统
|
||||
var appMenus = ConfigurationManager.GetSection("AppMenus").Get<ICollection<string>>();
|
||||
var appMenus = BootstrapAppContext.Configuration.GetSection("AppMenus").Get<ICollection<string>>();
|
||||
if (appMenus.Any(m => m.Equals(menu.Name, System.StringComparison.OrdinalIgnoreCase))) return true;
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace Bootstrap.DataAccess
|
|||
if (!value.Any()) return true;
|
||||
|
||||
// 演示系统
|
||||
var appMenus = ConfigurationManager.GetSection("AppMenus").Get<ICollection<string>>();
|
||||
var appMenus = BootstrapAppContext.Configuration.GetSection("AppMenus").Get<ICollection<string>>();
|
||||
var appIds = RetrieveAllMenus("Admin").Where(m => appMenus.Any(app => m.Name.Equals(app, System.StringComparison.OrdinalIgnoreCase))).Select(m => m.Id);
|
||||
value = value.Where(m => !appIds.Any(app => app.Equals(m, System.StringComparison.OrdinalIgnoreCase)));
|
||||
if (!value.Any()) return true;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Bootstrap.Security;
|
||||
using Longbow.Configuration;
|
||||
using Bootstrap.Security.Mvc;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization;
|
||||
|
@ -31,7 +31,7 @@ namespace Bootstrap.Client.DataAccess.MongoDB
|
|||
if (!_register)
|
||||
{
|
||||
_register = true;
|
||||
ChangeToken.OnChange(() => ConfigurationManager.AppSettings.GetReloadToken(), () => _db = null);
|
||||
ChangeToken.OnChange(() => BootstrapAppContext.Configuration.GetReloadToken(), () => _db = null);
|
||||
InitClassMap();
|
||||
}
|
||||
if (_db == null)
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="3.0.1-beta2" />
|
||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="3.0.1-beta3" />
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.2-beta5" />
|
||||
<PackageReference Include="Longbow" Version="3.0.0" />
|
||||
<PackageReference Include="Longbow.Cache" Version="3.0.0" />
|
||||
<PackageReference Include="Longbow.Configuration" Version="3.0.0" />
|
||||
<PackageReference Include="Longbow.Data" Version="3.0.0" />
|
||||
<PackageReference Include="Longbow.Cache" Version="3.0.1-beta1" />
|
||||
<PackageReference Include="Longbow.Data" Version="3.0.1-beta1" />
|
||||
<PackageReference Include="Longbow.Web" Version="3.0.0" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.7.0" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using Bootstrap.Security;
|
||||
using Bootstrap.Security.DataAccess;
|
||||
using Bootstrap.Security.Mvc;
|
||||
using Longbow.Cache;
|
||||
using Longbow.Configuration;
|
||||
using Longbow.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -26,7 +26,7 @@ namespace Bootstrap.Client.DataAccess
|
|||
/// <returns></returns>
|
||||
public static IEnumerable<BootstrapMenu> RetrieveAppMenus(string userName, string activeUrl)
|
||||
{
|
||||
var appId = ConfigurationManager.GetValue("AppId", "");
|
||||
var appId = BootstrapAppContext.AppId;
|
||||
var menus = RetrieveAllMenus(userName).Where(m => m.Category == "1" && m.IsResource == 0 && m.Application == appId);
|
||||
return DbHelper.CascadeMenus(menus, activeUrl);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using Bootstrap.Security.DataAccess;
|
||||
using Longbow.Configuration;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bootstrap.Client.DataAccess
|
||||
|
@ -24,6 +23,6 @@ namespace Bootstrap.Client.DataAccess
|
|||
/// <param name="url"></param>
|
||||
/// <param name="appId"></param>
|
||||
/// <returns></returns>
|
||||
public virtual IEnumerable<string> RetrievesByUrl(string url, string appId) => DbHelper.RetrieveRolesByUrl(url, ConfigurationManager.GetValue("AppId", appId));
|
||||
public virtual IEnumerable<string> RetrievesByUrl(string url, string appId) => DbHelper.RetrieveRolesByUrl(url, appId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.2-beta4" />
|
||||
<PackageReference Include="Longbow.Logging" Version="3.0.2-beta1" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="3.0.0" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
using Bootstrap.Client.Models;
|
||||
using Longbow.Configuration;
|
||||
using Longbow.Data;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
|
||||
namespace Bootstrap.Client.Controllers
|
||||
|
@ -72,12 +72,13 @@ namespace Bootstrap.Client.Controllers
|
|||
/// <summary>
|
||||
/// 错误视图
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[AllowAnonymous]
|
||||
public IActionResult Error(int id)
|
||||
public IActionResult Error([FromServices]IConfiguration config, int id)
|
||||
{
|
||||
var options = ConfigurationManager.Get<BootstrapAdminAuthenticationOptions>();
|
||||
var options = config.GetBootstrapAdminAuthenticationOptions();
|
||||
var uriBuilder = new UriBuilder(options.AuthHost) { Query = QueryString.Create(CookieAuthenticationDefaults.ReturnUrlParameter, $"{Request.Scheme}://{Request.Host}{Request.PathBase}").ToString() };
|
||||
uriBuilder.Path = uriBuilder.Path == "/" ? Request.Path.Value : uriBuilder.Path + Request.Path.Value;
|
||||
return Redirect(uriBuilder.ToString());
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
using Microsoft.AspNetCore;
|
||||
|
||||
namespace Microsoft.Extensions.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// IConfiguration 扩展类
|
||||
/// </summary>
|
||||
public static class ConfigurationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// 获得 配置文件中 BootstrapAdminAuthenticationOptions 实例
|
||||
/// </summary>
|
||||
/// <param name="configuration"></param>
|
||||
/// <returns></returns>
|
||||
public static BootstrapAdminAuthenticationOptions GetBootstrapAdminAuthenticationOptions(this IConfiguration configuration) => configuration.GetSection<BootstrapAdminAuthenticationOptions>().Get<BootstrapAdminAuthenticationOptions>();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
using Bootstrap.Client.DataAccess;
|
||||
using Longbow.Configuration;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
@ -29,7 +29,8 @@ namespace Microsoft.AspNetCore.Builder
|
|||
var cookieValues = context.HttpContext.Request.Cookies.Select(cookie => $"{cookie.Key}={cookie.Value}");
|
||||
client.DefaultRequestHeaders.Add("Cookie", cookieValues);
|
||||
|
||||
var authHost = ConfigurationManager.Get<BootstrapAdminAuthenticationOptions>().AuthHost.TrimEnd(new char[] { '/' });
|
||||
var config = provider.GetRequiredService<IConfiguration>();
|
||||
var authHost = config.GetBootstrapAdminAuthenticationOptions().AuthHost.TrimEnd(new char[] { '/' });
|
||||
var url = $"{authHost}/api/Traces";
|
||||
client.BaseAddress = new Uri(url);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
using Bootstrap.Client.DataAccess;
|
||||
using Longbow.Configuration;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Security.Principal;
|
||||
|
||||
|
@ -15,10 +17,10 @@ namespace Bootstrap.Client.Models
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="identity"></param>
|
||||
public HeaderBarModel(IIdentity identity)
|
||||
/// <param name="controller"></param>
|
||||
public HeaderBarModel(ControllerBase controller)
|
||||
{
|
||||
var user = UserHelper.RetrieveUserByUserName(identity.Name);
|
||||
var user = UserHelper.RetrieveUserByUserName(controller.User.Identity.Name);
|
||||
DisplayName = user.DisplayName;
|
||||
UserName = user.UserName;
|
||||
SettingsUrl = DictHelper.RetrieveSettingsUrl(AppId);
|
||||
|
@ -26,7 +28,8 @@ namespace Bootstrap.Client.Models
|
|||
NotisUrl = DictHelper.RetrieveNotisUrl(AppId);
|
||||
|
||||
// set LogoutUrl
|
||||
var authHost = ConfigurationManager.Get<BootstrapAdminAuthenticationOptions>().AuthHost;
|
||||
var config = controller.HttpContext.RequestServices.GetRequiredService<IConfiguration>();
|
||||
var authHost = config.GetBootstrapAdminAuthenticationOptions().AuthHost;
|
||||
var uriBuilder = new UriBuilder(authHost);
|
||||
uriBuilder.Path = uriBuilder.Path == "/" ? CookieAuthenticationDefaults.LogoutPath.Value : $"{uriBuilder.Path.TrimEnd('/')}{CookieAuthenticationDefaults.LogoutPath.Value}";
|
||||
uriBuilder.Query = $"AppId={AppId}";
|
||||
|
@ -34,7 +37,7 @@ namespace Bootstrap.Client.Models
|
|||
|
||||
// set Icon
|
||||
var icon = $"/{DictHelper.RetrieveIconFolderPath().Trim('~', '/')}/{user.Icon}";
|
||||
Icon = user.Icon.Contains("://", StringComparison.OrdinalIgnoreCase) ? user.Icon : (string.IsNullOrEmpty(ConfigurationManager.GetValue("SimulateUserName", string.Empty)) ? $"{authHost.TrimEnd('/')}{icon}" : "/images/admin.jpg");
|
||||
Icon = user.Icon.Contains("://", StringComparison.OrdinalIgnoreCase) ? user.Icon : (string.IsNullOrEmpty(config.GetValue("SimulateUserName", string.Empty)) ? $"{authHost.TrimEnd('/')}{icon}" : "/images/admin.jpg");
|
||||
if (!string.IsNullOrEmpty(user.Css)) Theme = user.Css;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Bootstrap.Client.Models
|
|||
///
|
||||
/// </summary>
|
||||
/// <param name="controller"></param>
|
||||
public NavigatorBarModel(ControllerBase controller) : base(controller.User.Identity)
|
||||
public NavigatorBarModel(ControllerBase controller) : base(controller)
|
||||
{
|
||||
Navigations = MenuHelper.RetrieveAppMenus(UserName, $"~/{controller.ControllerContext.ActionDescriptor.ControllerName}/{controller.ControllerContext.ActionDescriptor.ActionName}");
|
||||
ImageLibUrl = DictHelper.RetrieveImagesLibUrl();
|
||||
|
|
|
@ -47,7 +47,6 @@ namespace Bootstrap.Client
|
|||
});
|
||||
services.AddCors();
|
||||
services.AddLogging(builder => builder.AddFileLogger());
|
||||
services.AddConfigurationManager();
|
||||
services.AddCacheManager();
|
||||
services.AddDbAdapter();
|
||||
services.AddBootstrapHttpClient();
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace Bootstrap.Admin.Api
|
|||
Assert.Contains("TotalDuration", cates);
|
||||
|
||||
// 测试数据库不能加载时健康检查
|
||||
var config = Longbow.Configuration.ConfigurationManager.AppSettings;
|
||||
var config = HealthCheckStartup.Configuration;
|
||||
config["DB:0:Enabled"] = "false";
|
||||
config["DB:4:Enabled"] = "true";
|
||||
config["DB:4:Widget"] = "Bootstrap.DataAccess.MongoDB1";
|
||||
|
@ -77,13 +77,12 @@ namespace Bootstrap.Admin.Api
|
|||
/// <summary>
|
||||
/// 获得 系统配置项 Iconfiguration 实例
|
||||
/// </summary>
|
||||
public IConfiguration Configuration { get; }
|
||||
public static IConfiguration Configuration { get; private set; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddCacheManager();
|
||||
services.AddConfigurationManager();
|
||||
services.AddDbAdapter();
|
||||
services.AddHealthChecks().AddCheck<DBHealthCheck>("db");
|
||||
services.AddControllers();
|
||||
|
|
Loading…
Reference in New Issue