ancoleman/ai-design-components/securing-authentication
Claude Code and agent skill by ancoleman/ai-design-components
- community
Checking that the SKILL.md file is still in the repository.
Authentication, authorization, and API security implementation. Use when building user systems, protecting APIs, or implementing access control. Covers OAuth 2.1/OIDC, JWT patterns, sessions, Passkeys/WebAuthn, RBAC/ABAC/ReBAC, policy engines (OPA, Casbin, SpiceDB), managed auth (Clerk, Auth0), self-hosted (Keycloak, Ory), and API security best practices.
Install
npx vskill@latest install ancoleman/ai-design-components/securing-authenticationSKILL.md
Authentication & Security
Implement modern authentication, authorization, and API security across Python, Rust, Go, and TypeScript.
When to Use This Skill
Use this skill when:
- Building user authentication systems (login, signup, SSO)
- Implementing authorization (roles, permissions, access control)
- Securing APIs (JWT validation, rate limiting)
- Adding passwordless auth (Passkeys/WebAuthn)
- Migrating from password-based to modern auth
- Integrating enterprise SSO (SAML, OIDC)
- Implementing fine-grained permissions (RBAC, ABAC, ReBAC)
OAuth 2.1 Mandatory Requirements (2025 Standard)
Critical: PKCE is now mandatory for ALL OAuth flows, not just public clients.
JWT Best Practices
Signing Algorithms (Priority Order)
- EdDSA with Ed25519 (Recommended)
- Fastest performance
- Smallest signature size
- Modern cryptography
- ES256 (ECDSA with P-256)
- Good performance
- Industry standard
- Wide compatibility
- RS256 (RSA)
- Legacy compatibility
- Larger signatures
- Slower performance
NEVER allow `alg: none` or algorithm switching attacks.
Token Lifetimes (Concrete Values)
- Access token: 5-15 minutes
- Refresh token: 1-7 days with rotation
- ID token: Same as access token (5-15 minutes)
Refresh token rotation: Each refresh generates new access AND refresh tokens, invalidating the old refresh token.
Token Storage
- Access token: Memory only (never localStorage)
- Refresh token: HTTP-only cookie + SameSite=Strict
- CSRF token: Separate non-HTTP-only cookie
- Never log tokens: Redact in application logs
JWT Claims (Required)
Password Hashing with Argon2id
OWASP 2025 Parameters
Implementation
For concrete implementations, see references/password-hashing.md.
Key Points:
- Argon2id is hybrid: data-independent timing + memory-hard
- Tune memory cost to achieve 150-250ms on YOUR hardware
- Use timing-safe comparison for verification
- Migrate from bcrypt gradually (verify with old, rehash with new)
Passkeys / WebAuthn
Passkeys provide phishing-resistant, passwordless authentication using FIDO2/WebAuthn.
When to Use Passkeys
- User-facing applications prioritizing security
- Reducing password-related support burden
- Mobile-first applications (biometric auth)
- Applications requiring MFA without SMS
Cross-Device Passkey Sync
- iCloud Keychain: Apple ecosystem (iOS 16+, macOS 13+)
- Google Password Manager: Android, Chrome
- 1Password, Bitwarden: Third-party password managers
For implementation guide, see references/passkeys-webauthn.md.
Authorization Models
For detailed comparison, see references/authorization-patterns.md.
Library Selection by Language
TypeScript
| Use Case | Library | Context7 ID | Trust | Notes | |
|---|---|---|---|---|---|
| Auth Framework | Auth.js v5 | /websites/authjs_dev | 87.4 | Multi-framework (Next, Svelte, Solid) | |
| JWT | jose 5.x | - | - | EdDSA, ES256, RS256 support | |
| Passkeys | @simplewebauthn/server 11.x | - | - | FIDO2 server | |
| Validation | Zod 3.x | /colinhacks/zod | 90.4 | Schema validation | |
| Policy Engine | Casbin.js 1.x | - | - | RBAC/ABAC embedded |
Python
| Use Case | Library | Notes | |
|---|---|---|---|
| Auth Framework | Authlib 1.3+ | OAuth/OIDC client + server | |
| JWT | joserfc 1.x | Modern, maintained | |
| Passkeys | py_webauthn 2.x | WebAuthn server | |
| Password Hashing | argon2-cffi 24.x | OWASP parameters | |
| Validation | Pydantic 2.x | FastAPI integration | |
| Policy Engine | PyCasbin 1.x | RBAC/ABAC embedded |
Rust
| Use Case | Library | Notes | |
|---|---|---|---|
| JWT | jsonwebtoken 10.x | EdDSA, ES256, RS256 | |
| OAuth Client | oauth2 5.x | OAuth 2.1 flows | |
| Passkeys | webauthn-rs 0.5.x | WebAuthn + attestation | |
| Password Hashing | argon2 0.5.x | Native Argon2id | |
| Policy Engine | Casbin-RS 2.x | RBAC/ABAC embedded |
Go
| Use Case | Library | Notes | |
|---|---|---|---|
| JWT | golang-jwt v5 | Community-maintained | |
| OAuth Client | go-oidc v3 | OIDC client only | |
| Passkeys | go-webauthn 0.11.x | Duo-maintained | |
| Password Hashing | golang.org/x/crypto/argon2 | Standard library | |
| Policy Engine | Casbin v2 | Original implementation |
Managed Auth Services
| Service | Best For | Key Features | |
|---|---|---|---|
| Clerk | Rapid development, startups | Prebuilt UI, Next.js SDK | |
| Auth0 | Enterprise, established | 25+ social providers, SSO | |
| WorkOS AuthKit | B2B SaaS, enterprise SSO | SAML/SCIM, admin portal | |
| Supabase Auth | Postgres users | Built on Postgres, RLS |
For detailed comparison, see references/managed-auth-comparison.md.
Self-Hosted Solutions
| Solution | Language | Use Case | |
|---|---|---|---|
| Keycloak | Java | Enterprise, on-prem | |
| Ory | Go | Cloud-native, microservices | |
| Authentik | Python | Modern, developer-friendly |
For setup guides, see references/self-hosted-auth.md.
API Security Best Practices
Rate Limiting
Use sliding window algorithm (not fixed window) with Redis.
CORS Configuration
Security Headers
For complete API security guide, see references/api-security.md.
Frontend Integration Patterns
Protected Routes (Next.js)
Role-Based UI Rendering
Common Workflows
1. OAuth 2.1 Integration
- Generate PKCE challenge
- Redirect to authorization endpoint
- Handle callback with authorization code
- Exchange code for tokens (with code_verifier)
- Store tokens securely
- Implement refresh token rotation
See references/oauth21-guide.md for complete implementation.
2. JWT Implementation
- Generate signing keys using
scripts/generate_jwt_keys.py - Configure token lifetimes (5-15 min access, 1-7 day refresh)
- Implement token validation middleware
- Set up refresh token rotation
- Configure token storage (memory for access, HTTP-only cookie for refresh)
See references/jwt-best-practices.md for detailed patterns.
3. Passkeys Setup
- Register credential during signup/settings
- Generate challenge for registration
- Verify attestation
- Store credential ID and public key
- Implement authentication flow with assertion
See examples/passkeys-demo/ for runnable implementation.
4. Authorization Engine Setup
- Choose engine (Casbin for simple RBAC, SpiceDB for ReBAC)
- Define schema/policies
- Implement check functions
- Integrate with route handlers
- Add audit logging
See references/authorization-patterns.md for detailed comparison.
Integration with Other Skills
Forms Skill
- Login/register forms with validation
- Error states for auth failures
- Password strength indicators
- Email validation
API Patterns Skill
- JWT middleware integration
- Error response formats (401, 403)
- OpenAPI security schemas
- CORS configuration
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/securing-authentication/SKILL.md
Popularity
- Repository stars
- 350
- Repository forks
- 53
- 7-day trend score
- 29
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 1 May 2026, 6 months ago.
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/ancoleman/ai-design-components/securing-authentication)