[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M792BDSMCF0MZGGFC8Y2GQ16":3,"skill-same:01M792BDSMCF0MZGGFC8Y2GQ16":61},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":14,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":32,"ownerDescription":33,"updatedAt":34,"install":35,"resources":48},"01M792BDSMCF0MZGGFC8Y2GQ16","authentication",null,"Implement OAuth 2.0, OIDC, sessions, token lifetimes, MFA and password storage without rolling your own crypto. Use when implementing auth flows, OAuth, JWT, MFA, or sessions.","poorvith-mp\u002Fskills-developer","poorvith-mp","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F277478855?v=4","01M78Z5K0YH1Z3PX815PGQ96ND","Poorvith M P","01M792ACSFXT45RJ69SSGKTVJN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-developer\u002Fblob\u002Fmain\u002Fskills\u002Fauthentication\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: authentication\nlast_reviewed: 2026-09-06\ngroup: Security\ndescription: >-\n  Implement OAuth 2.0, OIDC, sessions, token lifetimes, MFA and password storage without rolling\n  your own crypto. Use when implementing auth flows, OAuth, JWT, MFA, or sessions.\n---\n\n# authentication\n\n## Core Philosophy\nAuthentication is security engineering, not a weekend feature to hack together. Rolling custom cryptographic functions or hashing passwords with naive SHA-256 is an immediate vulnerability. Production authentication requires industry-standard protocols (OAuth 2.0, OIDC, WebAuthn), cryptographically secure password hashing (Argon2id), stateful session management or rotated short-lived JWTs, and multi-factor authentication (MFA) with replay attack protection.\n\n---\n\n## 4-Step Authentication Architecture Framework\n\n### Step 1: Password Storage & Cryptographic Hashing\n1. **The Argon2id Standard**:\n   - Never use MD5, SHA-1, SHA-256, or plain bcrypt for new systems. Enforce **Argon2id** (RFC 9106):\n     - Memory Cost ($m$): minimum 64MB (65536 KiB).\n     - Time Cost ($t$): minimum 3 iterations.\n     - Parallelism ($p$): 4 threads.\n     - Salt: 16 cryptographically secure random bytes generated per password (`crypto.randomBytes(16)`).\n2. **Password Policies**:\n   - Enforce minimum length (>= 12 characters). Prohibit arbitrary character restrictions that prevent password managers from generating high-entropy strings.\n   - Screen passwords against haveibeenpwned k-anonymity hash API during registration.\n\n### Step 2: Session Management & Token Lifecycles\n1. **Cookie-Based Sessions vs Stateless JWTs**:\n   - *Stateful Sessions (Preferred for Web Apps)*: Store session ID in an `HttpOnly; Secure; SameSite=Lax` cookie. Back with Redis\u002FPostgreSQL for instant revocation.\n   - *Stateless JWTs (API \u002F Mobile)*:\n     - Access Token TTL: Strictly 10 to 15 minutes. Sign with asymmetric keys (RS256 or Ed25519), never symmetric HS256 with weak secrets.\n     - Refresh Token TTL: 14 to 30 days. Store hashed in database.\n2. **Refresh Token Rotation & Reuse Detection**:\n   - Issue a single-use refresh token. When exchanged, issue a new access token and invalidate the old refresh token.\n   - If an invalidated refresh token is ever presented, invalidate the entire token family immediately—this indicates token theft.\n\n### Step 3: OAuth 2.0 & OpenID Connect (OIDC) with PKCE\n1. **Authorization Code Flow with PKCE**:\n   - Proof Key for Code Exchange (PKCE, RFC 7636) is mandatory for all clients (SPAs, mobile apps, and server-side apps).\n   - Generate high-entropy `code_verifier` and compute `code_challenge = BASE64URL-ENCODE(SHA256(code_verifier))`.\n   - Validate cryptographically random `state` parameter on callback to prevent Cross-Site Request Forgery (CSRF).\n\n### Step 4: Multi-Factor Authentication (MFA) & Passkeys\n1. **TOTP (RFC 6238)**:\n   - Secret key minimum 160 bits (32 base32 characters).\n   - Time step: 30 seconds; clock skew allowance: $\\pm 1$ step.\n   - Generate 8 single-use emergency backup recovery codes, hashed with Argon2id.\n2. **WebAuthn \u002F Passkeys (FIDO2)**:\n   - Implement biometric passkeys as primary or secondary auth, binding authentication to the physical hardware authenticator and origin domain.\n\n---\n\n## Deliverable Format: Authentication Architecture Spec (`AUTH-SPEC.md`)\n\n```markdown\n# Authentication System Specification: [Application Name]\n\n## 1. Credentials & Cryptography Baseline\n- **Password Hash**: Argon2id ($m=65536, t=3, p=4$, salt=16 bytes)\n- **Session Mechanism**: Stateful HttpOnly Cookies \u002F Ephemeral JWT\n- **JWT Signing Algorithm**: RS256 (Public\u002FPrivate keypair via KMS)\n- **Token Lifetimes**: Access Token = 15 mins | Refresh Token = 14 days\n\n## 2. Token Exchange & Rotation Sequence\n```mermaid\nsequenceDiagram\n    Client->>AuthServer: POST \u002Fauth\u002Frefresh (RefreshToken_v1)\n    alt Valid Token\n        AuthServer->>AuthServer: Invalidate RefreshToken_v1\n        AuthServer->>AuthServer: Generate RefreshToken_v2\n        AuthServer-->>Client: 200 OK (AccessToken_v2, RefreshToken_v2)\n    else Replayed Token Detected\n        AuthServer->>AuthServer: REVOKE ALL TOKENS FOR USER\n        AuthServer-->>Client: 401 Unauthorized (Breach Flagged)\n    end\n```\n\n## 3. Cookie Security Attributes\n```http\nSet-Cookie: __Host-session_id=s%3A8f...; Path=\u002F; Secure; HttpOnly; SameSite=Lax; Max-Age=1209600\n```\n```\n\n---\n\n## Worked Example: Zero-Downtime Session Invalidation\n\n- **Challenge**: User reported stolen laptop; needed immediate revocation across all active sessions while keeping other team members logged in.\n- **Implementation**: Redis-backed session store keyed by `user_sessions:{user_id}:{session_id}`. Revoked all keys matching prefix on password reset.\n- **Result**: Immediate revocation of active sessions within 5ms globally; zero orphaned tokens.\n\n---\n\n## Verification Checklist\n\n- [ ] Passwords hashed using Argon2id with recommended memory and time parameters.\n- [ ] Cookies configure `HttpOnly`, `Secure`, and `SameSite` flags.\n- [ ] Refresh tokens use rotation and detect reuse to trigger family revocation.\n- [ ] OAuth 2.0 flows implement PKCE and validate the `state` parameter against CSRF.\n- [ ] Rate-limiting is enforced on all login, reset, and token endpoints (max 5 attempts\u002Fmin).\n\n---\n\n## Anti-Patterns\n\n- **Rolling Your Own Crypto**: Writing custom encryption or hashing algorithms.\n- **Storing JWTs in LocalStorage**: Exposing tokens to XSS script injection attacks.\n- **Permanent Access Tokens**: Issuing JWTs with 30-day expiration and zero revocation mechanism.\n","# authentication\n\n## Core Philosophy\nAuthentication is security engineering, not a weekend feature to hack together. Rolling custom cryptographic functions or hashing passwords with naive SHA-256 is an immediate vulnerability. Production authentication requires industry-standard protocols (OAuth 2.0, OIDC, WebAuthn), cryptographically secure password hashing (Argon2id), stateful session management or rotated short-lived JWTs, and multi-factor authentication (MFA) with replay attack protection.\n\n---\n\n## 4-Step Authentication Architecture Framework\n\n### Step 1: Password Storage & Cryptographic Hashing\n1. **The Argon2id Standard**:\n   - Never use MD5, SHA-1, SHA-256, or plain bcrypt for new systems. Enforce **Argon2id** (RFC 9106):\n     - Memory Cost ($m$): minimum 64MB (65536 KiB).\n     - Time Cost ($t$): minimum 3 iterations.\n     - Parallelism ($p$): 4 threads.\n     - Salt: 16 cryptographically secure random bytes generated per password (`crypto.randomBytes(16)`).\n2. **Password Policies**:\n   - Enforce minimum length (>= 12 characters). Prohibit arbitrary character restrictions that prevent password managers from generating high-entropy strings.\n   - Screen passwords against haveibeenpwned k-anonymity hash API during registration.\n\n### Step 2: Session Management & Token Lifecycles\n1. **Cookie-Based Sessions vs Stateless JWTs**:\n   - *Stateful Sessions (Preferred for Web Apps)*: Store session ID in an `HttpOnly; Secure; SameSite=Lax` cookie. Back with Redis\u002FPostgreSQL for instant revocation.\n   - *Stateless JWTs (API \u002F Mobile)*:\n     - Access Token TTL: Strictly 10 to 15 minutes. Sign with asymmetric keys (RS256 or Ed25519), never symmetric HS256 with weak secrets.\n     - Refresh Token TTL: 14 to 30 days. Store hashed in database.\n2. **Refresh Token Rotation & Reuse Detection**:\n   - Issue a single-use refresh token. When exchanged, issue a new access token and invalidate the old refresh token.\n   - If an invalidated refresh token is ever presented, invalidate the entire token family immediately—this indicates token theft.\n\n### Step 3: OAuth 2.0 & OpenID Connect (OIDC) with PKCE\n1. **Authorization Code Flow with PKCE**:\n   - Proof Key for Code Exchange (PKCE, RFC 7636) is mandatory for all clients (SPAs, mobile apps, and server-side apps).\n   - Generate high-entropy `code_verifier` and compute `code_challenge = BASE64URL-ENCODE(SHA256(code_verifier))`.\n   - Validate cryptographically random `state` parameter on callback to prevent Cross-Site Request Forgery (CSRF).\n\n### Step 4: Multi-Factor Authentication (MFA) & Passkeys\n1. **TOTP (RFC 6238)**:\n   - Secret key minimum 160 bits (32 base32 characters).\n   - Time step: 30 seconds; clock skew allowance: $\\pm 1$ step.\n   - Generate 8 single-use emergency backup recovery codes, hashed with Argon2id.\n2. **WebAuthn \u002F Passkeys (FIDO2)**:\n   - Implement biometric passkeys as primary or secondary auth, binding authentication to the physical hardware authenticator and origin domain.\n\n---\n\n## Deliverable Format: Authentication Architecture Spec (`AUTH-SPEC.md`)\n\n```markdown\n# Authentication System Specification: [Application Name]\n\n## 1. Credentials & Cryptography Baseline\n- **Password Hash**: Argon2id ($m=65536, t=3, p=4$, salt=16 bytes)\n- **Session Mechanism**: Stateful HttpOnly Cookies \u002F Ephemeral JWT\n- **JWT Signing Algorithm**: RS256 (Public\u002FPrivate keypair via KMS)\n- **Token Lifetimes**: Access Token = 15 mins | Refresh Token = 14 days\n\n## 2. Token Exchange & Rotation Sequence\n```mermaid\nsequenceDiagram\n    Client->>AuthServer: POST \u002Fauth\u002Frefresh (RefreshToken_v1)\n    alt Valid Token\n        AuthServer->>AuthServer: Invalidate RefreshToken_v1\n        AuthServer->>AuthServer: Generate RefreshToken_v2\n        AuthServer-->>Client: 200 OK (AccessToken_v2, RefreshToken_v2)\n    else Replayed Token Detected\n        AuthServer->>AuthServer: REVOKE ALL TOKENS FOR USER\n        AuthServer-->>Client: 401 Unauthorized (Breach Flagged)\n    end\n```\n\n## 3. Cookie Security Attributes\n```http\nSet-Cookie: __Host-session_id=s%3A8f...; Path=\u002F; Secure; HttpOnly; SameSite=Lax; Max-Age=1209600\n```\n```\n\n---\n\n## Worked Example: Zero-Downtime Session Invalidation\n\n- **Challenge**: User reported stolen laptop; needed immediate revocation across all active sessions while keeping other team members logged in.\n- **Implementation**: Redis-backed session store keyed by `user_sessions:{user_id}:{session_id}`. Revoked all keys matching prefix on password reset.\n- **Result**: Immediate revocation of active sessions within 5ms globally; zero orphaned tokens.\n\n---\n\n## Verification Checklist\n\n- [ ] Passwords hashed using Argon2id with recommended memory and time parameters.\n- [ ] Cookies configure `HttpOnly`, `Secure`, and `SameSite` flags.\n- [ ] Refresh tokens use rotation and detect reuse to trigger family revocation.\n- [ ] OAuth 2.0 flows implement PKCE and validate the `state` parameter against CSRF.\n- [ ] Rate-limiting is enforced on all login, reset, and token endpoints (max 5 attempts\u002Fmin).\n\n---\n\n## Anti-Patterns\n\n- **Rolling Your Own Crypto**: Writing custom encryption or hashing algorithms.\n- **Storing JWTs in LocalStorage**: Exposing tokens to XSS script injection attacks.\n- **Permanent Access Tokens**: Issuing JWTs with 30-day expiration and zero revocation mechanism.\n",{"name":5,"group":24,"description":7,"last_reviewed":25},"Security",1788652800000,"main","f6a053c46d4bf0f779ea766c929b6f6f92c51765","skills\u002Fauthentication","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-developer","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskillary","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp","poorvithmp.com","Shipping tools for problems people notice too late.","2026-10-02 21:32:22",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":47},[37,40,43],{"tool":38,"command":39},"npx","npx skills add poorvith-mp\u002Fskills-developer --skill authentication",{"tool":41,"command":42},"bunx","bunx skills add poorvith-mp\u002Fskills-developer --skill authentication",{"tool":44,"command":45},"pnpm","pnpm dlx skills add poorvith-mp\u002Fskills-developer --skill authentication","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-developer\u002Fblob\u002Fmain\u002Fskills\u002Fauthentication\u002FSKILL.md",true,[49,55],{"path":50,"resourceType":51,"resourceTypeDesc":52,"sizeBytes":53,"sourceHtmlUrl":54},"authentication.skill","OTHER","其他",3448,"https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-developer\u002Fblob\u002Fmain\u002Fskills\u002Fauthentication\u002Fauthentication.skill",{"path":56,"resourceType":57,"resourceTypeDesc":58,"sizeBytes":59,"sourceHtmlUrl":60},"evals\u002Frouting.yaml","REFERENCE","参考文档",875,"https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-developer\u002Fblob\u002Fmain\u002Fskills\u002Fauthentication\u002Fevals\u002Frouting.yaml",[62,69,76,83,90,97],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M792Q79X14YD94WXEEJY9GCW","workflow-optimizer","Moved to workflow-mapping in skills-agents. Removed in v4.1.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-developer\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow-optimizer\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M792Q387DNC91VKEVM07SJM3","webhooks","Build webhook receivers with signature verification, idempotency, retries and dead letter queues. Use when implementing, verifying, or signing incoming\u002Foutgoing webhooks.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-developer\u002Fblob\u002Fmain\u002Fskills\u002Fwebhooks\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M792PZW0SM71X7V9709ZWHCR","webhook-handler-builder","Moved to webhooks in skills-developer. Removed in v4.1.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-developer\u002Fblob\u002Fmain\u002Fskills\u002Fwebhook-handler-builder\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M792PW7XPB7J9S0QSS52JXZV","voice-ai-integration-engineer","Moved to speech-pipelines in skills-developer. Removed in v4.1.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-developer\u002Fblob\u002Fmain\u002Fskills\u002Fvoice-ai-integration-engineer\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M792PRZ5GSAQ1P2999V9XAJ5","typescript-migrator","Moved to port-code in skills-developer. Removed in v4.1.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-developer\u002Fblob\u002Fmain\u002Fskills\u002Ftypescript-migrator\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":19},"01M792PQDARKP00V8Z3GYD4QZP","trigger-dev","Moved to trigger-dev in skills-agents. Removed in v4.1.","https:\u002F\u002Fgithub.com\u002Fpoorvith-mp\u002Fskills-developer\u002Fblob\u002Fmain\u002Fskills\u002Ftrigger-dev\u002FSKILL.md",[],[]]