Ir al contenido

Buscar en el Ecosistema EricksonLopez.*

Escribe el nombre de una librería, ID de paquete NuGet, tipo .NET o concepto arquitectónico para buscar en el portal.

Guías y Recetas — Security

Patrones verificados de defensa SSRF y MFA compilados en .NET 10 (ImplicitUsings=disable, Nullable=enable).

using System.Net.Http;
using EricksonLopez.Security.Network;
namespace Example.SecurityQuickStart;
public static class SsrfHttpClientRecipe
{
public static HttpClient CreateHardenedClient()
{
var options = new SsrfProtectionOptions
{
RequireHttps = true,
BlockCloudMetadata = true,
RestrictToAllowedHostnames = true,
};
options.AllowedHostnames.Add("api.partner.com");
var handler = new SafeSocketsHttpHandler(options: options);
return new HttpClient(handler, disposeHandler: true);
}
}
using System;
using EricksonLopez.Security.Mfa;
namespace Example.SecurityQuickStart;
public static class TotpRecipe
{
public static bool VerifyProvisionedCode()
{
var service = new TotpService();
TotpSetupInfo setup = service.GenerateSetupInfo("NorthwindApp", "user@example.com");
string code = service.ComputeCode(setup.SecretKey, DateTimeOffset.UtcNow);
return service.VerifyCode(setup.SecretKey, code, DateTimeOffset.UtcNow);
}
}