auth-implementation-patterns

Implement JWT, OAuth2, RBAC, and Redis session authentication patterns.

Updated Sep 24, 2021
One-click install
npx skills add https://github.com/coolguy1771/dotfiles --skill auth-implementation-patterns-coolguy1771
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth-implementation-patterns
Source: https://github.com/coolguy1771/dotfiles/tree/main/chezmoi/private_dot_cursor/skills/auth-implementation-patterns
Command: npx skills add https://github.com/coolguy1771/dotfiles --skill auth-implementation-patterns-coolguy1771

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jsonwebtoken, passport, passport-google-oauth20, passport-github2, express-session, connect-redis, redis, bcrypt, zod, express-rate-limit, rate-limit-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 robust authentication and authorization mechanisms, ensuring secure and scalable access control for applications.

Core Features & Use Cases

  • Authentication Strategies: Covers session-based, JWT-based, and OAuth2/OpenID Connect flows.
  • 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 web application by implementing JWT authentication for APIs, RBAC for user roles, and rate limiting to prevent abuse.

Quick Start

Implement JWT authentication for your API endpoints using the provided 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 for my API endpoints?

JWT authentication for APIs involves generating tokens upon login and validating them via middleware on protected endpoints. This provides stateless access control for securing API routes.

What's the best way to implement RBAC and permission checks in Express?

Role-Based Access Control (RBAC) in Express assigns user roles and enforces permission checks via middleware before route handlers. This ensures users only access authorized resources.

How does OAuth2 integration with Passport.js work for social login?

OAuth2 integration with Passport.js uses strategies like Google or GitHub to authenticate users via third-party providers. It redirects users to the provider, then validates credentials to establish application sessions.

Do I need Redis for session management when using JWT?

Redis is not required for stateless JWT authentication, but it is essential for managing server-side sessions and refresh token blacklisting. Using connect-redis with express-session provides scalable session storage.

How do I secure passwords and prevent brute force attacks in my web application?

Secure passwords by hashing them with bcrypt before database storage. Prevent brute force attacks by implementing rate limiting using express-rate-limit and rate-limit-redis to restrict repeated API requests.

Can I use Zod for input validation when setting up authentication flows?

Zod can validate incoming request bodies during authentication flows, ensuring login and registration data conforms to expected schemas before processing credentials or generating authorization tokens.