|
|
|
@ -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<PublicFacingUrlMiddleware>($"{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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|