sairam0424/mindforge/auth-patterns
Claude Code and agent skill by sairam0424/mindforge
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install sairam0424/mindforge/auth-patternsSKILL.md
The same SKILL.md was published earlier as sairam0424/mindforge/auth-patterns.
Skill — Auth Patterns
When this skill activates
Any task involving authentication flow design, authorization model selection, token lifecycle management, MFA implementation, or identity provider integration.
Mandatory actions when this skill is active
Before writing any code
- Identify the auth requirements: Who are the users? What are the trust boundaries?
- Select the appropriate OAuth2 flow for the client type.
- Decide between sessions and JWTs based on revocation requirements.
- Map out the authorization model (RBAC vs ABAC vs hybrid).
During implementation
- Never store plain-text credentials anywhere.
- Use short-lived access tokens (15 min max) with long-lived refresh tokens (7 days max).
- Implement token rotation on every refresh (detect reuse = compromised).
- Check permissions in code, never roles directly.
- Log every auth failure with context (IP, user agent, timestamp).
After implementation
- Verify no auth bypass exists on any protected route.
- Test token expiration and refresh flows end-to-end.
- Confirm MFA cannot be bypassed via API directly.
- Run security scan on auth-related endpoints.
OAuth2 Flows
Authorization Code + PKCE (SPAs, Mobile)
Use for: Browser apps, mobile apps, any public client.
Client Credentials (Machine-to-Machine)
Use for: Backend services, cron jobs, microservice-to-microservice.
Device Authorization (CLI, TV)
Use for: CLI tools, IoT devices, smart TVs.
Session vs JWT
Sessions (Server-Side)
- Pros: Instantly revocable, smaller payload, server controls lifetime.
- Cons: Requires session store (Redis), sticky sessions or shared store in distributed systems.
- Use when: You need instant revocation, have a monolith or can share session store.
JWT (Stateless)
- Pros: No server-side storage, works across services, self-contained claims.
- Cons: Cannot revoke until expiry (unless you add a blocklist, negating statelessness).
- Use when: Microservices, short-lived tokens acceptable, combined with refresh token rotation.
Hybrid (Recommended)
- Short-lived JWT access token (15 min) — never stored server-side.
- Long-lived refresh token (7 days) — stored server-side, rotated on each use.
- Revoke by deleting refresh token and waiting for access token expiry.
Token Rotation
MFA Implementation
TOTP (Time-Based One-Time Password) — Preferred
- Generate shared secret, encode as QR code for authenticator apps.
- Verify with time-window tolerance (±1 step = 30 seconds).
- Store backup codes (hashed) for account recovery.
WebAuthn / Passkeys — Most Secure
- Phishing-resistant (bound to origin).
- No shared secrets to steal.
- Use as primary or second factor.
SMS — Last Resort
- Vulnerable to SIM swapping.
- Use only if no alternative and combine with other signals.
Authorization Models
RBAC (Role-Based Access Control)
ABAC (Attribute-Based Access Control)
Hybrid (RBAC + ABAC)
- Use RBAC for coarse-grained access (can this user access this module?).
- Use ABAC for fine-grained rules (can this user edit THIS specific resource?).
Anti-patterns to avoid
- Storing JWT in localStorage (XSS vulnerable — use httpOnly cookies or memory).
- Checking roles instead of permissions in application code.
- Long-lived access tokens without refresh rotation.
- MFA bypass via direct API calls (always enforce server-side).
- Shared secrets in client-side code.
- Missing auth on internal/admin routes ("it's internal" is not security).
Self-check before task completion
Before marking a task done when this skill was active:
- [ ] No plain-text credentials stored anywhere?
- [ ] Access tokens are short-lived (≤15 min)?
- [ ] Refresh token rotation implemented and reuse detected?
- [ ] Permissions checked in code (not roles)?
- [ ] Every protected route has auth middleware?
- [ ] Auth failures logged with sufficient context?
- [ ] MFA cannot be bypassed via API?
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.mindforge/skills/auth-patterns/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/sairam0424/mindforge/auth-patterns)