diff --git a/BootstrapAdmin.sln b/BootstrapAdmin.sln index fc6f1cfd..dbe982b0 100644 --- a/BootstrapAdmin.sln +++ b/BootstrapAdmin.sln @@ -157,7 +157,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapClient.Web", "src\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootStarpAdmin.DataAccess.FreeSql", "src\blazor\admin\BootStarpAdmin.DataAccess.FreeSql\BootStarpAdmin.DataAccess.FreeSql.csproj", "{11122D97-B349-4A3E-B7DD-73B8B363C47C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BootStarpAdmin.DataAccess.SqlSugar", "src\blazor\admin\BootStarpAdmin.DataAccess.SqlSugar\BootStarpAdmin.DataAccess.SqlSugar.csproj", "{1D20E6CF-9825-4CDE-B732-AE586BD1AABA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootStarpAdmin.DataAccess.SqlSugar", "src\blazor\admin\BootStarpAdmin.DataAccess.SqlSugar\BootStarpAdmin.DataAccess.SqlSugar.csproj", "{1D20E6CF-9825-4CDE-B732-AE586BD1AABA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapClient.Web.Core", "src\blazor\client\BootstrapClient.Web.Core\BootstrapClient.Web.Core.csproj", "{FFDF9FF9-0B29-47D3-AD42-53A476B570EC}" EndProject @@ -165,6 +165,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapClient.DataAccess. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapAdmin.Caching", "src\blazor\admin\BootstrapAdmin.Caching\BootstrapAdmin.Caching.csproj", "{ADD20515-1C1C-418B-84F6-8B05A7AA315B}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vue", "vue", "{31F93CAE-7ADD-490F-A129-49D90FE4574A}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api", "api", "{FED2B095-F0EA-4E52-A095-BD4C5AEA5C04}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BootstrapAdmin.Api", "src\vue\api\BootstrapAdmin.Api\BootstrapAdmin.Api.csproj", "{7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -251,6 +257,10 @@ Global {ADD20515-1C1C-418B-84F6-8B05A7AA315B}.Debug|Any CPU.Build.0 = Debug|Any CPU {ADD20515-1C1C-418B-84F6-8B05A7AA315B}.Release|Any CPU.ActiveCfg = Release|Any CPU {ADD20515-1C1C-418B-84F6-8B05A7AA315B}.Release|Any CPU.Build.0 = Release|Any CPU + {7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -293,6 +303,9 @@ Global {FFDF9FF9-0B29-47D3-AD42-53A476B570EC} = {55A2459A-6BDE-4493-B2C0-5BE1673E99EE} {CC3DF23A-2880-438F-BDEB-DB093E919ABA} = {55A2459A-6BDE-4493-B2C0-5BE1673E99EE} {ADD20515-1C1C-418B-84F6-8B05A7AA315B} = {45ADEF9B-C8BD-4224-9E12-F6716E85A22C} + {31F93CAE-7ADD-490F-A129-49D90FE4574A} = {41B6D37A-5E5E-42B3-85E4-D81A81E3D757} + {FED2B095-F0EA-4E52-A095-BD4C5AEA5C04} = {31F93CAE-7ADD-490F-A129-49D90FE4574A} + {7B38D4EF-9297-40B4-ADA5-0A67FC82CF1C} = {FED2B095-F0EA-4E52-A095-BD4C5AEA5C04} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {221EAE38-5F75-4391-9A48-E462A9F3B8FC} diff --git a/src/vue/api/BootstrapAdmin.Api/Authencation/BootstrapAdminJwtHandler.cs b/src/vue/api/BootstrapAdmin.Api/Authencation/BootstrapAdminJwtHandler.cs new file mode 100644 index 00000000..e3993de0 --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/Authencation/BootstrapAdminJwtHandler.cs @@ -0,0 +1,70 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information. +// Website: https://admin.blazor.zone + +using Microsoft.IdentityModel.Tokens; +using System.IdentityModel.Tokens.Jwt; +using System.Security.Claims; +using System.Text; + +namespace BootstrapAdmin.Api.Authencation; + +/// +/// +/// +public static class BootstrapAdminJwtHandler +{ + /// + /// + /// + /// + /// + /// + public static string CreateToken(string userName, Action? configure = null) + { + ClaimsIdentity claimsIdentity = new ClaimsIdentity("Bearer"); + claimsIdentity.AddClaim(new Claim(ClaimTypes.Name, userName)); + JwtSecurityTokenHandler jwtSecurityTokenHandler = new JwtSecurityTokenHandler(); + TokenValidateOption tokenValidateOption = new TokenValidateOption(); + configure?.Invoke(tokenValidateOption); + return jwtSecurityTokenHandler.CreateEncodedJwt(new SecurityTokenDescriptor + { + Issuer = tokenValidateOption.Issuer, + Audience = tokenValidateOption.Audience, + Subject = claimsIdentity, + Expires = DateTime.Now.AddMinutes(tokenValidateOption.Expires), + SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(tokenValidateOption.SecurityKey)), "HS256") + }); + } + + /// + /// + /// + /// + public static string CreateRefershToken() + { + JwtSecurityTokenHandler jwtSecurityTokenHandler = new JwtSecurityTokenHandler(); + TokenValidateOption tokenValidateOption = new TokenValidateOption(); + return jwtSecurityTokenHandler.CreateEncodedJwt(new SecurityTokenDescriptor + { + Issuer = tokenValidateOption.Issuer, + Audience = tokenValidateOption.Audience, + Expires = DateTime.Now.AddMinutes(10), + SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(Encoding.UTF8.GetBytes(tokenValidateOption.SecurityKey)), "HS256") + }); + } + + /// + /// + /// + /// + /// + public static bool ValidateTokenExpires(string token) + { + JwtSecurityTokenHandler jwtSecurityTokenHandler = new JwtSecurityTokenHandler(); + var parmeter = jwtSecurityTokenHandler.ReadJwtToken(token); + var value = parmeter.Claims.FirstOrDefault(s => s.Type == ClaimTypes.Expired); + + return value!.Value != null; + } +} diff --git a/src/vue/api/BootstrapAdmin.Api/Authencation/TokenValidateOption.cs b/src/vue/api/BootstrapAdmin.Api/Authencation/TokenValidateOption.cs new file mode 100644 index 00000000..087fe7da --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/Authencation/TokenValidateOption.cs @@ -0,0 +1,32 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information. +// Website: https://admin.blazor.zone + +namespace BootstrapAdmin.Api.Authencation; + +/// +/// +/// +public class TokenValidateOption +{ + /// + /// + /// + public string Issuer { get; set; } = "BA"; + + /// + /// + /// + public string Audience { get; set; } = "api"; + + /// + /// + /// + public int Expires { get; set; } = 5; + + /// + /// + /// + public string SecurityKey { get; set; } = "BootstrapAdmin-V1.1"; + +} diff --git a/src/vue/api/BootstrapAdmin.Api/Authorization.cs b/src/vue/api/BootstrapAdmin.Api/Authorization.cs new file mode 100644 index 00000000..d65ce092 --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/Authorization.cs @@ -0,0 +1,12 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information. +// Website: https://admin.blazor.zone + +namespace BootstrapAdmin.Api; + +/// +/// +/// +public static class Authorization +{ +} diff --git a/src/vue/api/BootstrapAdmin.Api/BootstrapAdmin.Api.csproj b/src/vue/api/BootstrapAdmin.Api/BootstrapAdmin.Api.csproj new file mode 100644 index 00000000..cfbb2fcb --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/BootstrapAdmin.Api.csproj @@ -0,0 +1,33 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + + PreserveNewest + true + PreserveNewest + + + PreserveNewest + true + PreserveNewest + + + + diff --git a/src/vue/api/BootstrapAdmin.Api/BootstrapAdmin.db b/src/vue/api/BootstrapAdmin.Api/BootstrapAdmin.db new file mode 100644 index 00000000..e82319d9 Binary files /dev/null and b/src/vue/api/BootstrapAdmin.Api/BootstrapAdmin.db differ diff --git a/src/vue/api/BootstrapAdmin.Api/Controllers/AccountController.cs b/src/vue/api/BootstrapAdmin.Api/Controllers/AccountController.cs new file mode 100644 index 00000000..3a8f84b1 --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/Controllers/AccountController.cs @@ -0,0 +1,60 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information. +// Website: https://admin.blazor.zone + +using BootstrapAdmin.Api.Authencation; +using BootstrapAdmin.Api.Extensions; +using BootstrapAdmin.Api.Models; +using BootstrapAdmin.Web.Core; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; + +namespace BootstrapAdmin.Api.Controllers; + +/// +/// +/// +[Route("api/[controller]/[action]")] +[ApiController] +[Authorize] +public class AccountController : ControllerBase +{ + private IUser UserService { get; } + + /// + /// + /// + /// + public AccountController(IUser userService) => UserService = userService; + + /// + /// + /// + /// + [HttpPost] + public ActionResult Login([FromServices] IConfiguration configuration, [FromBody] LoginUser user) + { + string? token = null; + string? refershtoken = null; + string? userName = user.UserName; + string? password = user.Password; + if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password) && UserService.Authenticate(userName, password)) + { + token = BootstrapAdminJwtHandler.CreateToken(userName, op => + { + var tokenOption = configuration.GetOption(() => new TokenValidateOption()); + op.Audience = tokenOption.Audience; + op.Expires = tokenOption.Expires; + op.Issuer = tokenOption.Issuer; + op.SecurityKey = tokenOption.SecurityKey; + }); + refershtoken = BootstrapAdminJwtHandler.CreateRefershToken(); + return new LoginResult { Code = "account:200", Message = "login successed!", Token = token, RefershToken = refershtoken }; + + } + else + { + return new LoginResult { Code = "account:400", Message = "login failed!", Token = token, RefershToken = refershtoken }; + } + } +} diff --git a/src/vue/api/BootstrapAdmin.Api/Extensions/ConfigurationExtension.cs b/src/vue/api/BootstrapAdmin.Api/Extensions/ConfigurationExtension.cs new file mode 100644 index 00000000..2122a767 --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/Extensions/ConfigurationExtension.cs @@ -0,0 +1,41 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information. +// Website: https://admin.blazor.zone + +namespace BootstrapAdmin.Api.Extensions; + +/// +/// +/// +public static class ConfigurationExtension +{ + /// + /// + /// + /// + /// + /// + /// + public static T GetOption(this IConfiguration configuration, Func valueFactory) where T : class + { + T val = null; + Type typeFromHandle = typeof(T); + IConfigurationSection section = configuration.GetSection(typeFromHandle.Name); + if (!section.Exists()) + { + section = configuration.GetSection(typeFromHandle.FullName); + } + + if (section.Exists()) + { + val = section.Get(); + } + + if (val == null) + { + val = valueFactory(); + } + + return val; + } +} diff --git a/src/vue/api/BootstrapAdmin.Api/Extensions/ServiceCollectionExtension.cs b/src/vue/api/BootstrapAdmin.Api/Extensions/ServiceCollectionExtension.cs new file mode 100644 index 00000000..86b3556d --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/Extensions/ServiceCollectionExtension.cs @@ -0,0 +1,54 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information. +// Website: https://admin.blazor.zone + +using PetaPoco; +using PetaPoco.Providers; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.IdentityModel.Tokens; +using System.Text; +using BootstrapAdmin.Api.Authencation; + +namespace Microsoft.Extensions.DependencyInjection; + +/// +/// +/// +public static class ServiceCollectionExtension +{ + /// + /// + /// + /// + /// + public static IServiceCollection AddBootstrapAdminService(this IServiceCollection services) + { + + services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, option => + { + var tokenValidateOption = new TokenValidateOption(); + option.TokenValidationParameters = new TokenValidationParameters() + { + ValidateIssuer = true,//是否验证Issuer + ValidateAudience = true,//是否验证Audience + ValidateLifetime = true,//是否验证失效时间 + ClockSkew = TimeSpan.Zero, + ValidateIssuerSigningKey = true,//是否验证SecurityKey + ValidAudience = tokenValidateOption.Audience,//Audience + ValidIssuer = tokenValidateOption.Issuer,//Issuer,这两项和前面签发jwt的设置一致 + IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(tokenValidateOption.SecurityKey)),//拿到SecurityKey + }; + option.RequireHttpsMetadata = false; + }); + + services.AddPetaPocoDataAccessServices((provider, builder) => + { + var configuration = provider.GetRequiredService(); + var connString = configuration.GetConnectionString("bb"); + builder.UsingProvider() + .UsingConnectionString(connString); + }); + return services; + } +} diff --git a/src/vue/api/BootstrapAdmin.Api/Models/LoginResult.cs b/src/vue/api/BootstrapAdmin.Api/Models/LoginResult.cs new file mode 100644 index 00000000..148217ab --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/Models/LoginResult.cs @@ -0,0 +1,31 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information. +// Website: https://admin.blazor.zone + +namespace BootstrapAdmin.Api.Models; + +/// +/// +/// +public class LoginResult +{ + /// + /// + /// + public string? Code { get; set; } + + /// + /// + /// + public string? Message { get; set; } + + /// + /// + /// + public string? Token { get; set; } + + /// + /// + /// + public string? RefershToken { get; set; } +} diff --git a/src/vue/api/BootstrapAdmin.Api/Models/LoginUser.cs b/src/vue/api/BootstrapAdmin.Api/Models/LoginUser.cs new file mode 100644 index 00000000..455bf61a --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/Models/LoginUser.cs @@ -0,0 +1,21 @@ +// Copyright (c) Argo Zhang (argo@163.com). All rights reserved. +// Licensed under the LGPL License, Version 3.0. See License.txt in the project root for license information. +// Website: https://admin.blazor.zone + +namespace BootstrapAdmin.Api.Models; + +/// +/// +/// +public class LoginUser +{ + /// + /// + /// + public string? UserName { get; set; } + + /// + /// + /// + public string? Password { get; set; } +} diff --git a/src/vue/api/BootstrapAdmin.Api/Program.cs b/src/vue/api/BootstrapAdmin.Api/Program.cs new file mode 100644 index 00000000..5fbd188d --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/Program.cs @@ -0,0 +1,66 @@ +using Microsoft.OpenApi.Models; +using PetaPoco; +using PetaPoco.Providers; + +var builder = WebApplication.CreateBuilder(args); + +// Configure the service container. +builder.Services.AddControllers(); +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(options => +{ + options.SwaggerDoc("v1", new OpenApiInfo + { + Version = "v1", + Title = "BootstrapAdmin API" + }); + + //Set the comments path for the swagger json and ui. + //var xmlPath = Path.Combine(AppContext.BaseDirectory, "Bootstrap.Admin.xml"); + //options.IncludeXmlComments(xmlPath); + + options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme + { + Name = "Authorization", + Type = SecuritySchemeType.ApiKey, + Scheme = "Bearer", + BearerFormat = "JWT", + In = ParameterLocation.Header, + Description = "JWT Authorization header using the Bearer scheme." + }); + options.AddSecurityRequirement(new OpenApiSecurityRequirement + { + { + new OpenApiSecurityScheme + { + Reference = new OpenApiReference + { + Type = ReferenceType.SecurityScheme, + Id = "Bearer" + } + }, + new string[]{ } + } + }); +}); +builder.Services.AddBootstrapAdminService(); + + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(option => + { + option.DocumentTitle = "BootstrapAdmin API V1"; + }); +} + +app.UseAuthentication(); +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); diff --git a/src/vue/api/BootstrapAdmin.Api/Properties/launchSettings.json b/src/vue/api/BootstrapAdmin.Api/Properties/launchSettings.json new file mode 100644 index 00000000..36c9dd56 --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:11008", + "sslPort": 0 + } + }, + "profiles": { + "BootstrapAdmin.Api": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5046", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/vue/api/BootstrapAdmin.Api/appsettings.Development.json b/src/vue/api/BootstrapAdmin.Api/appsettings.Development.json new file mode 100644 index 00000000..47155e1f --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/appsettings.Development.json @@ -0,0 +1,350 @@ +{ + "DetailedErrors": true, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information", + "Longbow.Tasks": "Error" + }, + "LgbFile": { + "IncludeScopes": true, + "LogLevel": { + "Default": "Error" + }, + "FileName": "Error\\Log.log" + } + }, + "SimulateUserName": "", + "AutoGenerateDatabase": true, + "BootstrapAdminAuthenticationOptions": { + "KeyPath": "..\\..\\keys" + }, + "DB": [ + { + "Enabled": false, + "ProviderName": "SqlServer", + "SqlFolder": "..\\..\\..\\db\\SqlServer", + "ConnectionStrings": { + "ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa" + } + }, + { + "Enabled": true, + "ProviderName": "Sqlite", + "SqlFolder": "..\\..\\..\\db\\SQLite", + "ConnectionStrings": { + "ba": "Data Source=BootstrapAdmin.db;" + } + }, + { + "Enabled": false, + "ProviderName": "MySql", + "SqlFolder": "..\\..\\..\\db\\MySQL", + "ConnectionStrings": { + "ba": "Server=localhost;Database=BA;Uid=argozhang;Pwd=argo@163.com;SslMode=none;" + } + }, + { + "Enabled": false, + "ProviderName": "Oracle", + "ConnectionStrings": { + "ba": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XXXXXX)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL)));User Id=XX;Password=XX" + } + }, + { + "Enabled": false, + "ProviderName": "Npgsql", + "ConnectionStrings": { + "ba": "Server=localhost;Database=BootstrapAdmin;User ID=argozhang;Password=argo@163.com;" + } + }, + { + "Enabled": false, + "Widget": "Bootstrap.DataAccess.MongoDB", + "ProviderName": "MongoDB", + "SqlFolder": "..\\..\\..\\db\\MongoDB", + "ConnectionStrings": { + "ba": "mongodb://localhost:27017/BootstrapAdmin" + } + } + ], + "SwaggerPathBase": "", + "GiteeHealthChecks": "true", + "AllowOrigins": "http://localhost:49185", + "HealthsCloudUrl": "https://client.blazor.zone/api/Interface/Healths", + "FileStorageOptions": { + "Enabled": true, + "Folder": "TaskStorage", + "Secure": false + }, + "GiteeOptions": { + "Enabled": true, + "ClientId": "9bfe9b95d813ca7d613b110a54eda28bf227154b314c95f0c69e7680d64525e1", + "ClientSecret": "3427f2d901ba9afc76c1842a7303b2d67f8e098e71acc15051f89fe6f3d265db", + "CallbackPath": "/signin-gitee", + "HomePath": "/Admin/Profiles", + "Scope": [ "user_info", "projects" ], + "Roles": [ "Administrators" ], + "App": "Demo", + "StarredUrl": "https://gitee.com/api/v5/user/starred/LongbowEnterprise/BootstrapAdmin" + }, + "GitHubOptions": { + "Enabled": true, + "ClientId": "ec53ecfe238558a0423b", + "ClientSecret": "ffa759ca599df941b869efecb5e750bc1b27334e", + "CallbackPath": "/signin-github", + "HomePath": "/Admin/Profiles", + "Scope": [ "user_info", "repo" ], + "Roles": [ "Administrators" ], + "App": "Demo", + "StarredUrl": "https://api.github.com/user/starred/ArgoZhang/BootstrapAdmin" + }, + "WeChatOptions": { + "Enabled": true, + "ClientId": "", + "ClientSecret": "", + "CallbackPath": "/signin-weixin", + "HomePath": "/Admin/Profiles", + "Scope": [ "snsapi_login" ], + "Roles": [ "Administrators" ], + "App": "Demo" + }, + "TencentOptions": { + "Enabled": true, + "ClientId": "", + "ClientSecret": "", + "CallbackPath": "/signin-tencent", + "HomePath": "/Admin/Profiles", + "Scope": [ "get_user_info" ], + "Roles": [ "Administrators" ], + "App": "Demo" + }, + "SMSOptions": { + "CompanyCode": "", + "MD5Key": "MD5Key", + "Roles": [ "Administrators" ], + "HomePath": "/Admin/Profiles", + "App": "Demo" + }, + "AlipayOptions": { + "Enabled": true, + "ClientId": "", + "ClientSecret": "", + "CallbackPath": "/signin-alipay", + "HomePath": "/Admin/Profiles", + "SignKey": "", + "Scope": [ "auth_user" ], + "Roles": [ "Administrators" ], + "App": "Demo" + }, + "TencentSMSOptions": { + "AppId": "", + "AppKey": "", + "TplId": 0, + "Sign": "", + "Roles": [ "Default" ], + "HomePath": "/Admin/Profiles", + "App": "Demo", + "Debug": true + }, + "AppMenus": [ + "首页", + "测试页面", + "关于", + "返回码云", + "多级菜单", + "第二层", + "第三层", + "第四层" + ], + "LongbowCache": { + "Enabled": true, + "CorsItems": [ + { + "Enabled": true, + "Key": "ba", + "Url": "CacheList.axd", + "Desc": "后台管理数据缓存接口", + "Self": true + }, + { + "Enabled": true, + "Key": "App", + "Url": "http://localhost:49185/CacheList.axd", + "Desc": "测试系统", + "Self": false + } + ], + "CacheItems": [ + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRolesByUserName", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "指定用户角色数据缓存" + }, + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRolesByUrl", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过菜单获得角色数据" + }, + { + "Enabled": true, + "Key": "AppHelper-RetrieveAppsByUserName", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "指定用户授权应用数据缓存" + }, + { + "Enabled": true, + "Key": "BootstrapUser-RetrieveUsersByName", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "登录用户数据" + }, + { + "Enabled": true, + "Key": "BootstrapDict-RetrieveDicts", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "所有字典数据缓存" + }, + { + "Enabled": true, + "Key": "BootstrapMenu-RetrieveMenus", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "用户所有菜单数据缓存" + }, + { + "Enabled": true, + "Key": "GroupHelper-RetrieveGroupsByUserName", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "指定用户组数据缓存" + }, + { + "Enabled": true, + "Key": "UserHelper-RetrieveUsers", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "所有用户数据" + }, + { + "Enabled": true, + "Key": "UserHelper-RetrieveUsersByRoleId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过角色ID获得所有用户数据" + }, + { + "Enabled": true, + "Key": "UserHelper-RetrieveUsersByGroupId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过部门ID获得所有用户数据" + }, + { + "Enabled": true, + "Key": "UserHelper-RetrieveNewUsers", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "新用户数据" + }, + { + "Enabled": true, + "Key": "MenuHelper-RetrieveMenusByRoleId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过角色ID获得所有菜单数据" + }, + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRoles", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "所有角色数据" + }, + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRolesByUserId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过用户ID获得所有角色数据" + }, + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRolesByMenuId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过菜单ID获得所有角色数据" + }, + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRolesByGroupId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过部门ID获得所有角色数据" + }, + { + "Enabled": true, + "Key": "GroupHelper-RetrieveGroups", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "所有部门数据" + }, + { + "Enabled": true, + "Key": "GroupHelper-RetrieveGroupsByUserId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过用户ID获得所有部门数据" + }, + { + "Enabled": true, + "Key": "GroupHelper-RetrieveGroupsByRoleId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过角色ID获得所有部门数据" + }, + { + "Enabled": true, + "Key": "AppHelper-RetrieveAppsByRoleId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过角色ID获得所有应用程序数据" + }, + { + "Enabled": true, + "Key": "DictHelper-RetrieveDictsCategory", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "字典分类数据" + }, + { + "Enabled": true, + "Key": "ExceptionHelper-RetrieveExceptions", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "程序异常数据" + }, + { + "Enabled": true, + "Key": "MessageHelper-RetrieveMessages", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "站内消息数据" + }, + { + "Enabled": true, + "Key": "TaskHelper-RetrieveTasks", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "所有任务数据" + } + ] + } +} \ No newline at end of file diff --git a/src/vue/api/BootstrapAdmin.Api/appsettings.json b/src/vue/api/BootstrapAdmin.Api/appsettings.json new file mode 100644 index 00000000..c67bc152 --- /dev/null +++ b/src/vue/api/BootstrapAdmin.Api/appsettings.json @@ -0,0 +1,350 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + }, + "LgbFile": { + "IncludeScopes": true, + "LogLevel": { + "Default": "Error" + }, + "FileName": "Error\\Log.log" + }, + "Cloud": { + "LogLevel": { + "Default": "Error" + }, + "Url": "https://client.blazor.zone/api/Interface/Log" + } + }, + "ConnectionStrings": { + "ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa", + "bb": "Data Source=BootstrapAdmin.db;" + }, + "AutoGenerateDatabase": false, + "DB": [ + { + "Enabled": false, + "ProviderName": "SqlServer", + "ConnectionStrings": { + "ba": "Data Source=.;Initial Catalog=BootstrapAdmin;User ID=sa;Password=sa" + } + }, + { + "Enabled": true, + "ProviderName": "Sqlite", + "ConnectionStrings": { + "ba": "Data Source=BootstrapAdmin.db;" + } + }, + { + "Enabled": false, + "ProviderName": "MySql", + "ConnectionStrings": { + "ba": "Server=localhost;Database=BA;Uid=argozhang;Pwd=argo@163.com;SslMode=none;" + } + }, + { + "Enabled": false, + "ProviderName": "Npgsql", + "ConnectionStrings": { + "ba": "Server=localhost;Database=BootstrapAdmin;User ID=argozhang;Password=argo@163.com;" + } + }, + { + "Enabled": false, + "Widget": "Bootstrap.DataAccess.MongoDB", + "ProviderName": "MongoDB", + "ConnectionStrings": { + "ba": "mongodb://localhost:27017/BootstrapAdmin" + } + } + ], + "AppId": "BA", + "UseHttps": true, + "SwaggerPathBase": "", + "AllowOrigins": "http://localhost,http://admin.blazor.zone", + "HealthsCloudUrl": "https://client.blazor.zone/api/Interface/Healths", + "GiteeHealthChecks": false, + "Sentry": { + "Dsn": "https://70bdfff562e84fa7b9a43d65924ab9ad@sentry.io/1469396" + }, + "BootstrapBlazorOptions": { + "DefaultCultureInfo": "zh-CN" + }, + "Exceptionless": { + "ApiKey": "AgQlY1MRWpX5qOF2edpK2IZYBhgPYImhr4UnZdAT" + }, + "TokenValidateOption": { + "Issuer": "BA", + "Audience": "api", + "Expires": 5, + "SecurityKey": "BootstrapAdmin-V1.1" + }, + "TaskServicesOptions": { + "ShutdownTimeout": "00:00:05" + }, + "FileStorageOptions": { + "Enabled": true, + "Folder": "TaskStorage", + "Secure": true + }, + "GiteeOptions": { + "Enabled": true, + "ClientId": "", + "ClientSecret": "", + "CallbackPath": "/signin-gitee", + "HomePath": "/Home/Index", + "Scope": [ "user_info", "projects" ], + "Roles": [ "Default" ], + "App": "Demo" + }, + "GitHubOptions": { + "Enabled": true, + "ClientId": "", + "ClientSecret": "", + "CallbackPath": "/signin-github", + "HomePath": "/Home/Index", + "Scope": [ "user_info", "repo" ], + "Roles": [ "Default" ], + "App": "Demo" + }, + "WeChatOptions": { + "Enabled": true, + "ClientId": "", + "ClientSecret": "", + "CallbackPath": "/signin-weixin", + "HomePath": "/Admin/Profiles", + "Scope": [ "snsapi_login" ], + "Roles": [ "Default" ], + "App": "Demo" + }, + "TencentOptions": { + "Enabled": true, + "ClientId": "", + "ClientSecret": "", + "CallbackPath": "/signin-tencent", + "HomePath": "/Admin/Profiles", + "Scope": [ "get_user_info" ], + "Roles": [ "Administrators" ], + "App": "Demo" + }, + "AlipayOptions": { + "Enabled": true, + "ClientId": "", + "ClientSecret": "", + "CallbackPath": "/signin-alipay", + "HomePath": "/Admin/Profiles", + "SignKey": "", + "Scope": [ "auth_user" ], + "Roles": [ "Administrators" ], + "App": "Demo" + }, + "SMSOptions": { + "CompanyCode": "", + "MD5Key": "MD5Key", + "Roles": [ "Default" ], + "HomePath": "/Home/Index", + "App": "Demo" + }, + "TencentSMSOptions": { + "AppId": "", + "AppKey": "", + "TplId": 0, + "Sign": "", + "Roles": [ "Default" ], + "HomePath": "/Admin/Profiles", + "App": "Demo" + }, + "LongbowCache": { + "Enabled": true, + "CorsItems": [ + { + "Enabled": true, + "Key": "ba", + "Url": "CacheList.axd", + "Desc": "后台管理数据缓存接口", + "Self": true + }, + { + "Enabled": true, + "Key": "App", + "Url": "../Client/CacheList.axd", + "Desc": "测试系统", + "Self": false + } + ], + "CacheItems": [ + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRolesByUserName", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "指定用户角色数据缓存" + }, + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRolesByUrl", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过菜单获得角色数据" + }, + { + "Enabled": true, + "Key": "AppHelper-RetrieveAppsByUserName", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "指定用户授权应用数据缓存" + }, + { + "Enabled": true, + "Key": "BootstrapUser-RetrieveUsersByName", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "登录用户数据" + }, + { + "Enabled": true, + "Key": "BootstrapDict-RetrieveDicts", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "所有字典数据缓存" + }, + { + "Enabled": true, + "Key": "BootstrapMenu-RetrieveMenus", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "用户所有菜单数据缓存" + }, + { + "Enabled": true, + "Key": "GroupHelper-RetrieveGroupsByUserName", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "指定用户组数据缓存" + }, + { + "Enabled": true, + "Key": "UserHelper-RetrieveUsers", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "所有用户数据" + }, + { + "Enabled": true, + "Key": "UserHelper-RetrieveUsersByRoleId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过角色ID获得所有用户数据" + }, + { + "Enabled": true, + "Key": "UserHelper-RetrieveUsersByGroupId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过部门ID获得所有用户数据" + }, + { + "Enabled": true, + "Key": "UserHelper-RetrieveNewUsers", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "新用户数据" + }, + { + "Enabled": true, + "Key": "MenuHelper-RetrieveMenusByRoleId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过角色ID获得所有菜单数据" + }, + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRoles", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "所有角色数据" + }, + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRolesByUserId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过用户ID获得所有角色数据" + }, + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRolesByMenuId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过菜单ID获得所有角色数据" + }, + { + "Enabled": true, + "Key": "RoleHelper-RetrieveRolesByGroupId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过部门ID获得所有角色数据" + }, + { + "Enabled": true, + "Key": "GroupHelper-RetrieveGroups", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "所有部门数据" + }, + { + "Enabled": true, + "Key": "GroupHelper-RetrieveGroupsByUserId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过用户ID获得所有部门数据" + }, + { + "Enabled": true, + "Key": "GroupHelper-RetrieveGroupsByRoleId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过角色ID获得所有部门数据" + }, + { + "Enabled": true, + "Key": "AppHelper-RetrieveAppsByRoleId", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "通过角色ID获得所有应用程序数据" + }, + { + "Enabled": true, + "Key": "DictHelper-RetrieveDictsCategory", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "字典分类数据" + }, + { + "Enabled": true, + "Key": "ExceptionHelper-RetrieveExceptions", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "程序异常数据" + }, + { + "Enabled": true, + "Key": "MessageHelper-RetrieveMessages", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "站内消息数据" + }, + { + "Enabled": true, + "Key": "TaskHelper-RetrieveTasks", + "Interval": 600000, + "SlidingExpiration": true, + "Desc": "所有任务数据" + } + ] + } +}