diff --git a/applications/KonSoft.AuthServer/KonSoftAuthServerModule.cs b/applications/KonSoft.AuthServer/KonSoftAuthServerModule.cs index 9ecd951..3be84b5 100644 --- a/applications/KonSoft.AuthServer/KonSoftAuthServerModule.cs +++ b/applications/KonSoft.AuthServer/KonSoftAuthServerModule.cs @@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using OpenIddict.Validation; using System; using System.Linq; using System.Net; @@ -58,16 +57,14 @@ public class KonSoftAuthServerModule : AbpModule }); }); - context.Services.Configure(options => + PreConfigure(options => { - options.KnownNetworks.Clear(); - options.KnownProxies.Clear(); - options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; - }); + options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | + ForwardedHeaders.XForwardedProto | + ForwardedHeaders.XForwardedHost; - Configure(options => - { - options.SetIssuer(""); + 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()) @@ -114,6 +111,16 @@ public class KonSoftAuthServerModule : AbpModule options.ApplicationName = "AuthServer"; }); + Configure(options => + { + options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; + options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"]?.Split(',') ?? + Array.Empty()); + + options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"]; + options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password"; + }); + Configure(options => { options.IsJobExecutionEnabled = false; }); context.Services.Configure(options => @@ -146,18 +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.UseErrorPage(); - app.UseForwardedHeaders(); - app.UseHsts(); - } + ctx.Request.Scheme = "https"; + await next(); + }); - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - app.UseForwardedHeaders(); - } + app.UseDeveloperExceptionPage(); + app.UseAbpRequestLocalization(); + app.UseErrorPage(); app.UseAbpRequestLocalization();