Compare commits

..

9 Commits

Author SHA1 Message Date
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
8 changed files with 29 additions and 27 deletions

3
.gitignore vendored
View File

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

View File

@ -58,6 +58,8 @@ public class KonSoftAuthServerModule : AbpModule
context.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.KnownNetworks.Clear();
options.KnownProxies.Clear();
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
});
@ -137,18 +139,19 @@ public class KonSoftAuthServerModule : AbpModule
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseForwardedHeaders();
}
else
if (!env.IsDevelopment())
{
app.UseErrorPage();
app.UseForwardedHeaders();
app.UseHsts();
}
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseForwardedHeaders();
}
app.UseAbpRequestLocalization();
app.UseCorrelationId();

View File

@ -25,6 +25,10 @@ namespace KonSoft.InternalGateway.Extensions
.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 =>
@ -36,9 +40,7 @@ namespace KonSoft.InternalGateway.Extensions
}
// options.SwaggerEndpoint($"{clusterGroup.Value.Address}/swagger/v1/swagger.json", $"{routeConfig.RouteId} API");
options.SwaggerEndpoint(new Uri(new Uri(clusterGroup.Value.Address), "/swagger/v1/swagger.json").AbsoluteUri, $"{routeConfig.RouteId} API");
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
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");
}
});

View File

@ -2,6 +2,7 @@ using KonSoft.InternalGateway;
using KonSoft.InternalGateway.Extensions;
using KonSoft.Shared.Hosting.AspNetCore;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.OpenApi.Models;
using Serilog;
@ -21,7 +22,7 @@ try
.UseAutofac()
.UseSerilog();
builder.Services.AddSwaggerGen(options =>
builder.Services.AddAbpSwaggerGenWithOidc(builder.Configuration["AuthServer:Authority"]!, setupAction: options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{

View File

@ -4,5 +4,10 @@
"name": "KonSoft.InternalGateway",
"nodes": "https://config.konsoft.top/",
"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(
context,
configuration["AuthServer:Authority"]!,
["AdministrationService"],
["Admin", "Dispatch", "Payment", "Report", "TenantManagement"],
discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
apiTitle: "Administration Service API"
);

View File

@ -6,18 +6,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://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
"applicationUrl": "http://localhost:44354"
}
},
"$schema": "http://json.schemastore.org/launchsettings.json"

View File

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