chore: 优化authserver代码
This commit is contained in:
14
applications/KonSoft.AuthServer/Controller/HomeController.cs
Normal file
14
applications/KonSoft.AuthServer/Controller/HomeController.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
|
||||
namespace KonSoft.Controller
|
||||
{
|
||||
public class HomeController : AbpController
|
||||
{
|
||||
[HttpGet("health")]
|
||||
public ActionResult Health()
|
||||
{
|
||||
return Ok("online");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -59,6 +59,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\modules\admin\src\KonSoft.Admin.Application\KonSoft.Admin.Application.csproj" />
|
||||
<ProjectReference Include="..\..\modules\admin\src\KonSoft.Admin.EntityFrameworkCore\KonSoft.Admin.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\..\shared\KonSoft.Shared.Hosting.Microservices\KonSoft.Shared.Hosting.Microservices.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
using KonSoft.Admin;
|
||||
using KonSoft.Admin.EntityFrameworkCore;
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using KonSoft.Shared.Hosting.Microservices;
|
||||
using KonSoft.Shared.Localization.Localization;
|
||||
@ -10,6 +12,7 @@ using Volo.Abp.Account;
|
||||
using Volo.Abp.Account.Localization;
|
||||
using Volo.Abp.Account.Web;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
|
||||
using Volo.Abp.Auditing;
|
||||
@ -24,7 +27,10 @@ namespace KonSoft;
|
||||
[DependsOn(
|
||||
typeof(AbpAccountWebOpenIddictModule),
|
||||
typeof(AbpAccountApplicationModule),
|
||||
typeof(AbpAccountHttpApiModule),
|
||||
typeof(AbpAccountHttpApiModule),
|
||||
typeof(AdminApplicationModule),
|
||||
typeof(AdminEntityFrameworkCoreModule),
|
||||
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
|
||||
typeof(KonSoftSharedHostingMicroservicesModule)
|
||||
)]
|
||||
public class KonSoftAuthServerModule : AbpModule
|
||||
@ -54,7 +60,7 @@ public class KonSoftAuthServerModule : AbpModule
|
||||
PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
|
||||
{
|
||||
serverBuilder.AddProductionEncryptionAndSigningCertificate("openiddict.pfx",
|
||||
"59464dba-b66e-48cd-8b81-2e4a9c08c977");
|
||||
configuration["Certificate:Password"]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using KonSoft.Shared.Hosting.AspNetCore;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KonSoft;
|
||||
|
||||
@ -12,45 +10,27 @@ public class Program
|
||||
{
|
||||
public static async Task<int> Main(string[] args)
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
#if DEBUG
|
||||
.MinimumLevel.Debug()
|
||||
#else
|
||||
.MinimumLevel.Information()
|
||||
#endif
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Async(c => c.File("Logs/logs.txt"))
|
||||
.WriteTo.Async(c => c.Console())
|
||||
.CreateLogger();
|
||||
var assemblyName = typeof(Program).Assembly.GetName().Name!;
|
||||
|
||||
SerilogConfigurationHelper.Configure(assemblyName);
|
||||
try
|
||||
{
|
||||
Log.Information("Starting KonSoft.AuthServer.");
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Host.AddAppSettingsSecretsJson()
|
||||
.UseAutofac()
|
||||
.UseSerilog();
|
||||
await builder.AddApplicationAsync<KonSoftAuthServerModule>();
|
||||
var app = builder.Build();
|
||||
Log.Information($"Starting {assemblyName}.");
|
||||
var app = await ApplicationBuilderHelper
|
||||
.BuildApplicationAsync<KonSoftAuthServerModule>(args);
|
||||
await app.InitializeApplicationAsync();
|
||||
await app.RunAsync();
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is HostAbortedException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
Log.Fatal(ex, "KonSoft.AuthServer terminated unexpectedly!");
|
||||
Log.Fatal(ex, $"{assemblyName} terminated unexpectedly!");
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
await Log.CloseAndFlushAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,17 +1,8 @@
|
||||
{
|
||||
"App": {
|
||||
"SelfUrl": "https://localhost:44322",
|
||||
"ClientUrl": "http://localhost:4200",
|
||||
"CorsOrigins": "https://*.KonSoft.com,http://localhost:4200,https://localhost:44316,https://localhost:44370",
|
||||
"RedirectAllowedUrls": "http://localhost:4200,https://localhost:44319,https://localhost:44316,https://localhost:44347"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "Host=localhost;Port=5432;Database=KonSoft;User ID=root;Password=myPassword;"
|
||||
},
|
||||
"Redis": {
|
||||
"Configuration": "127.0.0.1"
|
||||
},
|
||||
"StringEncryption": {
|
||||
"DefaultPassPhrase": "kxtywyrXW4i7vijT"
|
||||
"AgileConfig": {
|
||||
"appId": "KonSoft.Admin.HttpApi.Host",
|
||||
"name": "KonSoft.Admin.HttpApi.Host",
|
||||
"nodes": "https://config.konsoft.top/",
|
||||
"secret": "DBE31703-14F9-4B01-893D-900B8380CE04"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
services:
|
||||
internalgateways:
|
||||
container_name: clean-internalgateways
|
||||
restart: always
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./gateways/KonSoft.InternalGateway/Dockerfile
|
||||
@ -15,10 +15,21 @@ services:
|
||||
- 8080:8080
|
||||
networks:
|
||||
- konsoft-shared-network
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8081/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
authserver:
|
||||
container_name: clean-authserver
|
||||
restart: always
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./applications/KonSoft.AuthServer/Dockerfile
|
||||
@ -30,12 +41,25 @@ services:
|
||||
- AgileConfig__Secret=DBE31703-14F9-4B01-893D-900B8380CE04
|
||||
ports:
|
||||
- 8081:8081
|
||||
volumes:
|
||||
- /root/openiddict.pfx:/app/openiddict.pfx:ro
|
||||
networks:
|
||||
- konsoft-shared-network
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
adminservice:
|
||||
container_name: clean-adminservice
|
||||
restart: always
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./microservices/KonSoft.Admin.HttpApi.Host/Dockerfile
|
||||
@ -47,6 +71,17 @@ services:
|
||||
- AgileConfig__Secret=DBE31703-14F9-4B01-893D-900B8380CE04
|
||||
networks:
|
||||
- konsoft-shared-network
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
networks:
|
||||
konsoft-shared-network:
|
||||
|
||||
@ -9,4 +9,10 @@ public class HomeController : AbpController
|
||||
{
|
||||
return Redirect("~/swagger");
|
||||
}
|
||||
|
||||
[HttpGet("health")]
|
||||
public ActionResult Health()
|
||||
{
|
||||
return Ok("online");
|
||||
}
|
||||
}
|
||||
@ -9,4 +9,11 @@ public class HomeController : AbpController
|
||||
{
|
||||
return Redirect("~/swagger");
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("health")]
|
||||
public ActionResult Health()
|
||||
{
|
||||
return Ok("online");
|
||||
}
|
||||
}
|
||||
@ -9,4 +9,11 @@ public class HomeController : AbpController
|
||||
{
|
||||
return Redirect("~/swagger");
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("health")]
|
||||
public ActionResult Health()
|
||||
{
|
||||
return Ok("online");
|
||||
}
|
||||
}
|
||||
@ -9,4 +9,11 @@ public class HomeController : AbpController
|
||||
{
|
||||
return Redirect("~/swagger");
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("health")]
|
||||
public ActionResult Health()
|
||||
{
|
||||
return Ok("online");
|
||||
}
|
||||
}
|
||||
@ -9,4 +9,11 @@ public class HomeController : AbpController
|
||||
{
|
||||
return Redirect("~/swagger");
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("health")]
|
||||
public ActionResult Health()
|
||||
{
|
||||
return Ok("online");
|
||||
}
|
||||
}
|
||||
@ -56,13 +56,14 @@ public class KonSoftSharedHostingMicroservicesModule : AbpModule
|
||||
ServiceConfigurationContext context,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
var redisConnStr = configuration["Redis:Configuration"]!;
|
||||
context.Services.AddDataProtection().SetApplicationName("KonSoft")
|
||||
.PersistKeysToStackExchangeRedis(ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!),
|
||||
.PersistKeysToStackExchangeRedis(ConnectionMultiplexer.Connect(redisConnStr),
|
||||
"KonSoft-Protection-Keys");
|
||||
|
||||
context.Services.AddSingleton<IDistributedLockProvider>(_ =>
|
||||
new RedisDistributedSynchronizationProvider(ConnectionMultiplexer
|
||||
.Connect(configuration["Redis:Configuration"]!).GetDatabase()));
|
||||
.Connect(redisConnStr).GetDatabase()));
|
||||
}
|
||||
|
||||
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
|
||||
Reference in New Issue
Block a user