Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
wshobson avatar

Auth Implementation Patterns

  • 11.2k installs
  • 38.5k repo stars
  • Updated July 22, 2026
  • wshobson/agents

How to implement secure, scalable authentication and authorization systems using JWT, OAuth2, session management, and RBAC.

About

Skill covers authentication and authorization patterns for building secure access control systems. Covers session-based auth, JWT tokens, OAuth2/OpenID Connect, and role-based access control (RBAC). Developers use this when implementing user authentication, securing REST/GraphQL APIs, adding social login, designing session management, or debugging auth issues. Key workflows include verifying identity, issuing credentials, permission checking, and policy enforcement. Includes best practices for password hashing, HTTPS, token expiration, secure cookies, input validation, rate limiting, CSRF protection, secret rotation, security logging, and MFA.

  • Session-based, JWT token-based, and OAuth2/OpenID Connect authentication strategies
  • Role-based access control (RBAC) and resource ownership validation patterns
  • Best practices: bcrypt/argon2 hashing, short-lived tokens (15-30 min), httpOnly secure cookies, rate limiting
  • Security checklist covers HTTPS, CSRF protection, secret rotation, security event logging, and MFA
  • Common pitfalls: weak passwords, JWT in localStorage, missing token expiration, client-side-only auth checks, insecure p

Auth Implementation Patterns by the numbers

  • 11,176 all-time installs (skills.sh)
  • +323 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Ranked #71 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

auth-implementation-patterns capabilities & compatibility

Capabilities
design session based and token based auth flows · implement jwt issuing and validation · configure oauth2 and social login providers · model and enforce role based access control · apply password hashing and validation · implement rate limiting and csrf protection
Use cases
api development · security audit · code review
npx skills add https://github.com/wshobson/agents --skill auth-implementation-patterns

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs11.2k
repo stars38.5k
Security audit3 / 3 scanners passed
Last updatedJuly 22, 2026
Repositorywshobson/agents

What it does

Implement JWT, OAuth2, session management, and RBAC patterns for secure API authentication and authorization systems.

Who is it for?

Backend engineers building APIs, securing multi-user systems, implementing SSO or multi-tenancy, debugging auth failures.

Skip if: Frontend-only concerns; client-side UI frameworks unrelated to auth logic.

When should I use this skill?

Starting auth system design, integrating social login, migrating authentication, diagnosing security issues, scaling horizontally.

What you get

Implement stateless or stateful auth, delegate via OAuth2, enforce permissions via RBAC, and follow 10+ security best practices.

  • JWT token helpers
  • Auth middleware modules
  • Refresh token flow patterns

By the numbers

  • 10 best practices documented
  • 6 authentication/authorization use cases covered
  • 3 authentication strategies (session-based, JWT, OAuth2)

Files

SKILL.mdMarkdownGitHub ↗

Authentication & Authorization Implementation Patterns

Build secure, scalable authentication and authorization systems using industry-standard patterns and modern best practices.

When to Use This Skill

  • Implementing user authentication systems
  • Securing REST or GraphQL APIs
  • Adding OAuth2/social login
  • Implementing role-based access control (RBAC)
  • Designing session management
  • Migrating authentication systems
  • Debugging auth issues
  • Implementing SSO or multi-tenancy

Core Concepts

1. Authentication vs Authorization

Authentication (AuthN): Who are you?

  • Verifying identity (username/password, OAuth, biometrics)
  • Issuing credentials (sessions, tokens)
  • Managing login/logout

Authorization (AuthZ): What can you do?

  • Permission checking
  • Role-based access control (RBAC)
  • Resource ownership validation
  • Policy enforcement

2. Authentication Strategies

Session-Based:

  • Server stores session state
  • Session ID in cookie
  • Traditional, simple, stateful

Token-Based (JWT):

  • Stateless, self-contained
  • Scales horizontally
  • Can store claims

OAuth2/OpenID Connect:

  • Delegate authentication
  • Social login (Google, GitHub)
  • Enterprise SSO

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Best Practices

1. Never Store Plain Passwords: Always hash with bcrypt/argon2 2. Use HTTPS: Encrypt data in transit 3. Short-Lived Access Tokens: 15-30 minutes max 4. Secure Cookies: httpOnly, secure, sameSite flags 5. Validate All Input: Email format, password strength 6. Rate Limit Auth Endpoints: Prevent brute force attacks 7. Implement CSRF Protection: For session-based auth 8. Rotate Secrets Regularly: JWT secrets, session secrets 9. Log Security Events: Login attempts, failed auth 10. Use MFA When Possible: Extra security layer

Common Pitfalls

  • Weak Passwords: Enforce strong password policies
  • JWT in localStorage: Vulnerable to XSS, use httpOnly cookies
  • No Token Expiration: Tokens should expire
  • Client-Side Auth Checks Only: Always validate server-side
  • Insecure Password Reset: Use secure tokens with expiration
  • No Rate Limiting: Vulnerable to brute force
  • Trusting Client Data: Always validate on server

Related skills

How it compares

Use auth-implementation-patterns for hand-rolled JWT and session code in Express or Next.js rather than OAuth provider integration guides.

FAQ

Should I use session-based or token-based authentication?

Session-based is traditional and stateful; token-based (JWT) is stateless and scales horizontally. OAuth2/OpenID Connect delegates auth to external providers for social login and enterprise SSO.

What is the recommended token expiration time?

Use short-lived access tokens (15-30 minutes max) and refresh tokens for longer-term access. Always validate tokens server-side and rotate secrets regularly.

Why is storing JWT in localStorage dangerous?

localStorage is vulnerable to XSS attacks. Use httpOnly cookies instead, which are inaccessible to JavaScript and include secure and sameSite flags.

Is Auth Implementation Patterns safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Backend & APIsappseccompliance

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.