Muster fir Authentifikatioun: Verglach tëscht Session, JWT an OAuth, Wiel vun engem Provider (NextAuth, Clerk, Supabase Auth), Sécherheetschecklëscht a heefeg Feeler. Benotzt dëse Skill, wann Dir Authentifikatioun implementéiert, Auth-Flëss iwwerpréift oder Auth-Provider auswielt.
Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.
Funktionéiert mat all LLM
KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.
Alles an den Instruktiounen
Alles, wat de Modell brauch, steet an den Instruktiounen — keng zousätzlech Dateien ze synchroniséieren.
Open Source
zebbern huet de Skill op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.
Installatioun
Installéiert de KI-Skill Authentication Patterns an TypingMind, fir e mat all LLM ze benotzen, oder setzt en an en anere KI-Agent an, deen SKILL.md liest.
1
An TypingMind installéieren
TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.
Maacht d'App op a gitt op Plugins → Skills.
Wielt „Vu GitHub installéieren“.
Pecht d'URL vum Skill-Dossier, déi hei drënner steet, an a bestätegt d'Installatioun.
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.
An TypingMind benotzen
Aktivéiert Authentication Patterns an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.
SkillsSkill lueden"authentication-patterns"
GPT-6 Astra
De Modell luet Authentication Patterns automatesch, soubal eng Ufro dozou passt.
Funktionéiert mat all KI-Modell
KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Authentication Patterns net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Schlësselen.
Gëtt nëmme gelueden, wann et néideg ass
De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.
De Modell am lafende Chat wiesselen
Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.
Skill-Instruktiounen
Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.
Authentication Patterns Skill
Reference for implementing secure, production-ready authentication.
WHEN_TO_USE
Apply this skill when implementing authentication in a project, reviewing existing auth flows for security issues, choosing between auth providers, or migrating between auth strategies. Use the security checklist before shipping any auth-related change.
AUTH_APPROACHES
Approach
How It Works
Best For
Drawbacks
Session-based
Server stores session in DB/Redis, client holds session ID cookie
Traditional server-rendered apps, apps needing instant revocation
Requires server-side storage, harder to scale horizontally without shared store
JWT (stateless)
Server signs token, client sends it on each request
API-first apps, microservices, mobile clients
Cannot revoke without blocklist, token size grows with claims
OAuth 2.0 / OIDC
Delegates auth to external provider (Google, GitHub, etc.)
Social login, enterprise SSO, reducing auth responsibility
More complex flow, depends on external provider availability
Passkeys / WebAuthn
Cryptographic key pair, no passwords
High-security apps, passwordless UX
Limited browser support legacy, user education needed
Decision Guide
Server-rendered app with simple needs → Session-based
SPA or mobile app calling APIs → JWT with refresh token rotation
Want social login or SSO → OAuth 2.0 / OIDC
Greenfield with modern UX goals → Passkeys + OAuth fallback
JWT_BEST_PRACTICES
Token Lifecycle
Login → Access Token (short-lived) + Refresh Token (long-lived, rotated)
│
├─ Access Token: 15 min expiry, sent via httpOnly cookie or Authorization header
│
└─ Refresh Token: 7-30 day expiry, stored in httpOnly secure cookie
│
└─ On use: issue new access + new refresh token, invalidate old refresh token
Rules
[P0-MUST] Set short expiry on access tokens (15 minutes or less).
[P0-MUST] Store tokens in httpOnly, Secure, SameSite=Lax cookies — never in localStorage or sessionStorage.
[P0-MUST] Implement refresh token rotation — each refresh token is single-use.
[P0-MUST] Maintain a server-side blocklist for revoked refresh tokens.
[P1-SHOULD] Include only essential claims in JWT payload (sub, iat, exp, role). Keep it small.
[P1-SHOULD] Use asymmetric signing (RS256 or ES256) for distributed systems; symmetric (HS256) for single-service only.
[P1-SHOULD] Validate iss, aud, and exp claims on every request.
[P2-MAY] Use JWE (encrypted JWT) when token payload contains sensitive data.
Token Storage Comparison
Storage
XSS Safe
CSRF Safe
Recommendation
httpOnly cookie
Yes
No (needs CSRF token)
Recommended
localStorage
No
Yes
Never use for auth tokens
sessionStorage
No
Yes
Never use for auth tokens
In-memory (JS variable)
Yes
Yes
OK for SPAs, lost on refresh
PROVIDER_PATTERNS
Comparison
Provider
Type
Best For
Pricing
Key Features
NextAuth / Auth.js
OSS library
Next.js apps wanting full control
Free
80+ providers, DB adapters, self-hosted
Clerk
Managed service
Fast launch, pre-built UI, user management
Free tier, then per-MAU
Drop-in components, user dashboard, org support
Supabase Auth
Managed (part of Supabase)
Apps already using Supabase for DB/storage
Free tier, then per-MAU
Row-level security integration, magic links, SSO
Lucia
OSS library
Full control, minimal abstraction
Free
Session-based, framework-agnostic, type-safe
When to Use Each
NextAuth / Auth.js: You want provider flexibility, self-hosting, and database session control. Best when you need custom flows.
Clerk: You want auth done fast with pre-built UI components. Best for MVPs and teams that don't want to build auth UI.
Supabase Auth: You're already using Supabase. Auth integrates with RLS policies for row-level security.
Lucia: You want a minimal, type-safe session library without framework lock-in.
Rate limiting: Login endpoint limited to 5-10 attempts per minute per IP.
CSRF protection: Anti-CSRF tokens on all state-changing requests (or use SameSite=Lax cookies).
Password hashing: Using bcrypt (cost 12+) or argon2id — never MD5, SHA-1, or plain SHA-256.
HTTPS only: All auth endpoints served over TLS. Cookies have Secure flag.
Input validation: Email format, password length (min 8, max 128), no SQL/NoSQL injection vectors.
Account enumeration: Login and registration return the same response whether account exists or not.
Session invalidation: Logout invalidates server-side session/refresh token, not just client cookie.
MFA support: TOTP (authenticator app) or WebAuthn as second factor for sensitive accounts.
Password reset: Time-limited tokens (1 hour), single-use, sent over secure channel.
Audit logging: Log auth events (login, logout, failed attempts, password changes) with timestamp and IP.
Password Hashing
typescript
// Using bcrypt
import bcrypt from "bcrypt";
const SALT_ROUNDS = 12;
async function hashPassword(password: string): Promise<string> {
return bcrypt.hash(password, SALT_ROUNDS);
}
async function verifyPassword(password: string, hash: string): Promise<boolean> {
return bcrypt.compare(password, hash);
}
typescript
// Using argon2 (preferred for new projects)
import argon2 from "argon2";
async function hashPassword(password: string): Promise<string> {
return argon2.hash(password, { type: argon2.argon2id });
}
async function verifyPassword(hash: string, password: string): Promise<boolean> {
return argon2.verify(hash, password);
}
COMMON_MISTAKES
Mistake
Risk
Fix
Storing JWT in localStorage
XSS can steal tokens
Use httpOnly cookies
Long-lived JWTs (days/weeks)
Stolen token is valid for extended period
15 min access token + refresh rotation
Missing CSRF protection
Attackers can forge requests from other sites
SameSite=Lax cookies + CSRF token
Weak password requirements
Brute force and credential stuffing
Min 8 chars, check against breached password lists
Exposing user existence on login
Account enumeration
Generic "Invalid credentials" message
Not rotating refresh tokens
Stolen refresh token grants indefinite access
Single-use refresh tokens with rotation
Hardcoding secrets in source
Credential leak via git history
Use environment variables, never commit secrets
Missing rate limiting on login
Brute force attacks
5-10 attempts/min per IP, exponential backoff
Rolling your own crypto
Subtle vulnerabilities
Use established libraries (bcrypt, argon2, jose)
Not validating JWT claims
Token misuse across services
Always verify iss, aud, exp
Heefeg gestallte Froen
Wat mécht de KI-Skill Authentication Patterns?
Muster fir Authentifikatioun: Verglach tëscht Session, JWT an OAuth, Wiel vun engem Provider (NextAuth, Clerk, Supabase Auth), Sécherheetschecklëscht a heefeg Feeler. Benotzt dëse Skill, wann Dir Authentifikatioun implementéiert, Auth-Flëss iwwerpréift oder Auth-Provider auswielt.
Firwat Authentication Patterns op TypingMind benotzen?
Well Dir en eemol installéiert a mat all Modell benotze kënnt. Authentication Patterns besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt, amplaz en Abonnement pro Benotzerplaz ze bezuelen. Är Skills a Chats bleiwen an Ärem eegene Späicher.
Wéi installéieren ech Authentication Patterns an TypingMind?
Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/zebbern/claude-code-guide/tree/main/skills/authentication-patterns an. TypingMind liest d'Datei SKILL.md an installéiert de Skill, deen Dir pro Chat aktivéiere kënnt.
Wéi eng KI-Modeller kënnen Authentication Patterns benotzen?
All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.
Wéi vill KI-Modeller kann ech mat Authentication Patterns benotzen?
Esou vill wéi Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Authentication Patterns domat benotzen – zum Beispill mat GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama – alles op TypingMind mat Ären eegenen API-Schlësselen.
Ass de KI-Skill Authentication Patterns gratis?
Jo. zebbern huet de Skill ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.
Wat si KI-Skills?
E KI-Skill ass e weiderverwendbare Pak vun Instruktiounen, deen engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.
Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?
E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt e maache soll a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a kee Lafzäitëmfeld a funktionéiere mat all Modell.