auth-architecture

Design authentication and authorization architecture with JWT, OAuth2, RBAC, and MFA patterns.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill auth-architecture-kalilurrahman
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: auth-architecture
Source: https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts/tree/main/05-security/auth-architecture
Command: npx skills add https://github.com/kalilurrahman/kr-claudiator-skills-original-prompts --skill auth-architecture-kalilurrahman

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Designing authentication and authorization incorrectly leads to catastrophic security failures, yet many teams start coding before deciding on token strategy, permission models, and trust boundaries. This Skill provides a structured process and production-grade implementation patterns for making these decisions deliberately. ## Core Features & Use Cases - Token Strategy Design: Decision matrix for choosing between session cookies, short-lived JWTs with refresh tokens, mTLS, and API keys based on application type. - Complete Implementation Patterns: Python/FastAPI code for JWT issuance with RS256, refresh token rotation with reuse detection, RBAC permission resolution, OAuth2 social login, and TOTP-based MFA with backup codes. - Use Case: You are building a SaaS API with web and mobile clients. Use this Skill to map all auth flows (login, refresh, logout, MFA), implement refresh token rotation that detects token theft, and enforce fine-grained permissions like "orders:delete" via FastAPI dependencies. ## Quick Start Design the authentication architecture for my multi-tenant SaaS application with Google OAuth login, role-based permissions, and MFA support.

Frequently Asked Questions about auth-architecture

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

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

Store hashed refresh tokens server-side and invalidate each token on use, issuing a new pair. If a previously rotated token is presented again, treat it as theft and revoke all sessions for that user. Use short-lived access tokens (15 minutes) alongside 30-day refresh tokens.

Should I use JWT or session cookies for authentication?

Use HttpOnly session cookies for same-domain web apps since they are CSRF-safe and instantly revocable. Use short-lived JWTs with refresh tokens for SPAs on different domains or mobile apps where stateless verification across services matters.

RS256 vs HS256 for JWT signing, which should I use?

Use RS256 (asymmetric) so services can verify tokens with only the public key without knowing the signing secret. HS256 requires sharing the secret with every verifying service, increasing exposure if any service is compromised.

How do I implement RBAC permissions in FastAPI?

Map roles to sets of fine-grained permission strings like "orders:delete", resolve the union of permissions from all user roles, and enforce them with a FastAPI dependency that checks required permissions against token claims. Add resource-level ownership checks in route handlers.

Where should refresh tokens be stored on the client?

Store refresh tokens in HttpOnly, Secure, SameSite cookies, never in localStorage where JavaScript can access them. HttpOnly prevents XSS-based token theft, and SameSite=lax provides CSRF protection.

How do I detect stolen refresh tokens?

Rotate refresh tokens on every use and track recently rotated token hashes. If an already-rotated token is presented again, it indicates replay by an attacker, so revoke all sessions for that user immediately.