diff --git a/backend/src/Squidex/Areas/IdentityServer/Config/IdentityServerServices.cs b/backend/src/Squidex/Areas/IdentityServer/Config/IdentityServerServices.cs index 8127fbe1a..5231b29e7 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Config/IdentityServerServices.cs +++ b/backend/src/Squidex/Areas/IdentityServer/Config/IdentityServerServices.cs @@ -15,6 +15,7 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection.KeyManagement; using Microsoft.AspNetCore.DataProtection.Repositories; using Microsoft.AspNetCore.Identity; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Squidex.Domain.Users; @@ -26,12 +27,14 @@ namespace Squidex.Areas.IdentityServer.Config { public static class IdentityServerServices { - public static void AddSquidexIdentityServer(this IServiceCollection services) + public static void AddSquidexIdentityServer(this IServiceCollection services, IConfiguration config) { X509Certificate2 certificate; var assembly = typeof(IdentityServerServices).Assembly; + var urlsOptions = config.GetSection("urls").Get(); + using (var certificateStream = assembly.GetManifestResourceStream("Squidex.Areas.IdentityServer.Config.Cert.IdentityCert.pfx")) { var certData = new byte[certificateStream!.Length]; @@ -74,6 +77,11 @@ namespace Squidex.Areas.IdentityServer.Config services.AddIdentityServer(options => { options.UserInteraction.ErrorUrl = "/error/"; + + if (!string.IsNullOrWhiteSpace(urlsOptions.BaseUrl)) + { + options.PublicOrigin = urlsOptions.BaseUrl; + } }) .AddAspNetIdentity() .AddInMemoryApiResources(GetApiResources()) diff --git a/backend/src/Squidex/Startup.cs b/backend/src/Squidex/Startup.cs index c15572b4c..4fbef75a7 100644 --- a/backend/src/Squidex/Startup.cs +++ b/backend/src/Squidex/Startup.cs @@ -54,7 +54,7 @@ namespace Squidex services.AddSquidexHealthChecks(config); services.AddSquidexHistory(); services.AddSquidexIdentity(config); - services.AddSquidexIdentityServer(); + services.AddSquidexIdentityServer(config); services.AddSquidexInfrastructure(config); services.AddSquidexMigration(config); services.AddSquidexNotifications(config);