auth-implementation-patterns

Implement JWT authentication and RBAC for Express.js APIs.

2|Updated Feb 5, 2026
One-click install
npx skills add https://github.com/yashvinthan/DuskSpendr --skill auth-implementation-patterns-yashvinthan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth-implementation-patterns
Source: https://github.com/yashvinthan/DuskSpendr/tree/main/.agents/skills/auth-implementation-patterns
Command: npx skills add https://github.com/yashvinthan/DuskSpendr --skill auth-implementation-patterns-yashvinthan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jsonwebtoken, express-session, passport, passport-google-oauth20, passport-github2, bcrypt, zod, express-rate-limit, rate-limit-redis, connect-redis, redis, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill provides comprehensive guidance and code examples for implementing secure and scalable authentication and authorization systems, addressing common security vulnerabilities and best practices.

Core Features & Use Cases

  • Authentication Strategies: Covers session-based, JWT, and OAuth2/OpenID Connect.
  • Authorization Patterns: Implements Role-Based Access Control (RBAC), permission-based control, and resource ownership checks.
  • Security Best Practices: Details password security, rate limiting, and common pitfalls.
  • Use Case: Secure a new API endpoint by implementing JWT authentication and role-based access control to ensure only authorized users can access sensitive data.

Quick Start

Implement JWT authentication for an Express.js API using the provided TypeScript middleware and token generation functions.

Frequently Asked Questions about auth-implementation-patterns

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

FAQPage Schema
How do I implement JWT authentication in an Express.js API?

Implement JWT authentication in Express.js by using the jsonwebtoken dependency for token generation and validation middleware. This Skill provides TypeScript code examples to secure API endpoints, ensuring only authorized users with valid tokens can access sensitive data.

What is the best way to set up OAuth2 with Passport in Node.js?

Set up OAuth2 in Node.js by integrating the Passport library with specific strategies like passport-google-oauth20 and passport-github2. This Skill demonstrates how to configure these strategies to handle external provider authentication securely within your application.

How do I implement Role-Based Access Control for API authorization?

Implement Role-Based Access Control (RBAC) by defining user roles and permissions, then enforcing them through Express middleware. This Skill provides patterns for authorization, including permission-based control and resource ownership checks to protect sensitive API data.

Does this authentication pattern support rate limiting and Redis?

Yes, the authentication patterns support rate limiting using express-rate-limit and rate-limit-redis. It integrates with Redis via connect-redis and express-session to manage distributed rate limiting and secure session storage effectively.

Do I need Redis to handle session management for authentication?

Redis is required if you need distributed session management and scalable rate limiting. The Skill uses connect-redis and express-session to store session data in Redis, ensuring persistent and secure user sessions across multiple server instances.

How do I securely hash passwords and validate input in Node.js?

Securely hash passwords using the bcrypt dependency and validate input data using zod schemas. This Skill addresses security best practices by detailing robust password hashing techniques and strict input validation to prevent common vulnerabilities.