fix(api): test ip
This commit is contained in:
@@ -45,5 +45,12 @@ 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,19 +34,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;
|
||||
//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();
|
||||
|
||||
Reference in New Issue
Block a user