Compare commits

..

10 Commits

7 changed files with 39 additions and 38 deletions

View File

@ -26,6 +26,7 @@ using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Volo.Abp.OpenIddict;
using Volo.Abp.Security.Claims;
using Volo.Abp.UI.Navigation.Urls;
using IPNetwork = Microsoft.AspNetCore.HttpOverrides.IPNetwork;
namespace KonSoft;
@ -50,15 +51,20 @@ public class KonSoftAuthServerModule : AbpModule
{
builder.AddValidation(options =>
{
options.AddAudiences("KonSoft");
options.AddAudiences(KonSoftConsts.AuthServerAudience);
options.UseLocalServer();
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())
@ -105,6 +111,16 @@ public class KonSoftAuthServerModule : AbpModule
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; });
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
@ -137,17 +153,16 @@ public class KonSoftAuthServerModule : AbpModule
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
app.UseForwardedHeaders();
app.Use(async (ctx, next) =>
{
app.UseDeveloperExceptionPage();
app.UseForwardedHeaders();
}
else
{
app.UseErrorPage();
app.UseForwardedHeaders();
app.UseHsts();
}
ctx.Request.Scheme = "https";
await next();
});
app.UseDeveloperExceptionPage();
app.UseAbpRequestLocalization();
app.UseErrorPage();
app.UseAbpRequestLocalization();

View File

@ -27,6 +27,8 @@ namespace KonSoft.InternalGateway.Extensions
.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 =>
@ -38,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(!string.IsNullOrWhiteSpace(gatewayUrl)? gatewayUrl: 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

@ -22,11 +22,7 @@ try
.UseAutofac()
.UseSerilog();
builder.Services.AddAbpSwaggerGenWithOAuth(builder.Configuration["AuthServer:Authority"]!,
new Dictionary<string, string>
{
{ "Clean", "Clean API" }
}, options =>
builder.Services.AddAbpSwaggerGenWithOidc(builder.Configuration["AuthServer:Authority"]!, setupAction: options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{

View File

@ -6,7 +6,7 @@
"secret": "DBE31703-14F9-4B01-893D-900B8380CE04"
},
"AuthServer": {
"Authority": "https://localhost:44322",
"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"
}
}