jwt-auth-security

Implements JWT authentication, token rotation, and secure cookie patterns for Express applications.

Updated Aug 11, 2026
One-click install
npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill jwt-auth-security-duccuong159
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jwt-auth-security
Source: https://github.com/DucCuong159/Realtime-chatapp/tree/main/.agent/skills/jwt-auth-security
Command: npx skills add https://github.com/DucCuong159/Realtime-chatapp --skill jwt-auth-security-duccuong159

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires passport, passport-jwt, bcrypt, express-rate-limit.

What problem does it solve? Building secure authentication in Node.js and Express apps is error-prone: tokens get stolen via XSS, refresh flows leak credentials, and login endpoints get hammered by brute-force attacks. This Skill provides production-grade patterns for the full JWT token lifecycle so you avoid these common security pitfalls. ## Core Features & Use Cases - Access/Refresh Token Rotation: Short-lived JWT access tokens paired with long-lived refresh tokens stored in HttpOnly, SameSite, Secure cookies. - Passport JWT Integration: Cookie-and-header token extraction with a Passport JWT strategy and reusable requireAuth middleware for protecting Express routes. - Credential & Endpoint Hardening: bcrypt password hashing, Mongoose toJSON transforms that strip passwords, and express-rate-limit on auth endpoints to stop brute-force attacks. - Use Case: You are adding login and session management to a React + Express app. Use this Skill to configure secure cookies, wire up Passport JWT, hash passwords with bcrypt, and rate-limit the login route before shipping. ## Quick Start Use the jwt-auth-security skill to implement secure login with refresh token rotation and HttpOnly cookies in my Express TypeScript API.

Frequently Asked Questions about jwt-auth-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement JWT refresh token rotation in Express?

Issue a short-lived access token (around 15 minutes) and a long-lived refresh token (7-30 days), both stored in HttpOnly cookies. When the access token expires, the client calls a refresh endpoint that validates the refresh token and issues a new access token without re-login.

How to store JWT tokens securely in a React app?

Store tokens in HttpOnly, Secure, SameSite cookies rather than localStorage or sessionStorage, which are vulnerable to XSS token theft. Keep the access token in memory (e.g., Zustand state) if possible, and let the browser send cookies automatically.

Does Passport JWT support reading tokens from cookies?

Yes, Passport JWT accepts a custom token extractor function. Write a cookieExtractor that reads the access_token cookie from req.cookies, with a fallback to the Authorization Bearer header for API clients.

How do I prevent brute-force attacks on login endpoints?

Apply express-rate-limit to authentication routes, for example limiting requests to 10 attempts per IP per 15-minute window. Combine this with bcrypt hashing (12 salt rounds) so credential guessing remains slow even if hashes leak.

Why does my Mongoose user response leak the password hash?

Mongoose returns all schema fields by default, including password. Add a toJSON transform on the schema that deletes the password and __v fields, and use .select("-password") when querying users for authentication payloads.