Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

authentication-security

БесплатноЗапускает вложенные скриптыНе проверен

Authentication security standards covering OAuth2 flows (authorization code, PKCE), JWT best practices (RS256, expiration), MFA (TOTP, WebAuthn), session…

williamzujkowskiот williamzujkowski★ 23 звезды на GitHub20 установок в других каталогах

Об этом скилле

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

  1. Multi-Factor Always: Require MFA for sensitive operations (TOTP, WebAuthn, hardware keys)
  2. Secure Tokens: Use RS256 for JWT, never HS256 with shared secrets in distributed systems
  3. Short-Lived Tokens: Access tokens <15 min, refresh tokens with rotation
  4. OAuth2 with PKCE: Always use PKCE for SPAs and mobile apps
  5. 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


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
Полный SKILL.md на GitHub

Установить authentication-security в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

resources/README.mdresources/nist-800-63b-checklist.mdresources/oauth2-flow-diagram.mdscripts/README.mdscripts/generate-jwt-keys.shtemplates/README.mdtemplates/jwt-validator.jstemplates/jwt-validator.pytemplates/oauth2-client.js

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 запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить authentication-security с