Skip to content

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.

Guides & Recipes — Security

Verified SSRF protection and MFA configuration patterns compiled on .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);
}
}