auth-implementation-patterns

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

Updated Dec 23, 2025
One-click install
npx skills add https://github.com/drgaciw/academic-compliance-hub-glm --skill auth-implementation-patterns-drgaciw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth-implementation-patterns
Source: https://github.com/drgaciw/academic-compliance-hub-glm/tree/main/agents/plugins/developer-essentials/skills/auth-implementation-patterns
Command: npx skills add https://github.com/drgaciw/academic-compliance-hub-glm --skill auth-implementation-patterns-drgaciw

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires jsonwebtoken, express-session, passport, passport-google-oauth20, bcrypt, zod, express-rate-limit, connect-redis, 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, and OAuth2/OpenID Connect.
  • Authorization Patterns: Implements 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 API endpoint using the provided TypeScript middleware.

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 an API endpoint?

You implement JWT authentication by applying TypeScript middleware to validate stateless tokens and enforce role-based access control before granting access to sensitive API endpoints. This ensures only authorized users can access protected data.

What's the best way to set up OAuth2 with Passport?

The best way to set up OAuth2 with Passport is configuring the passport-google-oauth20 strategy to handle external identity providers. This enables OpenID Connect flows for secure, delegated access control in your application.

How does RBAC compare to permission-based access control?

RBAC assigns permissions to roles rather than individual users, simplifying management at scale. Permission-based control checks granular rights per resource, while RBAC relies on role hierarchies to enforce access policies across the application.

Can I use Redis for session management and rate limiting?

You can use Redis for session management and rate limiting by integrating connect-redis with express-session and rate-limit-redis. This stores session data and tracks API requests externally to secure scalable applications against abuse.

How do I validate user input securely before generating a session?

You validate user input securely before generating a session by applying zod schemas to parse incoming request data. This prevents malformed payloads from reaching your authentication logic and ensures data integrity throughout the auth flow.

Why do I need bcrypt for password security?

You need bcrypt for password security to salt and hash user credentials before storing them in your database. This protects against plaintext exposure and mitigates brute-force attacks by adding computational cost to credential verification.