diff --git a/samples/voting/IdentityServer/Startup.cs b/samples/voting/IdentityServer/Startup.cs index cb7ad0ed..ed34dc6a 100644 --- a/samples/voting/IdentityServer/Startup.cs +++ b/samples/voting/IdentityServer/Startup.cs @@ -45,7 +45,6 @@ namespace IdentityServer options.Events.RaiseInformationEvents = true; options.Events.RaiseFailureEvents = true; options.Events.RaiseSuccessEvents = true; - options.IssuerUri = $"{publicIp}/identityserver"; // see https://identityserver4.readthedocs.io/en/latest/topics/resources.html options.EmitStaticAudienceClaim = true; }) @@ -91,14 +90,14 @@ namespace IdentityServer app.UseStaticFiles(); - app.UseForwardedHeaders(new ForwardedHeadersOptions() + var khOptions = new ForwardedHeadersOptions() { - ForwardedHeaders = ForwardedHeaders.All - }); - - var publicIp = Configuration["public-ip"]; + ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto + }; + khOptions.KnownProxies.Clear(); + khOptions.KnownNetworks.Clear(); - app.UseMiddleware($"{publicIp}"); + app.UseForwardedHeaders(khOptions); app.UseRouting(); app.UseIdentityServer(); @@ -108,27 +107,5 @@ namespace IdentityServer endpoints.MapDefaultControllerRoute(); }); } - - public class PublicFacingUrlMiddleware - { - private readonly RequestDelegate _next; - private readonly string _publicFacingUri; - - public PublicFacingUrlMiddleware(RequestDelegate next, string publicFacingUri) - { - _publicFacingUri = publicFacingUri; - _next = next; - } - - public async Task Invoke(HttpContext context) - { - var request = context.Request; - - context.SetIdentityServerOrigin(_publicFacingUri); - // context.SetIdentityServerBasePath(request.PathBase.Value.TrimEnd('/')); - - await _next(context); - } - } } } diff --git a/samples/voting/results/Pages/LoginDisplay.razor b/samples/voting/results/Pages/LoginDisplay.razor index 1d467c25..6da5f601 100644 --- a/samples/voting/results/Pages/LoginDisplay.razor +++ b/samples/voting/results/Pages/LoginDisplay.razor @@ -1,6 +1,6 @@ -
+
diff --git a/samples/voting/results/Startup.cs b/samples/voting/results/Startup.cs index 1dcff5cd..651d86de 100644 --- a/samples/voting/results/Startup.cs +++ b/samples/voting/results/Startup.cs @@ -1,5 +1,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.HttpOverrides; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -65,6 +66,15 @@ namespace Results app.UsePathBase("/results"); + var khOptions = new ForwardedHeadersOptions() + { + ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto + }; + khOptions.KnownProxies.Clear(); + khOptions.KnownNetworks.Clear(); + + app.UseForwardedHeaders(khOptions); + app.UseStaticFiles(); app.UseRouting(); diff --git a/samples/voting/tye.yaml b/samples/voting/tye.yaml index 2945bf6c..2d79b4b3 100644 --- a/samples/voting/tye.yaml +++ b/samples/voting/tye.yaml @@ -24,8 +24,8 @@ services: protocol: http env: - name: public-ip - value: http://52.159.20.103 - # value: http://localhost:8080 + #value: http://52.159.20.103 + value: http://localhost:8080 - name: identityserver project: IdentityServer/IdentityServer.csproj bindings: @@ -33,8 +33,8 @@ services: protocol: http env: - name: public-ip - value: http://52.159.20.103 - # value: http://localhost:8080 + #value: http://52.159.20.103 + value: http://localhost:8080 ingress: - name: ingress bindings: