This commit is contained in:
2025-09-26 13:49:18 +08:00
parent 6ba81c6481
commit f8705e7137
3 changed files with 34 additions and 11 deletions

View File

@@ -15,6 +15,15 @@ namespace Dlhis.InfoCheck.Controllers;
[Route("api/[controller]")]
public class FaceController : ControllerBase
{
private readonly ILogger<FaceController> _logger;
private readonly IHttpContextAccessor _httpContextAccessor;
public FaceController(ILogger<FaceController> logger, IHttpContextAccessor httpContextAccessor)
{
_logger = logger;
_httpContextAccessor = httpContextAccessor;
}
/// <summary>
/// 人脸质量检测
/// </summary>
@@ -24,6 +33,8 @@ public class FaceController : ControllerBase
[HttpPost("detection")]
public IEnumerable<string> FacialDetection(FaceDetectRequest request)
{
_logger.LogInformation("currentIP:{IP}", _httpContextAccessor.HttpContext.Connection.RemoteIpAddress);
var base64Bytes = Convert.FromBase64String(request.Base64);
using var stream = new MemoryStream(base64Bytes);
using var bitmap = SKBitmap.Decode(stream);

View File

@@ -1,5 +1,5 @@
using Kurisu.AspNetCore.Startup;
using Kurisu.AspNetCore.Utils.Extensions;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.IdentityModel.Logging;
class Program
@@ -16,4 +16,23 @@ public class Startup : DefaultStartup
{
IdentityModelEventSource.ShowPII = true;
}
public override void ConfigureServices(IServiceCollection services)
{
base.ConfigureServices(services);
services.AddHttpContextAccessor();
services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders = ForwardedHeaders.All;
options.KnownNetworks.Clear();
options.KnownProxies.Clear();
});
}
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseForwardedHeaders();
base.Configure(app, env);
}
}