kid-sid/claude-spellbook/auth
Claude Code and agent skill by kid-sid/claude-spellbook
- community
Checking that the SKILL.md file is still in the repository.
Use when implementing login flows, issuing or validating JWTs, setting up OAuth2/OIDC with a provider, designing role-based or attribute-based access control, securing API endpoints, or handling token refresh and revocation.
Install
npx vskill@latest install kid-sid/claude-spellbook/authSKILL.md
Authentication & Authorization
Patterns for identity, token management, and access control across web APIs and services.
When to Activate
- Implementing login, logout, or registration flows
- Issuing, validating, or refreshing JWTs
- Integrating an OAuth2/OIDC provider (Google, GitHub, Auth0, Keycloak)
- Designing role-based (RBAC) or attribute-based (ABAC) access control
- Securing REST or GraphQL endpoints with middleware/guards
- Handling token revocation, rotation, or blacklisting
- Auditing an existing auth implementation for security gaps
Core Concepts
Authentication vs. Authorization
| Concept | Question answered | Example | |
|---|---|---|---|
| Authentication | Who are you? | Login with email + password | |
| Authorization | What can you do? | Admin can delete; viewer can only read | |
| Identity | What do we know about you? | Email, roles, tenant ID in the token |
Token Types
| Type | Storage | Lifespan | Use for | |
|---|---|---|---|---|
| Access token (JWT) | Memory / header | 5–60 min | API calls | |
| Refresh token (opaque) | HttpOnly cookie | Days–weeks | Obtain new access tokens | |
| Session cookie | HttpOnly cookie | Session or sliding | Traditional web apps | |
| API key | Server-side only | Long-lived | M2M, developer integrations |
JWT Patterns
Structure and Signing
RS256 vs HS256
| HS256 | RS256 | ||
|---|---|---|---|
| Key type | Shared secret | Private/public key pair | |
| Who can verify | Anyone with the secret | Anyone with the public key | |
| Best for | Single service | Microservices, public JWKS endpoint | |
| Rotation | Requires coordinated redeploy | Rotate private key; publish new JWKS |
Use RS256 in production when multiple services verify tokens, or when tokens are issued by an identity provider.
OAuth2 / OIDC
Flow Selection
| Flow | Use when | Notes | |
|---|---|---|---|
| Authorization Code + PKCE | Browser SPA, mobile app | No client secret on device | |
| Authorization Code | Server-side web app | Store client secret server-side | |
| Client Credentials | M2M / service accounts | No user involved | |
| Device Code | CLI tools, smart TVs | User authenticates on a second device |
Never use Implicit flow — it is deprecated (RFC 9700).
Authorization Code + PKCE (SPA)
Client Credentials (M2M)
Token Storage
| Location | XSS safe | CSRF safe | Notes | |
|---|---|---|---|---|
| Memory (JS variable) | Yes | Yes | Lost on page refresh; best for SPAs | |
| HttpOnly cookie | Yes | No — add CSRF token | Best for refresh tokens | |
| localStorage | No | Yes | Never store tokens here | |
| sessionStorage | No | Yes | Cleared on tab close; still XSS-vulnerable |
Rule: Store access tokens in memory. Store refresh tokens in HttpOnly, SameSite=Strict cookies. Never put tokens in localStorage.
Token Refresh and Revocation
Silent Refresh Pattern
Revocation Strategies
| Strategy | How | Trade-off | |
|---|---|---|---|
| Short expiry | 5–15 min access tokens | No revocation needed; stale window is small | |
| Token blacklist | Store revoked JTIs in Redis | Instant revocation; requires Redis lookup per request | |
| Refresh token rotation | Issue new refresh token on each use; invalidate old | Detects theft; one-time-use tokens | |
| Opaque tokens + introspection | Validate tokens against auth server | Instant revocation; adds latency |
Access Control (RBAC / ABAC)
RBAC Middleware
ABAC Policy Check
Password Hashing
Always use a slow, salted hashing algorithm. Never use MD5, SHA-1, or SHA-256 for passwords.
| Algorithm | Library (Python) | Library (Node) | Recommended? | |
|---|---|---|---|---|
| bcrypt | bcrypt | bcrypt / argon2-browser | Yes | |
| Argon2id | argon2-cffi | argon2-browser | Yes — preferred | |
| scrypt | stdlib hashlib | stdlib crypto | Yes | |
| PBKDF2 | stdlib hashlib | stdlib crypto | Acceptable | |
| MD5 / SHA-* | — | — | Never |
Red Flags
- Storing tokens in localStorage — XSS can steal every token; use HttpOnly cookies for refresh tokens and in-memory for access tokens.
- Using HS256 across multiple services — all services share the secret; a compromise of one exposes all; use RS256 with a JWKS endpoint.
- Long-lived access tokens — a 24-hour JWT cannot be revoked without a blacklist; keep them under 15 minutes.
- Skipping `state` parameter in OAuth2 — omitting
stateenables CSRF attacks on the callback endpoint. - Rolling your own crypto — never implement JWT signing, hashing, or encryption from scratch; use audited libraries.
- Trusting the `alg` header from the token — an attacker can set
alg: none; always pin the algorithm server-side. - Returning 404 instead of 403 — security-by-obscurity doesn't prevent enumeration; return 403 Forbidden for authorization failures.
- No token rotation on refresh — refresh tokens that never rotate are permanent credentials; rotate on every use and invalidate the old one.
- Putting secrets in JWTs — JWTs are base64-encoded, not encrypted; any party with the token can read the payload.
- Broad OAuth scopes — request only the minimum scopes needed;
*oradminscopes violate least privilege.
Checklist
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 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 repositoryCheckingskills/auth/skill.md
Popularity
- Repository stars
- 186
- Repository forks
- 15
- 7-day trend score
- 26
Stars and forks are for the whole GitHub repository, not this skill alone. 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/kid-sid/claude-spellbook/auth)