Skip to content

Repository files navigation

SecureCore Auth Framework 🛡️

Version .NET License

SecureCore Auth es una solución de identidad y gestión de sesiones modular, agnóstica a la base de datos y diseñada para aplicaciones .NET modernas que requieren un equilibrio entre ligereza y robustez.


🚀 Pilares Fundamentales

  1. Seguridad Moderna: Soporte nativo y prioritario para Passkeys (WebAuthn) y biometría.
  2. Control Total de Sesión: Gestión activa de Refresh Tokens con rotación (RTR) y capacidad de revocación global instántanea.
  3. Desacoplamiento Absoluto: Tú decides dónde y cómo guardas tus datos. La librería dicta la lógica, no la infraestructura.
  4. Resistencia por Diseño: Mitigaciones nativas contra ataques de enumeración y fuerza bruta.

📦 Estructura de Módulos

El framework está dividido en componentes independientes para que solo instales lo que necesites:

  • SecureCore.Auth.Abstractions: Contratos, interfaces y modelos base. Sin dependencias.
  • SecureCore.Auth.Core: El motor de orquestación, lógica de JWT, hashing (Argon2id) y MFA.
  • SecureCore.Auth.WebAuthn: Soporte para llaves físicas y biometría (FIDO2).
  • SecureCore.Auth.AspNetCore: Integración fluida con el pipeline de ASP.NET Core (Middleware y Endpoints).
  • SecureCore.Auth.OAuth: Orquestación OAuth2/OIDC y persistencia de tokens de proveedor.
  • SecureCore.Auth.OAuth.{Apple, Facebook, GitHub, Google, LinkedIn, Microsoft, TikTok}: Validadores específicos por proveedor (JWKS, nonce anti-replay, appsecret_proof).

🛠️ Inicio Rápido

1. Instalación

Agrega los paquetes necesarios a tu proyecto:

dotnet add package SecureCore.Auth.AspNetCore
dotnet add package SecureCore.Auth.Core

2. Configuración en Program.cs

Registra los servicios y configura las opciones de seguridad:

builder.Services.AddSecureAuth(options => {
    options.Issuer = "tu-dominio.com";
    options.Audience = "tu-app";
    options.SigningKey = builder.Configuration["Jwt:Key"];
})
.AddPasswordAuthentication()
.AddWebAuthn(); // Opcional

var app = builder.Build();

app.UseAuthentication();
app.UseSecureAuthValidation(); // Validación activa de sesiones
app.UseAuthorization();

app.MapSecureAuthEndpoints("/auth"); // Mapea login, refresh, logout automáticamente

🔒 Características de Seguridad

  • Argon2id: Hashing de contraseñas de última generación.
  • Passkeys / WebAuthn (primera clase): Ceremonias de registro y login completas (challenge single-use atómico, origin check fail-closed, anti-enumeración, rate limiting por IP y tope de payload propio).
  • Passwordless-first (A-25): Contraseña nullable de primera clase; SignInWithPasswordAsync(email, null)PasswordlessRequiresCredential (sin oráculo de enumeración); GET /auth/me expone hasPassword; claims amr por método (pwd|webauthn|oauth|mfa, RFC 8176, opt-in EmitAmr).
  • Recovery codes de primera clase: Generación, verificación (peek no consumidor) y redención single-use atómico; solo se persisten hashes SHA-256; expiración configurable; scope anti-abuso propio.
  • Anti-abuso por cuenta (S1): Lockout multi-scope, temporal y escalonado (contraseña, MFA, passkey, recovery, verify-action), distribuible por SPI, default in-memory.
  • Refresh Token Rotation (RTR): Protege contra el robo de tokens; con periodo de gracia real para condiciones de carrera y preservación del aseguramiento (amr/mfa_method) en la rotación.
  • Security Stamp Versioning (SSV): Permite invalidar todas las sesiones de un usuario de forma inmediata (Panic Button).
  • MFA + step-up (S3): TOTP (RFC 6238), códigos por email, ventana mfa_verified, verify-action y creación/cambio de contraseña con re-emisión de tokens.
  • Constant-Time Verification: Previene ataques de tiempo durante la validación de credenciales (Argon2 dummy, nonce OIDC, OTP).
  • Anti-replay y single-use atómico (S2): Primitiva transversal "consumir una vez" para OAuth state, challenges WebAuthn, OTP y recovery codes (extensible a GETDEL/Lua en Redis).
  • OAuth2/OIDC: Login social (Google, Microsoft, Apple, GitHub, Facebook, LinkedIn, TikTok) con validación criptográfica de JWKS y client_secret nunca en URLs.
  • Blacklist de access tokens opt-in (A-24): ITokenBlacklist (default no-op) — el host puede revocar el jti del access token en el logout con TTL = vida restante.
  • Protección anti-DoS: Límites de payload en endpoints anónimos y rate limiting por IP (login, forgot-password, WebAuthn, recovery codes).

📄 Documentación

Para más detalles, consulta la documentación extendida:


🤝 Contribución

Las contribuciones son bienvenidas. Asegúrate de seguir los estándares de código y mantener una cobertura de pruebas superior al 90%.


Desarrollado con ❤️ por el equipo de SecureCore.


English

SecureCore Auth Framework 🛡️

Version .NET License

SecureCore Auth is a modular, database-agnostic identity and session management solution designed for modern .NET applications that need a balance between lightness and robustness.


🚀 Core Pillars

  1. Modern Security: Native, prioritized support for Passkeys (WebAuthn) and biometrics.
  2. Full Session Control: Active Refresh Token management with rotation (RTR) and instant global revocation.
  3. Total Decoupling: You decide where and how you store your data. The library dictates the logic, not the infrastructure.
  4. Security by Design: Built-in mitigations against enumeration and brute-force attacks.

📦 Module Structure

The framework is split into independent components so you only install what you need:

  • SecureCore.Auth.Abstractions: Contracts, interfaces and base models. No dependencies.
  • SecureCore.Auth.Core: The orchestration engine, JWT logic, hashing (Argon2id) and MFA.
  • SecureCore.Auth.WebAuthn: Support for security keys and biometrics (FIDO2).
  • SecureCore.Auth.AspNetCore: Seamless integration with the ASP.NET Core pipeline (Middleware & Endpoints).
  • SecureCore.Auth.OAuth: OAuth2/OIDC orchestration and provider token persistence.
  • SecureCore.Auth.OAuth.{Apple, Facebook, GitHub, Google, LinkedIn, Microsoft, TikTok}: Provider-specific validators (JWKS, anti-replay nonce, appsecret_proof).

🛠️ Quick Start

1. Installation

Add the required packages to your project:

dotnet add package SecureCore.Auth.AspNetCore
dotnet add package SecureCore.Auth.Core

2. Configuration in Program.cs

Register the services and configure the security options:

builder.Services.AddSecureAuth(options => {
    options.Issuer = "your-domain.com";
    options.Audience = "your-app";
    options.SigningKey = builder.Configuration["Jwt:Key"];
})
.AddPasswordAuthentication()
.AddWebAuthn(); // Optional

var app = builder.Build();

app.UseAuthentication();
app.UseSecureAuthValidation(); // Active session validation
app.UseAuthorization();

app.MapSecureAuthEndpoints("/auth"); // Maps login, refresh, logout automatically

🔒 Security Features

  • Argon2id: State-of-the-art password hashing.
  • Passkeys / WebAuthn (first-class): Full register/login ceremonies (atomic single-use challenge, fail-closed origin check, anti-enumeration, per-IP rate limiting and dedicated payload cap).
  • Passwordless-first (A-25): First-class nullable password; SignInWithPasswordAsync(email, null)PasswordlessRequiresCredential (no enumeration oracle); GET /auth/me exposes hasPassword; per-method amr claims (pwd|webauthn|oauth|mfa, RFC 8176, opt-in EmitAmr).
  • First-class recovery codes: Generation, non-consuming verification and atomic single-use redemption; only SHA-256 hashes persisted; configurable expiry; dedicated anti-abuse scope.
  • Per-account abuse prevention (S1): Multi-scope, time-based, escalating lockout (password, MFA, passkey, recovery, verify-action), distributable via SPI, in-memory default.
  • Refresh Token Rotation (RTR): Protects against token theft; with a real grace period for client races and session assurance (amr/mfa_method) preserved across rotation.
  • Security Stamp Versioning (SSV): Invalidate all of a user's sessions instantly (Panic Button).
  • MFA + step-up (S3): TOTP (RFC 6238), email codes, mfa_verified window, verify-action, and create/change password with token re-issuance.
  • Constant-Time Verification: Prevents timing attacks during credential validation (Argon2 dummy, OIDC nonce, OTP).
  • Atomic anti-replay / single-use (S2): Cross-cutting "consume once" primitive for OAuth state, WebAuthn challenges, OTP and recovery codes (extensible to Redis GETDEL/Lua).
  • OAuth2/OIDC: Social login (Google, Microsoft, Apple, GitHub, Facebook, LinkedIn, TikTok) with cryptographic JWKS validation and client_secret never in URLs.
  • Opt-in access-token blacklist (A-24): ITokenBlacklist (no-op default) — hosts can revoke the access token's jti on logout with TTL = remaining lifetime.
  • Anti-DoS: Payload limits on anonymous endpoints and per-IP rate limiting (login, forgot-password, WebAuthn, recovery codes).

📄 Documentation

For more details, check the extended documentation:


🤝 Contribution

Contributions are welcome. Please follow the coding standards and keep test coverage above 90%.


Built with ❤️ by the SecureCore team.

About

Identity & session management for ASP.NET Core: JWT, refresh token rotation, Argon2id, MFA (TOTP/email), WebAuthn/Passkeys and OAuth2/OIDC social login — Gestión de identidad y sesiones para ASP.NET Core: JWT, rotación de refresh tokens, Argon2id, MFA (TOTP/email), WebAuthn/Passkeys y login social OAuth2/OIDC.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages