本文へ移動
cccskills
無料GitHub で公開

auth-ops

Authentication and authorization patterns - JWT, OAuth2, sessions, RBAC, ABAC, passkeys, and MFA. Use for: authentication, authorization, jwt, oauth, oauth2, session, login, rbac, abac, passkey, mfa, totp, api key, token, auth, cookie, csrf, cors credentials, bearer token, refresh token, oidc.

インストール方法を見る

含まれるファイル(7)

  • SKILL.md14.5 KB
  • assets/.gitkeep0 B
  • references/authorization.md27.4 KB
  • references/implementation.md32.6 KB
  • references/jwt-sessions.md20.5 KB
  • references/oauth2-oidc.md31.4 KB
  • scripts/.gitkeep0 B

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Auth Operations

Comprehensive authentication and authorization patterns for secure application development across languages and frameworks.

Authentication Method Decision Tree

Use this tree to select the right authentication strategy for your use case.

What are you building?
│
├─ Traditional web application (server-rendered)?
│  └─ Session-based authentication
│     ├─ Server stores session data (Redis/DB)
│     ├─ Session ID in httpOnly cookie
│     └─ Best for: monoliths, SSR apps, admin panels
│
├─ API consumed by multiple clients?
│  └─ JWT (JSON Web Tokens)
│     ├─ Stateless, self-contained tokens
│     ├─ Access token (short-lived) + refresh token (long-lived)
│     └─ Best for: microservices, mobile apps, SPAs via BFF
│
├─ Service-to-service communication?
│  └─ API keys or Client Credentials (OAuth2)
│     ├─ API keys: simple, scoped, rotatable
│     ├─ Client Credentials: OAuth2 standard, token-based
│     └─ Best for: internal services, third-party integrations
│
├─ Third-party login (Google, GitHub, etc.)?
│  └─ OAuth2 / OpenID Connect
│     ├─ Authorization Code + PKCE for web/mobile
│     ├─ Delegate identity to trusted providers
│     └─ Best for: consumer apps, social login
│
└─ Passwordless authentication?
   └─ Passkeys (WebAuthn) or Magic Links
      ├─ Passkeys: phishing-resistant, biometric/hardware
      ├─ Magic links: email-based, time-limited
      └─ Best for: high-security, modern UX

JWT Quick Reference

Structure

Header.Payload.Signature

Header:  { "alg": "RS256", "typ": "JWT" }
Payload: { "iss": "auth.example.com", "sub": "user_123", ... }
Signature: RSASHA256(base64(header) + "." + base64(payload), privateKey)

Common Claims

ClaimNamePurposeExample
issIssuerWho issued the token"auth.example.com"
subSubjectWho the token represents"user_123"
expExpirationWhen the token expires1700000000 (Unix timestamp)
iatIssued AtWhen the token was created1699999100
audAudienceIntended recipient(s)"api.example.com"
jtiJWT IDUnique token identifier"a1b2c3d4" (for revocation)
nbfNot BeforeToken not valid before this time1699999100

Signing Algorithms

AlgorithmTypeKeyUse When
RS256Asymmetric (RSA)Public/private key pairDistributed systems, multiple verifiers
ES256Asymmetric (ECDSA)Public/private key pairSame as RS256, smaller keys/signatures
HS256Symmetric (HMAC)Shared secretSingle service, simple setups

Rule of thumb: Use asymmetric (RS256/ES256) when the token issuer and verifier are different services. Use HS256 only when a single service both creates and verifies tokens.

Access + Refresh Token Pattern

┌──────────┐                    ┌──────────┐
│  Client   │─── login ────────>│  Auth    │
│           │<── access (15m) ──│  Server  │
│           │<── refresh (7d) ──│          │
│           │                   └──────────┘
│           │─── API call ─────>┌──────────┐
│           │    (access token) │ Resource │
│           │<── response ──────│  Server  │
│           │                   └──────────┘
│           │─── access expired │          │
│           │─── refresh ──────>│  Auth    │
│           │<── new access ────│  Server  │
│           │<── new refresh ───│  (rotate)│
└──────────┘                    └──────────┘
  • Access token: Short-lived (5-15 minutes), used for API calls
  • Refresh token: Long-lived (7-30 days), used to get new access tokens
  • Rotation: Issue a new refresh token with each use, invalidate the old one
  • Family detection: Track refresh token lineage; if a revoked token is reused, invalidate the entire family

OAuth2 Flow Decision Tree

What type of client?
│
├─ Web app with backend (Next.js, Rails, Django)?
│  └─ Authorization Code + PKCE
│     ├─ Redirect user to authorization server
│     ├─ Receive code at callback URL
│     ├─ Exchange code for tokens server-side
│     └─ PKCE prevents code interception attacks
│
├─ SPA (React, Vue) without backend?
│  └─ Authorization Code + PKCE (via BFF)
│     ├─ Use a Backend-for-Frontend to handle tokens
│     ├─ Never store tokens in browser-accessible storage
│     └─ BFF proxies API calls with token attached
│
├─ Mobile app (iOS, Android)?
│  └─ Authorization Code + PKCE
│     ├─ Use custom URI scheme or universal links for redirect
│     ├─ PKCE is mandatory (public client)
│     └─ Store tokens in secure enclave/keystore
│
├─ Server-to-server (no user)?
│  └─ Client Credentials
│     ├─ Authenticate with client_id + client_secret
│     ├─ No user context, service-level access
│     └─ Token cached until expiry
│
├─ CLI tool or smart TV?
│  └─ Device Code
│     ├─ Display code and URL to user
│     ├─ User authenticates on another device
│     ├─ CLI/TV polls for completion
│     └─ Good UX for input-constrained devices
│
└─ Microservice acting on behalf of a user?
   └─ Token Exchange (RFC 8693)
      ├─ Exchange user's token for a scoped downstream token
      ├─ Maintains user context across services
      └─ Use `act` claim for delegation chain

Authorization Model Decision Tree

How complex are your access control needs?
│
├─ Simple: just "can user X do action Y"?
│  └─ Permission-based (direct)
│     ├─ user_permissions table
│     ├─ Simple to implement, hard to scale
│     └─ Good for: small apps, prototypes
│
├─ Users grouped into roles with fixed permissions?
│  └─ RBAC (Role-Based Access Control)
│     ├─ Roles: admin, editor, viewer
│     ├─ Each role has a set of permissions
│     ├─ Users assigned one or more roles
│     └─ Good for: most apps, admin panels, team tools
│
├─ Decisions depend on attributes (time, location, resource owner)?
│  └─ ABAC (Attribute-Based Access Control)
│     ├─ Policies evaluate subject + resource + environment attributes
│     ├─ "Allow if user.department == resource.department AND time < 17:00"
│     ├─ Flexible but complex
│     └─ Good for: enterprise, compliance-heavy, context-dependent access
│
└─ Access based on relationships (owner, parent, shared with)?
   └─ ReBAC (Relationship-Based Access Control)
      ├─ Google Zanzibar model
      ├─ Tuples: user:alice#viewer@document:report
      ├─ Supports inheritance: folder viewer → document viewer
      ├─ Tools: OpenFGA, SpiceDB, Ory Keto
      └─ Good for: file sharing, nested resources, social features

Session Management Quick Reference

Cookie Security Settings

SettingValuePurpose
SameSiteStrictCookie sent only for same-site requests (best CSRF protection)
SameSiteLaxCookie sent for top-level navigations (good default)
SameSiteNoneCookie sent for cross-site requests (requires Secure)
SecuretrueCookie only sent over HTTPS
HttpOnlytrueCookie not accessible via JavaScript (prevents XSS theft)
__Host- prefixN/ARequires Secure, no Domain, Path=/ (strictest)
__Secure- prefixN/ARequires Secure flag
Max-AgesecondsCookie lifetime (prefer over Expires)
Path/Scope cookie to path (usually /)

Recommended Cookie Configuration

Set-Cookie: __Host-session=abc123;
  Secure;
  HttpOnly;
  SameSite=Lax;
  Max-Age=86400;
  Path=/

Session Expiry Strategies

StrategyTypical ValueNotes
Idle timeout15-30 minutesReset on each request
Absolute timeout8-24 hoursForce re-authentication
Sliding window30 min idle, 8h maxBest balance
Remember me30 daysExtended session, reduced privileges

Password Handling Quick Reference

Hashing Algorithms

AlgorithmVerdictNotes
argon2idBESTMemory-hard, resists GPU attacks, recommended by OWASP
bcryptGOODBattle-tested, cost factor 12+, 72-byte input limit
scryptGOODMemory-hard, less common library support
PBKDF2ACCEPTABLEFIPS compliant, use 600k+ iterations with SHA-256
SHA-256/512BADToo fast, no salt built-in, easily brute-forced
MD5NEVERBroken, rainbow tables widely available

Password Rules (NIST 800-63B)

RuleGuidance
Minimum length8 characters (12+ recommended)
Maximum lengthAt least 64 characters
Complexity rulesDo NOT require special chars/uppercase/numbers
Breached password checkCheck against known breached passwords (HaveIBeenPwned API)
Password hintsDo NOT allow
Forced rotationDo NOT force periodic changes (only on breach)
Paste into password fieldALLOW (supports password managers)

Rate Limiting Login Attempts

AttemptResponse
1-5Normal login
6-10CAPTCHA required
11-20Progressive delays (2s, 4s, 8s...)
20+Temporary account lockout (15-30 min)

Important: Use consistent response times for both success and failure to prevent timing-based username enumeration.

MFA Quick Reference

Methods Ranked by Security

MethodSecurityUXNotes
WebAuthn/PasskeysHighestGoodPhishing-resistant, hardware-backed
TOTP (Authenticator)HighMediumApp-based (Google/Microsoft Authenticator)
Push notificationsHighGoodRequires mobile app
Email OTPMediumMediumDepends on email security
SMS OTPLowEasySIM swap vulnerable, use as fallback only

TOTP Implementation Checklist

  • Generate 160-bit secret (base32 encoded)
  • Build otpauth:// URI with issuer and account
  • Display QR code for authenticator scanning
  • Require verification of first code before enabling
  • Accept current window +/- 1 (30-second steps)
  • Generate 8-10 single-use backup codes
  • Hash backup codes before storing
  • Allow recovery via verified identity

Passkey/WebAuthn Checklist

  • Generate cryptographic challenge on server
  • Set relying party ID (your domain)
  • Store credential public key and ID
  • Verify signature on authentication
  • Support multiple credentials per user
  • Handle platform vs cross-platform authenticators
  • Provide fallback auth method

Common Gotchas

GotchaWhy It's DangerousFix
JWT stored in localStorageXSS can steal tokens, no expiry enforcement by browserUse httpOnly cookies or BFF pattern
Missing PKCE in OAuth2Authorization code interception attacks possibleAlways use PKCE, even for confidential clients
Role explosion in RBACHundreds of roles become unmanageableMove to ABAC or ReBAC for complex scenarios
String comparison for tokensTiming attacks reveal token value character by characterUse constant-time comparison (crypto.timingSafeEqual)
No token revocation strategyCannot invalidate compromised JWTs before expiryShort expiry + refresh tokens, or maintain a blocklist
CORS with credentials: trueAccess-Control-Allow-Origin: * does not work with credentialsSpecify exact origin, set Access-Control-Allow-Credentials: true
SameSite=None without SecureBrowser silently rejects the cookieAlways pair SameSite=None with Secure flag
Refresh token reuse without detectionStolen refresh tokens grant indefinite accessRotate refresh tokens, detect reuse (token families)
Using OAuth2 Implicit grantTokens exposed in URL fragment, no refresh tokensUse Authorization Code + PKCE instead (Implicit is deprecated)
Password in URL or logsURLs are logged by proxies, browsers, and serversAlways send credentials in request body or headers
Missing CSRF protection with cookiesCookie-based auth is vulnerable to cross-site request forgeryUse SameSite cookies + CSRF tokens for state-changing ops
Long-lived access tokens (hours/days)Large attack window if token is compromisedKeep access tokens to 5-15 minutes, use refresh tokens
Storing API keys in plaintextDatabase breach exposes all keysHash stored keys (SHA-256 of key), store prefix for lookup
Not validating JWT aud claimToken meant for Service A accepted by Service BAlways validate aud matches your service identifier
Session fixationAttacker sets session ID before login, then hijacks itRegenerate session ID after authentication
Hardcoded secrets in codeSecrets leak via source controlUse environment variables or secret managers (Vault, AWS SSM)

Reference Files

FileContentsLines
references/jwt-sessions.mdJWT structure, signing, sessions, cookies, CSRF, storage~650
references/oauth2-oidc.mdOAuth2 flows, OIDC, provider integration, social login~700
references/authorization.mdRBAC, ABAC, ReBAC, RLS, multi-tenant, audit logging~600
references/implementation.mdPassword hashing, MFA, rate limiting, API keys, reset flows~550

See Also

  • security-ops - Broader security patterns: OWASP, headers, input validation, encryption
  • api-design-ops - API design including authentication endpoints, rate limiting
  • postgres-ops - Row-level security (RLS) policies for database authorization

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Primary accessibility skill for VS Code. REQUIRED for new feature and contribution work, and also applies to updates of existing UI. Covers accessibility help dialogs, accessible views, verbosity settings, signals, ARIA announcements, keyboard navigation, and ARIA labels/roles.

日本語の概要は準備中です。原文の説明を表示しています。

jcasnellie69/homelab-config22026年10月12日 更新

Use this skill when the user explicitly asks to map, document, or onboard into an existing codebase. Trigger for prompts like "map this codebase", "document this architecture", "onboard me to this repo", or "create codebase docs". Do not trigger for routine feature implementation, bug fixes, or narrow code edits unless the user asks for repository-level discovery.

日本語の概要は準備中です。原文の説明を表示しています。

jcasnellie69/homelab-config22026年10月12日 更新

Act on user feedback attached to the current session. Use when the user submits feedback on the session's changes via the Submit Feedback button.

日本語の概要は準備中です。原文の説明を表示しています。

jcasnellie69/homelab-config22026年10月12日 更新

Add educational comments to the file specified, or prompt asking for file to comment if one is not provided.

日本語の概要は準備中です。原文の説明を表示しています。

jcasnellie69/homelab-config22026年10月12日 更新

Use when adding, modifying, or reviewing VS Code configuration policies. Covers the full policy lifecycle from registration to export to platform-specific artifacts. Run on ANY change that adds a `policy:` field to a configuration property.

日本語の概要は準備中です。原文の説明を表示しています。

jcasnellie69/homelab-config22026年10月12日 更新

Patterns and techniques for adding governance, safety, and trust controls to AI agent systems. Use this skill when: - Building AI agents that call external tools (APIs, databases, file systems) - Implementing policy-based access controls for agent tool usage - Adding semantic intent classification to detect dangerous prompts - Creating trust scoring systems for multi-agent workflows - Building audit trails for agent actions and decisions - Enforcing rate limits, content filters, or tool restrictions on agents - Working with any agent framework (PydanticAI, CrewAI, OpenAI Agents, LangChain, AutoGen)

日本語の概要は準備中です。原文の説明を表示しています。

jcasnellie69/homelab-config22026年10月12日 更新

jcasnellie69 のスキルをすべて見る

このスキルの問題を報告する