chore 优化authserver配置
This commit is contained in:
@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Cors;
|
|||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using OpenIddict.Validation;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@ -58,16 +57,14 @@ public class KonSoftAuthServerModule : AbpModule
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context.Services.Configure<ForwardedHeadersOptions>(options =>
|
PreConfigure<ForwardedHeadersOptions>(options =>
|
||||||
{
|
{
|
||||||
options.KnownNetworks.Clear();
|
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor |
|
||||||
options.KnownProxies.Clear();
|
ForwardedHeaders.XForwardedProto |
|
||||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
ForwardedHeaders.XForwardedHost;
|
||||||
});
|
|
||||||
|
|
||||||
Configure<OpenIddictServerBuilder>(options =>
|
options.KnownNetworks.Add(new IPNetwork(IPAddress.Parse("::ffff:127.0.0.1"), 104));
|
||||||
{
|
options.KnownProxies.Add(IPAddress.Parse("::ffff:127.0.0.1"));
|
||||||
options.SetIssuer("");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!hostingEnvironment.IsDevelopment())
|
if (!hostingEnvironment.IsDevelopment())
|
||||||
@ -114,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 =>
|
||||||
@ -146,18 +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.UseErrorPage();
|
ctx.Request.Scheme = "https";
|
||||||
app.UseForwardedHeaders();
|
await next();
|
||||||
app.UseHsts();
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
app.UseDeveloperExceptionPage();
|
||||||
{
|
app.UseAbpRequestLocalization();
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseErrorPage();
|
||||||
app.UseForwardedHeaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
app.UseAbpRequestLocalization();
|
app.UseAbpRequestLocalization();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user