Compare commits

19 Commits

Author SHA1 Message Date
ea3a825825 chore 优化authserver配置 2025-10-30 00:10:48 +08:00
90f0040f63 Merge branch 'master' of https://git.konsoft.top/konsoft/KonSoft.Clean 2025-10-29 23:52:43 +08:00
d4e54f5709 chore 优化authserverAudience 2025-10-29 23:52:40 +08:00
8d9e7658d7 upd:把OAuthClientId和secret的获取移动到了循环的外面 2025-10-28 08:39:41 +08:00
d340be4e2c fix 调整authserver服务https代理配置 2025-10-27 20:23:34 +08:00
4afd7924b7 chore 调整adminservice swagger 2025-10-27 20:21:24 +08:00
30e5e6a4dc upd 2025-10-27 15:53:21 +08:00
df78f842f3 upd: appsettings 2025-10-27 15:42:26 +08:00
5138daebea upd: InternalGateWay AddAbpSwaggerGenWithOidc 2025-10-27 14:47:41 +08:00
bbead3a651 upd: 网关swagger 2025-10-26 22:28:32 +08:00
802624e7ea upd: 网关swagger 2025-10-26 22:13:17 +08:00
b2bccc34f5 upd: 忽略logs.txt文件 2025-10-26 22:12:46 +08:00
f060641e97 upd: UseSwaggerUIWithYarp 2025-10-26 16:03:23 +08:00
e7aaacc410 upd: 网关添加swagger 2025-10-26 15:35:38 +08:00
75cd096b60 upd:刚刚好像没加完 2025-10-26 15:25:45 +08:00
e4629b1771 Merge branch 'master' of https://git.konsoft.top/konsoft/KonSoft.Clean 2025-10-26 15:07:23 +08:00
b699762c1b upd:在swagger里面聚合了Swagger 2025-10-26 15:07:13 +08:00
931ecbd4bc add: migrations 2025-10-26 14:43:57 +08:00
79171b51b2 Revert "upd:把管道内的静态文件顺序调整到了swagger后面"
This reverts commit 6dd678ec31.
2025-10-26 13:52:34 +08:00
11 changed files with 2520 additions and 35 deletions

3
.gitignore vendored
View File

@ -264,4 +264,5 @@ src/KonSoft.Admin.Blazor.Server.Tiered/Logs/*
# Use abp install-libs to restore. # Use abp install-libs to restore.
**/wwwroot/libs/* **/wwwroot/libs/*
**/Logs/* **/Logs/*
**/logs.txt

View File

@ -26,6 +26,7 @@ using Volo.Abp.Localization;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.OpenIddict; using Volo.Abp.OpenIddict;
using Volo.Abp.Security.Claims; using Volo.Abp.Security.Claims;
using Volo.Abp.UI.Navigation.Urls;
using IPNetwork = Microsoft.AspNetCore.HttpOverrides.IPNetwork; using IPNetwork = Microsoft.AspNetCore.HttpOverrides.IPNetwork;
namespace KonSoft; namespace KonSoft;
@ -50,15 +51,20 @@ public class KonSoftAuthServerModule : AbpModule
{ {
builder.AddValidation(options => builder.AddValidation(options =>
{ {
options.AddAudiences("KonSoft"); options.AddAudiences(KonSoftConsts.AuthServerAudience);
options.UseLocalServer(); options.UseLocalServer();
options.UseAspNetCore(); options.UseAspNetCore();
}); });
}); });
context.Services.Configure<ForwardedHeadersOptions>(options => PreConfigure<ForwardedHeadersOptions>(options =>
{ {
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; options.ForwardedHeaders = ForwardedHeaders.XForwardedFor |
ForwardedHeaders.XForwardedProto |
ForwardedHeaders.XForwardedHost;
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("::ffff:127.0.0.1"), 104));
options.KnownProxies.Add(IPAddress.Parse("::ffff:127.0.0.1"));
}); });
if (!hostingEnvironment.IsDevelopment()) if (!hostingEnvironment.IsDevelopment())
@ -105,6 +111,16 @@ public class KonSoftAuthServerModule : AbpModule
options.ApplicationName = "AuthServer"; options.ApplicationName = "AuthServer";
}); });
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"]?.Split(',') ??
Array.Empty<string>());
options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"];
options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password";
});
Configure<AbpBackgroundJobOptions>(options => { options.IsJobExecutionEnabled = false; }); Configure<AbpBackgroundJobOptions>(options => { options.IsJobExecutionEnabled = false; });
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options => context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
@ -137,17 +153,16 @@ public class KonSoftAuthServerModule : AbpModule
var app = context.GetApplicationBuilder(); var app = context.GetApplicationBuilder();
var env = context.GetEnvironment(); var env = context.GetEnvironment();
if (env.IsDevelopment()) app.UseForwardedHeaders();
app.Use(async (ctx, next) =>
{ {
app.UseDeveloperExceptionPage(); ctx.Request.Scheme = "https";
app.UseForwardedHeaders(); await next();
} });
else
{ app.UseDeveloperExceptionPage();
app.UseErrorPage(); app.UseAbpRequestLocalization();
app.UseForwardedHeaders(); app.UseErrorPage();
app.UseHsts();
}
app.UseAbpRequestLocalization(); app.UseAbpRequestLocalization();

View File

@ -0,0 +1,50 @@
using Microsoft.AspNetCore.Builder;
using Yarp.ReverseProxy.Configuration;
namespace KonSoft.InternalGateway.Extensions
{
public static class YarpSwaggerUIBuilderExtensions
{
public static IApplicationBuilder UseSwaggerUIWithYarp(this IApplicationBuilder app)
{
var serviceProvider = app.ApplicationServices;
app.UseSwagger();
app.UseSwaggerUI(options =>
{
var configuration = serviceProvider.GetRequiredService<IConfiguration>();
var logger = serviceProvider.GetRequiredService<ILogger<Program>>();
var proxyConfigProvider = serviceProvider.GetRequiredService<IProxyConfigProvider>();
var yarpConfig = proxyConfigProvider.GetConfig();
var routedClusters = yarpConfig.Clusters
.SelectMany(t => t.Destinations,
(clusterId, destination) => new { clusterId.ClusterId, destination.Value });
var groupedClusters = routedClusters
.GroupBy(q => q.Value.Address)
.Select(t => t.First())
.Distinct()
.ToList();
var gatewayUrl = configuration["GatewayUrl"];
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
foreach (var clusterGroup in groupedClusters)
{
var routeConfig = yarpConfig.Routes.FirstOrDefault(q =>
q.ClusterId == clusterGroup.ClusterId);
if (routeConfig == null)
{
logger.LogWarning($"Swagger UI: Couldn't find route configuration for {clusterGroup.ClusterId}...");
continue;
}
// options.SwaggerEndpoint($"{clusterGroup.Value.Address}/swagger/v1/swagger.json", $"{routeConfig.RouteId} API");
options.SwaggerEndpoint(new Uri(new Uri(!string.IsNullOrWhiteSpace(gatewayUrl)? gatewayUrl: clusterGroup.Value.Address), $"{routeConfig.RouteId.Split("-")[0]}/swagger/v1/swagger.json").AbsoluteUri, $"{routeConfig.RouteId} API");
}
});
return app;
}
}
}

View File

@ -1,5 +1,9 @@
using KonSoft.InternalGateway; using KonSoft.InternalGateway;
using KonSoft.InternalGateway.Extensions;
using KonSoft.Shared.Hosting.AspNetCore; using KonSoft.Shared.Hosting.AspNetCore;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using Serilog; using Serilog;
var assemblyName = typeof(Program).Assembly.GetName().Name!; var assemblyName = typeof(Program).Assembly.GetName().Name!;
@ -17,11 +21,26 @@ try
.AddAppSettingsSecretsJson() .AddAppSettingsSecretsJson()
.UseAutofac() .UseAutofac()
.UseSerilog(); .UseSerilog();
builder.Services.AddAbpSwaggerGenWithOidc(builder.Configuration["AuthServer:Authority"]!, setupAction: options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Title = "Gateway",
Version = "v1"
});
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
builder.Services.AddReverseProxy() builder.Services.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")); .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
builder.Services.AddControllers();
await builder.AddApplicationAsync<InternalGatewayModule>(); await builder.AddApplicationAsync<InternalGatewayModule>();
var app = builder.Build(); var app = builder.Build();
await app.InitializeApplicationAsync(); await app.InitializeApplicationAsync();
app.UseSwaggerUIWithYarp();
app.MapReverseProxy(); app.MapReverseProxy();
app.MapGet("/heath", () => "Online"); app.MapGet("/heath", () => "Online");
await app.RunAsync(); await app.RunAsync();

View File

@ -4,5 +4,10 @@
"name": "KonSoft.InternalGateway", "name": "KonSoft.InternalGateway",
"nodes": "https://config.konsoft.top/", "nodes": "https://config.konsoft.top/",
"secret": "DBE31703-14F9-4B01-893D-900B8380CE04" "secret": "DBE31703-14F9-4B01-893D-900B8380CE04"
},
"AuthServer": {
"Authority": "https://devauth.konsoft.top",
"RequireHttpsMetadata": true,
"SwaggerClientId": "Gateway_Swagger"
} }
} }

View File

@ -26,7 +26,7 @@ public class AdminHttpApiHostModule : AbpModule
SwaggerConfigurationHelper.ConfigureWithOidc( SwaggerConfigurationHelper.ConfigureWithOidc(
context, context,
configuration["AuthServer:Authority"]!, configuration["AuthServer:Authority"]!,
["AdministrationService"], ["Admin", "Dispatch", "Payment", "Report", "TenantManagement"],
discoveryEndpoint: configuration["AuthServer:MetadataAddress"], discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
apiTitle: "Administration Service API" apiTitle: "Administration Service API"
); );
@ -52,6 +52,7 @@ public class AdminHttpApiHostModule : AbpModule
app.UseAbpRequestLocalization(); app.UseAbpRequestLocalization();
app.UseCorrelationId(); app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting(); app.UseRouting();
app.UseCors(); app.UseCors();
app.UseAuthentication(); app.UseAuthentication();
@ -74,8 +75,7 @@ public class AdminHttpApiHostModule : AbpModule
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthScopes("Admin"); options.OAuthScopes("Admin");
}); });
app.UseStaticFiles();
app.UseAuditing(); app.UseAuditing();
app.UseAbpSerilogEnrichers(); app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints(); app.UseConfiguredEndpoints();

View File

@ -6,18 +6,7 @@
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },
"applicationUrl": "https://localhost:44354" "applicationUrl": "http://localhost:44354"
},
"Container (Dockerfile)": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": true
} }
}, },
"$schema": "http://json.schemastore.org/launchsettings.json" "$schema": "http://json.schemastore.org/launchsettings.json"

View File

@ -6,8 +6,9 @@
"secret": "DBE31703-14F9-4B01-893D-900B8380CE04" "secret": "DBE31703-14F9-4B01-893D-900B8380CE04"
}, },
"AuthServer": { "AuthServer": {
"Authority": "https://localhost:44322", "Authority": "https://devauth.konsoft.top",
"RequireHttpsMetadata": true, "RequireHttpsMetadata": false,
"SwaggerClientId": "Admin_Swagger" "SwaggerClientId": "Dev_Admin_Swagger",
"MetadataAddress": "https://devauth.konsoft.top"
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,69 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace KonSoft.Admin.Migrations
{
/// <inheritdoc />
public partial class V101 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "WorkerId",
table: "AppOrder",
newName: "HouseholdWorkerId");
migrationBuilder.CreateIndex(
name: "IX_AppOrder_CustomerId",
table: "AppOrder",
column: "CustomerId");
migrationBuilder.CreateIndex(
name: "IX_AppOrder_HouseholdWorkerId",
table: "AppOrder",
column: "HouseholdWorkerId");
migrationBuilder.AddForeignKey(
name: "FK_AppOrder_AbpUsers_CustomerId",
table: "AppOrder",
column: "CustomerId",
principalTable: "AbpUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_AppOrder_AbpUsers_HouseholdWorkerId",
table: "AppOrder",
column: "HouseholdWorkerId",
principalTable: "AbpUsers",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_AppOrder_AbpUsers_CustomerId",
table: "AppOrder");
migrationBuilder.DropForeignKey(
name: "FK_AppOrder_AbpUsers_HouseholdWorkerId",
table: "AppOrder");
migrationBuilder.DropIndex(
name: "IX_AppOrder_CustomerId",
table: "AppOrder");
migrationBuilder.DropIndex(
name: "IX_AppOrder_HouseholdWorkerId",
table: "AppOrder");
migrationBuilder.RenameColumn(
name: "HouseholdWorkerId",
table: "AppOrder",
newName: "WorkerId");
}
}
}

View File

@ -68,6 +68,9 @@ namespace KonSoft.Admin.Migrations
.HasColumnType("text") .HasColumnType("text")
.HasColumnName("ExtraProperties"); .HasColumnName("ExtraProperties");
b.Property<Guid?>("HouseholdWorkerId")
.HasColumnType("uuid");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("boolean") .HasColumnType("boolean")
@ -101,9 +104,6 @@ namespace KonSoft.Admin.Migrations
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("integer"); .HasColumnType("integer");
b.Property<Guid?>("WorkerId")
.HasColumnType("uuid");
b.ComplexProperty<Dictionary<string, object>>("Address", "KonSoft.Admin.Entities.Order.Address#AddressInfo", b1 => b.ComplexProperty<Dictionary<string, object>>("Address", "KonSoft.Admin.Entities.Order.Address#AddressInfo", b1 =>
{ {
b1.IsRequired(); b1.IsRequired();
@ -131,6 +131,10 @@ namespace KonSoft.Admin.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("HouseholdWorkerId");
b.ToTable("AppOrder", (string)null); b.ToTable("AppOrder", (string)null);
}); });
@ -2104,6 +2108,23 @@ namespace KonSoft.Admin.Migrations
b.HasDiscriminator().HasValue("HouseholdWorker"); b.HasDiscriminator().HasValue("HouseholdWorker");
}); });
modelBuilder.Entity("KonSoft.Admin.Entities.Order", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser", "Customer")
.WithMany()
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Volo.Abp.Identity.IdentityUser", "HouseholdWorker")
.WithMany()
.HasForeignKey("HouseholdWorkerId");
b.Navigation("Customer");
b.Navigation("HouseholdWorker");
});
modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b => modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogAction", b =>
{ {
b.HasOne("Volo.Abp.AuditLogging.AuditLog", null) b.HasOne("Volo.Abp.AuditLogging.AuditLog", null)