authentication-security
БесплатноЗапускает вложенные скриптыНе проверенAuthentication security standards covering OAuth2 flows (authorization code, PKCE), JWT best practices (RS256, expiration), MFA (TOTP, WebAuthn), session…
Об этом скилле
Authentication Security
Quick Navigation: Level 1: Quick Start (5 min) → Level 2: Implementation (30 min) → Level 3: Mastery (Extended)
Level 1: Quick Start (<2,000 tokens, 5 minutes)
Core Principles
- Multi-Factor Always: Require MFA for sensitive operations (TOTP, WebAuthn, hardware keys)
- Secure Tokens: Use RS256 for JWT, never HS256 with shared secrets in distributed systems
- Short-Lived Tokens: Access tokens <15 min, refresh tokens with rotation
- OAuth2 with PKCE: Always use PKCE for SPAs and mobile apps
- Session Security: httpOnly, secure, sameSite cookies with CSRF protection
Essential Checklist
- OAuth2 flow: Authorization code with PKCE for public clients
- JWT signing: RS256 asymmetric keys, never embed secrets in tokens
- Token expiration: Access <15 min, refresh <7 days with rotation
- MFA enabled: TOTP (Google Authenticator) or WebAuthn (hardware keys)
- Session cookies: httpOnly=true, secure=true, sameSite=strict
- CSRF protection: State parameter for OAuth2, CSRF tokens for sessions
- Password storage: bcrypt (cost≥12) or argon2id, never plaintext/MD5/SHA1
- Account lockout: 5 failed attempts → temporary lockout (AC-7)
- TLS required: All auth endpoints require HTTPS (SC-8)
- Audit logging: Log all auth events with timestamps (AU-2)
Quick Example
// @nist ia-2 "Identification and authentication"
// @nist ia-5 "Authenticator management"
const jwt = require('jsonwebtoken');
const fs = require('fs');
// ❌ NEVER do this (shared secret, symmetric)
// const token = jwt.sign({ userId: 123 }, 'hardcoded_secret', { algorithm: 'HS256' });
// ✅ Use RS256 with private/public keypair
const privateKey = fs.readFileSync('./keys/private.pem');
const publicKey = fs.readFileSync('./keys/public.pem');
function generateAccessToken(userId) {
return jwt.sign(
{
sub: userId,
iss: 'auth.example.com',
aud: 'api.example.com'
},
privateKey,
{
algorithm: 'RS256',
expiresIn: '15m' // Short-lived
}
);
}
function verifyToken(token) {
try {
return jwt.verify(token, publicKey, {
algorithms: ['RS256'],
issuer: 'auth.example.com',
audience: 'api.example.com'
});
} catch (err) {
throw new Error('Invalid token');
}
}
Quick Links to Level 2
- OAuth2 Implementation
- JWT Best Practices
- Multi-Factor Authentication
- Session Management
- NIST 800-63B Compliance
Level 2: Implementation (<5,000 tokens, 30 minutes)
OAuth2 Implementation
Authorization Code Flow with PKCE (see resources/oauth2-flow-diagram.md)
// @nist ia-2 "User authentication"
// @nist sc-8 "Transmission confidentiality"
const crypto = require('crypto');
const axios = require('axios');
class OAuth2Client {
constructor(clientId, redirectUri, authServerUrl) {
this.clientId = clientId;
this.redirectUri = redirectUri;
this.authServerUrl = authServerUrl;
}
// Generate PKCE challenge
generatePKCE() {
const codeVerifier = crypto.randomBytes(32).toString('base64url');
const codeChallenge = crypto
.createHash('sha256')
.update(codeVerifier)
.digest('base64url');
return { codeVerifier, codeChallenge };
}
// Step 1: Generate authorization URL
getAuthorizationUrl(scope = 'openid profile email') {
const { codeVerifier, codeChallenge } = this.generatePKCE();
const state = crypto.randomBytes(16).toString('hex');
// Store codeVerifier and state in session/storage
this.sessionStorage = { codeVerifier, state };
const params = new URLSearchParams({
response_type: 'code',
client_id: this.clientId,
redirect_uri: this.redirectUri,
scope: scope,
state: state,
code_challenge: codeChallenge,
code_challenge_method: 'S256'
});
return `${this.authServerUrl}/authorize?${params.toString()}`;
}
// Step 2: Exchange authorization code for tokens
async exchangeCode(code, receivedState) {
// Validate state parameter (CSRF protection)
if (receivedState !== this.sessionStorage.state) {
throw new Error('Invalid state parameter');
}
const response = await axios.post(`${this.authServerUrl}/token`, {
grant_type: 'authorization_code',
code: code,
redirect_uri: this.redirectUri,
client_id: this.clientId,
code_verifier: this.sessionStorage.codeVerifier
});
return response.data; // { access_token, refresh_token, id_token }
}
// Refresh access token
async refreshAccessToken(refreshToken) {
const response = await axios.po
Установить authentication-security в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл authentication-security?
Authentication security standards covering OAuth2 flows (authorization code, PKCE), JWT best practices (RS256, expiration), MFA (TOTP, WebAuthn), session management, and NIST 800-63B compliance for production systems
Как установить скилл authentication-security?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл authentication-security запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic