fix(api): test ip
This commit is contained in:
@@ -45,12 +45,5 @@ namespace PARR.API.Controllers.V1
|
||||
|
||||
return Ok(new Response<ApiHealthResponse>(response, true));
|
||||
}
|
||||
|
||||
[HttpGet("/get-ip")]
|
||||
public IActionResult Test()
|
||||
{
|
||||
var ip = HttpContext.Connection.RemoteIpAddress?.MapToIPv4();
|
||||
return Ok(ip.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
using Elastic.CommonSchema.Serilog;
|
||||
using FluentValidation;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.Server.HttpSys;
|
||||
using PARR.API.Authentication;
|
||||
using PARR.API.Installers;
|
||||
using PARR.API.RoleProvider;
|
||||
using PARR.BLL;
|
||||
using PARR.DAL;
|
||||
using Serilog;
|
||||
@@ -34,19 +32,19 @@ builder.Configuration.AddDalConfigurations(builder.Services);
|
||||
builder.Services.AddDallSettings(builder.Configuration);
|
||||
|
||||
// Auth
|
||||
//builder.Services.AddAuthentication(ParrAuthenticationOptions.DefaultScheme)
|
||||
// .AddScheme<ParrAuthenticationOptions, ParrAuthenticationHandler>(ParrAuthenticationOptions.DefaultScheme, opt => { });
|
||||
builder.Services.AddAuthentication(ParrAuthenticationOptions.DefaultScheme)
|
||||
.AddScheme<ParrAuthenticationOptions, ParrAuthenticationHandler>(ParrAuthenticationOptions.DefaultScheme, opt => { });
|
||||
// не используем, так как проверка ролей остается прежней, а роли подставляем в ParrAuthenticationHandler
|
||||
//builder.Services.AddSimpleRoleAuthorization<BaseSimpleRoleProvider>();
|
||||
|
||||
// При использовании балансировщика (haproxy, перенаправлять заголовки)
|
||||
//builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
||||
//{
|
||||
// options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||
// При использовании балансировщика (haproxy, перенаправлять заголовки) (см ниже: app.UseForwardedHeaders();)
|
||||
builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
||||
{
|
||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||
|
||||
// options.KnownNetworks.Clear();
|
||||
// options.KnownProxies.Clear();
|
||||
//});
|
||||
options.KnownNetworks.Clear();
|
||||
options.KnownProxies.Clear();
|
||||
});
|
||||
|
||||
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
@@ -61,6 +59,9 @@ builder.Services.InstallSwaggerService(builder.Configuration);
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// При использовании балансировщика (haproxy, перенаправлять заголовки)
|
||||
app.UseForwardedHeaders();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
app.InstallSwagger();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user