Skip to content

rblez/auser

Repository files navigation

Auser

License: MIT Node.js >= 18

Edge Access Layer & Anti-Bot — Sistema de seguridad perimetral para proteger aplicaciones SaaS contra bots y ataques automatizados.

Proxy edge + Motor de riesgo en tiempo real + Desafíos WebAuthn/Passkeys + SDKs multi-lenguaje

Características

  • Proxy Edge Fastify: Proxy de baja latencia (< 50ms) con rate limiting y security headers
  • Motor de Riesgo: Scoring multivariado con detección de bots por UA, request rate y concurrencia
  • WebAuthn/Passkeys: Sistema de desafíos step-up sin CAPTCHAs tradicionales
  • Upstash Redis: Base de datos serverless para sesiones, rate limiting y scoring
  • SDKs Multi-Lenguaje: JavaScript, Python y Go con API consistente
  • Dashboard Next.js: Monitoreo y métricas en tiempo real

Arquitectura

Cliente → Edge Proxy (Fastify) → Risk Engine (API + Upstash Redis) → Decisión
                                                                        ↓
                                                ┌───────────────────────┼───────────────────────┐
                                                ↓                       ↓                       ↓
                                             allow                  challenge                 block
                                          (forward to              (WebAuthn)               (403)
                                           backend)

Inicio Rápido

1. Instalación

git clone https://github.com/rblez/auser.git
cd auser
npm install

2. Configurar Variables de Entorno

cp .env.example .env

Edita .env con tus credenciales de Upstash Redis:

UPSTASH_REDIS_REST_URL=https://your-instance.upstash.io
UPSTASH_REDIS_REST_TOKEN=your-token-here
API_SECRET=your-secret-key-here

3. Iniciar Servicios

# Todos los servicios
npm run dev

# O individualmente
npm run dev:edge-proxy   # Proxy en puerto 3001
npm run dev:api          # API Risk Engine en puerto 3002
npm run dev:dash         # Dashboard en puerto 3003

Uso del SDK

JavaScript / TypeScript

npm install @auser/js
import { createClient } from "@auser/js";

const client = createClient({ apiUrl: "http://localhost:3002" });

const result = await client.protect({
  ip: "1.2.3.4",
  userAgent: "Mozilla/5.0...",
  method: "POST",
  path: "/api/login",
});

// result: { score: 15, action: 'allow', factors: ['normal_traffic'] }

Python

pip install auser-sdk
import asyncio
from auser_sdk import create_client

async def main():
    client = create_client(api_url='http://localhost:3002')
    result = await client.protect(
        ip='1.2.3.4',
        user_agent='Mozilla/5.0...',
        method='POST',
        path='/api/login',
    )
    print(f"Score: {result.score}, Action: {result.action}")

asyncio.run(main())

Go

go get github.com/rblez/auser/sdk-go
client := auser.NewClient("http://localhost:3002", "")

result, err := client.Protect(
    context.Background(),
    "1.2.3.4",
    "Mozilla/5.0...",
    "POST",
    "/api/login",
    nil,
)

Estructura del Proyecto

auser/
├── apps/
│   ├── edge-proxy/      # Proxy Fastify core
│   ├── api/             # Risk Engine API (Fastify + WebAuthn)
│   └── dash/            # Dashboard Next.js
├── packages/
│   ├── js/              # SDK JavaScript
│   ├── py/              # SDK Python
│   ├── go/              # SDK Go
│   └── shared/          # Tipos y utilidades compartidas
├── docs/                # Documentación (Nextra)
├── infra/               # Docker, Nginx, scripts
└── .github/             # GitHub Actions CI/CD

Risk Scoring

El motor evalúa múltiples factores con pesos ponderados:

Factor Peso Descripción
User Agent 40% Patrones sospechosos (bots, scrapers, headless)
Request Rate 35% Frecuencia de requests por IP
Concurrent Requests 25% Requests simultáneos
Score Acción Descripción
0-49 allow Tráfico normal, forward al backend
50-79 challenge Verificación WebAuthn requerida
80-100 block Tráfico bloqueado (403)

Comandos

Comando Descripción
npm run dev Iniciar todos los servicios en desarrollo
npm run dev:edge-proxy Iniciar solo edge proxy
npm run dev:api Iniciar solo API risk engine
npm run dev:dash Iniciar solo dashboard
npm run build Build de todos los packages y apps
npm test Ejecutar tests
npm run lint Linting del código
npm run lint:fix Linting con auto-fix

Tecnologías

Componente Stack
Edge Proxy Fastify (Node.js) + TypeScript
Risk Engine Fastify + TypeScript + Upstash Redis
Dashboard Next.js 15 + React 19
SDKs JavaScript, Python, Go
Base de Datos Upstash Redis (serverless)
Autenticación WebAuthn / Passkeys
Documentación Nextra (Next.js + MDX)

Seguridad

  • Rate Limiting: 100 req/15min general, 5 req/15min auth endpoints
  • WebAuthn: Desafíos step-up con cookies httpOnly, secure, sameSite
  • Security Headers: CSP, X-Content-Type-Options, X-Frame-Options, HSTS
  • HMAC-SHA256: Verificación de webhooks con ventana de 15 minutos
  • SSRF Protection: Bloqueo de intentos de acceso a metadata services
  • No Raw Header Leaks: Eliminación automática de headers sensibles

Métricas de Éxito

Métrica Objetivo
Latencia del proxy < 50ms
Precisión detección de bots > 99%
Tasa de conversión de desafíos 5-8%
Tasa de falsos positivos < 2%

Documentación

La documentación completa está disponible en rblez.github.io/auser.

Contributing

  1. Fork el repositorio
  2. Crea una feature branch (git checkout -b feature/amazing-feature)
  3. Haz tus cambios y commitea (git commit -m 'feat: add amazing feature')
  4. Push a la branch (git push origin feature/amazing-feature)
  5. Abre un Pull Request

Convención de Commits

feat: nueva funcionalidad
fix: corrección de bug
chore: mantenimiento
security: cambio de seguridad (OBLIGATORIO para cambios de seguridad)
docs: documentación

Licencia

MIT © 2026 Ray

About

Edge Access Layer & Anti-Bot - Sistema de seguridad perimetral para SaaS con proxy edge, risk engine, WebAuthn y SDKs multi-lenguaje

Topics

Resources

License

Stars

Watchers

Forks

Contributors