npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dcos-sls-auth-app

v1.0.56

Published

Este proyecto implementa un servicio de **Autenticación (Auth Service)** y **Autorización** basado en arquitectura **Serverless** utilizando AWS Lambda, API Gateway, y DynamoDB. La autenticación se realiza de forma **auto-hospedada** mediante **JSON Web T

Downloads

111

Readme

🔐 sls-auth-latam - Servicio de Autenticación Serverless (JWT Auto-Hospedado)

Este proyecto implementa un servicio de Autenticación (Auth Service) y Autorización basado en arquitectura Serverless utilizando AWS Lambda, API Gateway, y DynamoDB. La autenticación se realiza de forma auto-hospedada mediante JSON Web Tokens (JWT).

El servicio está diseñado para la región LATAM y sigue las mejores prácticas de Serverless y AWS IAM.


Inicio Rápido (Desarrollo Local)

Para desarrollar y probar este servicio en tu entorno local, utilizamos el plugin serverless-offline.

1. Prerrequisitos

Asegúrate de tener instalados:

  • Node.js (v20.x o superior)
  • npm (Node Package Manager)
  • AWS CLI configurado (para despliegue)
  • Serverless Framework CLI (npm install -g serverless)

2. Instalación de Dependencias

Navega al directorio raíz del proyecto e instala las dependencias de Node.js, incluyendo el plugin serverless-offline.

npm install

3. Ejecución Local

Inicia el servidor Serverless local. Esto simulará la API Gateway y las funciones Lambda.

serverless offline start

El servicio estará disponible en http://localhost:3000 (o el puerto configurado por defecto).


Configuración y Componentes (serverless.yml)

El servicio utiliza nodejs20.x en la región us-east-1 y gestiona automáticamente las etapas de despliegue.

1. Variables de Entorno Clave

|Variable|Valor por Defecto|Descripción| | :- | :- | :- | |JWT_SECRET|your-super-secret-key|Clave secreta para firmar y verificar JWTs. ¡Debe ser reemplazada en producción!| |TABLE_NAME_AUTH_LOGIN_APP|sls-auth-latam-{stage}-auth-login-app|Nombre de la tabla DynamoDB de credenciales.| |SCOPE_DEFAULT|client.rol/client.rol.read|Define el scope por defecto para los tokens emitidos.| |PATH_SLS|serverless.yml|Consulta la ruta donde se obtienen los scopes de las funciones lambda configuradas.| |VERSION_IAM|2012-10-17|Versión IAM aceptada por AWS.|

2. Base de Datos (DynamoDB)

El proyecto provisiona la tabla sls-auth-latam-{stage}-auth-login-app para almacenar las credenciales de clientes (ClientId y Secret) y la información de autorización (scopes/roles).

|Atributo Clave (HASH)|Índice Secundario Global (GSI)| | :- | :- | |ClientId (String)|SecretIndex (HASH: Secret (String))|

3. Funciones Lambda y Endpoints

|Función|Handler|Método(s)|Ruta|Propósito| | :- | :- | :- | :- | :- | |login|handler.login|POST|/login|Valida credenciales y emite un JWT. Requiere permisos de lectura/escritura en la tabla DynamoDB.| |authorizer|handler.authorizer|N/A|N/A|Valida el JWT y sus scopes. Configurado como Authorizer type: jwt.| |test|handler.test|GET|/test|Endpoint protegido. Requiere scopes específicos (admin.rol/admin.rol.read o vtex.rol/vtex.rol.read).| |clientauthadmin|authAdmin.handler|PATCH, GET, DELETE|/oauth2/pvt/client...|Endpoints de administración para gestionar credenciales de clientes.|


Pruebas de Endpoints

1. Obtención de Token (Login)

Ruta: POST /login

Función: login

Cabecera de Solicitud:

Authorization: Basic Base64([clientId_AQUÍ]:[secret_AQUÍ])

2. Acceso a Ruta Protegida (Test)

Ruta: GET /test

Función: test

Requerimiento: Incluir el token JWT obtenido del /login en la cabecera.

Cabecera de Solicitud:

Authorization: Bearer [TOKEN_JWT_AQUÍ]

Si el token es válido y tiene los scopes requeridos (admin.rol/admin.rol.read o vtex.rol/vtex.rol.read), la función se ejecutará. De lo contrario, el Authorizer la bloqueará.


Despliegue en AWS

El proyecto utiliza tags extensivos a nivel de stack y recurso (e.g., client: infracommerce, owner: dcos-team, country: LATAM).

1. Despliegue por Etapas (Stages)

Para desplegar en una etapa específica (ej. staging):

serverless deploy --stage staging

Si no se especifica el stage, por defecto se usa dev.

2. Eliminación del Servicio

Para eliminar todos los recursos del servicio en una etapa específica:

serverless remove --stage staging