[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79FH0VKVT44FK923K520ZQA":3,"skill-same:01M79FH0VKVT44FK923K520ZQA":51},{"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":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M79FH0VKVT44FK923K520ZQA","oauth2-oidc-security-flows",null,"Implement enterprise OAuth 2.1 and OpenID Connect (OIDC) authorization code flow with Proof Key for Code Exchange (PKCE), state and nonce verification, refresh token rotation, token revocation, and centralized IdP federation (Keycloak, Auth0, Okta). Trigger when building secure authentication, single sign-on (SSO), or third-party delegated authorization.","hamzabellouch\u002Fagent-skills","hamzabellouch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F237856042?v=4","01M79BRYW7XAMK3YDWQEMTWGWS","Hamza Bellouch","01M79BRYWXQV3JK2TGVTX8GN2A",8,"MIT","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Foauth2-oidc-security-flows\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: oauth2-oidc-security-flows\nmetadata:\n  category: Identity Auth and Access Management\ndescription: Implement enterprise OAuth 2.1 and OpenID Connect (OIDC) authorization code flow with Proof Key for Code Exchange (PKCE), state and nonce verification, refresh token rotation, token revocation, and centralized IdP federation (Keycloak, Auth0, Okta). Trigger when building secure authentication, single sign-on (SSO), or third-party delegated authorization.\ncompatibility: OAuth 2.1 RFC standards, OIDC Core 1.0, RFC 7636 (PKCE), RFC 7009\n---\n\n# OAuth 2.1 & OpenID Connect Security Flows Skill Guide\n\nThis skill governs standard, hardened implementation of OAuth 2.1 and OIDC authentication and authorization patterns for modern SPAs, mobile apps, and backend APIs.\n\n---\n\n## 1. Authorization Code Flow with PKCE (RFC 7636)\n\nOAuth 2.1 mandates **PKCE (Proof Key for Code Exchange)** for all clients, deprecating the legacy Implicit Grant and Resource Owner Password Credentials (ROPC) grant.\n\n```text\n+--------+                               +---------------+\n|        |--(A)- Generate code_verifier -|               |\n|        |       and code_challenge      |               |\n|        |                               |               |\n|        |--(B)- GET \u002Fauthorize -------->| Authorization |\n|        |       &code_challenge=SHA256  | Server (IdP)  |\n| Client |       &state=RANDOM_NONCE     | (Keycloak\u002F    |\n| (App)  |\u003C-(C)- 302 Redirect with code -|  Auth0\u002FOkta)  |\n|        |                               |               |\n|        |--(D)- POST \u002Ftoken ----------->|               |\n|        |       code + code_verifier    |               |\n|        |       &client_id              |               |\n|        |\u003C-(E)- Return Tokens ----------|               |\n|        |       (access, id, refresh)   |               |\n+--------+                               +---------------+\n```\n\n---\n\n## 2. Production Implementation Patterns\n\n### A. PKCE Generator & Validator (TypeScript \u002F Node.js)\n\n```typescript\nimport crypto from \"node:crypto\";\n\nexport interface PKCEPair {\n  codeVerifier: string;\n  codeChallenge: string;\n}\n\n\u002F**\n * Generates a cryptographically secure PKCE code verifier and SHA256 challenge.\n *\u002F\nexport function generatePKCE(): PKCEPair {\n  \u002F\u002F RFC 7636 Section 4.1: High-entropy cryptographic random string (43 to 128 characters)\n  const codeVerifier = crypto\n    .randomBytes(32)\n    .toString(\"base64url\");\n\n  const codeChallenge = crypto\n    .createHash(\"sha256\")\n    .update(codeVerifier)\n    .digest(\"base64url\");\n\n  return { codeVerifier, codeChallenge };\n}\n\n\u002F**\n * Validates code_verifier against code_challenge on the authorization server.\n *\u002F\nexport function verifyPKCE(verifier: string, challenge: string): boolean {\n  const computed = crypto\n    .createHash(\"sha256\")\n    .update(verifier)\n    .digest(\"base64url\");\n\n  return crypto.timingSafeEqual(\n    Buffer.from(computed),\n    Buffer.from(challenge)\n  );\n}\n```\n\n### B. OIDC Token Exchange & Validation Handler (Python)\n\n```python\nimport time\nimport httpx\nfrom jose import jwt, jwk\nfrom pydantic import BaseModel\n\n\nclass TokenResponse(BaseModel):\n    access_token: str\n    id_token: str\n    refresh_token: str\n    token_type: str\n    expires_in: int\n\n\nclass OIDCClient:\n    def __init__(self, idp_base_url: str, client_id: str, client_secret: str | None = None):\n        self.idp_base_url = idp_base_url.rstrip(\"\u002F\")\n        self.client_id = client_id\n        self.client_secret = client_secret\n        self._jwks_cache = None\n\n    async def get_jwks(self) -> dict:\n        if not self._jwks_cache:\n            async with httpx.AsyncClient() as client:\n                resp = await client.get(f\"{self.idp_base_url}\u002Fprotocol\u002Fopenid-connect\u002Fcerts\")\n                resp.raise_for_status()\n                self._jwks_cache = resp.json()\n        return self._jwks_cache\n\n    async def exchange_code(\n        self,\n        code: str,\n        code_verifier: str,\n        redirect_uri: str,\n    ) -> TokenResponse:\n        data = {\n            \"grant_type\": \"authorization_code\",\n            \"client_id\": self.client_id,\n            \"code\": code,\n            \"code_verifier\": code_verifier,\n            \"redirect_uri\": redirect_uri,\n        }\n        if self.client_secret:\n            data[\"client_secret\"] = self.client_secret\n\n        async with httpx.AsyncClient() as client:\n            resp = await client.post(\n                f\"{self.idp_base_url}\u002Fprotocol\u002Fopenid-connect\u002Ftoken\",\n                data=data,\n                headers={\"Content-Type\": \"application\u002Fx-www-form-urlencoded\"},\n            )\n            resp.raise_for_status()\n            return TokenResponse(**resp.json())\n\n    async def verify_id_token(self, id_token: str, expected_nonce: str) -> dict:\n        jwks = await self.get_jwks()\n        unverified_header = jwt.get_unverified_header(id_token)\n        kid = unverified_header[\"kid\"]\n\n        key = next((k for k in jwks[\"keys\"] if k[\"kid\"] == kid), None)\n        if not key:\n            raise ValueError(f\"Public key {kid} not found in IdP JWKS\")\n\n        claims = jwt.decode(\n            id_token,\n            key,\n            algorithms=[\"RS256\"],\n            audience=self.client_id,\n            issuer=f\"{self.idp_base_url}\",\n        )\n\n        if claims.get(\"nonce\") != expected_nonce:\n            raise ValueError(\"Nonce mismatch: potential replay attack\")\n\n        return claims\n```\n\n---\n\n## 3. Security Guidelines & Attack Mitigations\n\n1. **Always Enforce PKCE:** Never allow plain `code_challenge_method=plain`; strictly reject anything except `S256`.\n2. **State Parameter for CSRF:** Generate an unpredictable, encrypted or hashed `state` parameter stored in an HttpOnly session cookie, verified upon redirect.\n3. **Nonce for Replay Prevention:** Include a unique `nonce` in `\u002Fauthorize` requests and verify that the returned `id_token` contains an identical `nonce` claim.\n4. **Refresh Token Rotation (RTR):** Invalidate the old refresh token whenever a new one is issued. If a revoked refresh token is presented, revoke all descended tokens immediately (compromise detection).\n","# OAuth 2.1 & OpenID Connect Security Flows Skill Guide\n\nThis skill governs standard, hardened implementation of OAuth 2.1 and OIDC authentication and authorization patterns for modern SPAs, mobile apps, and backend APIs.\n\n---\n\n## 1. Authorization Code Flow with PKCE (RFC 7636)\n\nOAuth 2.1 mandates **PKCE (Proof Key for Code Exchange)** for all clients, deprecating the legacy Implicit Grant and Resource Owner Password Credentials (ROPC) grant.\n\n```text\n+--------+                               +---------------+\n|        |--(A)- Generate code_verifier -|               |\n|        |       and code_challenge      |               |\n|        |                               |               |\n|        |--(B)- GET \u002Fauthorize -------->| Authorization |\n|        |       &code_challenge=SHA256  | Server (IdP)  |\n| Client |       &state=RANDOM_NONCE     | (Keycloak\u002F    |\n| (App)  |\u003C-(C)- 302 Redirect with code -|  Auth0\u002FOkta)  |\n|        |                               |               |\n|        |--(D)- POST \u002Ftoken ----------->|               |\n|        |       code + code_verifier    |               |\n|        |       &client_id              |               |\n|        |\u003C-(E)- Return Tokens ----------|               |\n|        |       (access, id, refresh)   |               |\n+--------+                               +---------------+\n```\n\n---\n\n## 2. Production Implementation Patterns\n\n### A. PKCE Generator & Validator (TypeScript \u002F Node.js)\n\n```typescript\nimport crypto from \"node:crypto\";\n\nexport interface PKCEPair {\n  codeVerifier: string;\n  codeChallenge: string;\n}\n\n\u002F**\n * Generates a cryptographically secure PKCE code verifier and SHA256 challenge.\n *\u002F\nexport function generatePKCE(): PKCEPair {\n  \u002F\u002F RFC 7636 Section 4.1: High-entropy cryptographic random string (43 to 128 characters)\n  const codeVerifier = crypto\n    .randomBytes(32)\n    .toString(\"base64url\");\n\n  const codeChallenge = crypto\n    .createHash(\"sha256\")\n    .update(codeVerifier)\n    .digest(\"base64url\");\n\n  return { codeVerifier, codeChallenge };\n}\n\n\u002F**\n * Validates code_verifier against code_challenge on the authorization server.\n *\u002F\nexport function verifyPKCE(verifier: string, challenge: string): boolean {\n  const computed = crypto\n    .createHash(\"sha256\")\n    .update(verifier)\n    .digest(\"base64url\");\n\n  return crypto.timingSafeEqual(\n    Buffer.from(computed),\n    Buffer.from(challenge)\n  );\n}\n```\n\n### B. OIDC Token Exchange & Validation Handler (Python)\n\n```python\nimport time\nimport httpx\nfrom jose import jwt, jwk\nfrom pydantic import BaseModel\n\n\nclass TokenResponse(BaseModel):\n    access_token: str\n    id_token: str\n    refresh_token: str\n    token_type: str\n    expires_in: int\n\n\nclass OIDCClient:\n    def __init__(self, idp_base_url: str, client_id: str, client_secret: str | None = None):\n        self.idp_base_url = idp_base_url.rstrip(\"\u002F\")\n        self.client_id = client_id\n        self.client_secret = client_secret\n        self._jwks_cache = None\n\n    async def get_jwks(self) -> dict:\n        if not self._jwks_cache:\n            async with httpx.AsyncClient() as client:\n                resp = await client.get(f\"{self.idp_base_url}\u002Fprotocol\u002Fopenid-connect\u002Fcerts\")\n                resp.raise_for_status()\n                self._jwks_cache = resp.json()\n        return self._jwks_cache\n\n    async def exchange_code(\n        self,\n        code: str,\n        code_verifier: str,\n        redirect_uri: str,\n    ) -> TokenResponse:\n        data = {\n            \"grant_type\": \"authorization_code\",\n            \"client_id\": self.client_id,\n            \"code\": code,\n            \"code_verifier\": code_verifier,\n            \"redirect_uri\": redirect_uri,\n        }\n        if self.client_secret:\n            data[\"client_secret\"] = self.client_secret\n\n        async with httpx.AsyncClient() as client:\n            resp = await client.post(\n                f\"{self.idp_base_url}\u002Fprotocol\u002Fopenid-connect\u002Ftoken\",\n                data=data,\n                headers={\"Content-Type\": \"application\u002Fx-www-form-urlencoded\"},\n            )\n            resp.raise_for_status()\n            return TokenResponse(**resp.json())\n\n    async def verify_id_token(self, id_token: str, expected_nonce: str) -> dict:\n        jwks = await self.get_jwks()\n        unverified_header = jwt.get_unverified_header(id_token)\n        kid = unverified_header[\"kid\"]\n\n        key = next((k for k in jwks[\"keys\"] if k[\"kid\"] == kid), None)\n        if not key:\n            raise ValueError(f\"Public key {kid} not found in IdP JWKS\")\n\n        claims = jwt.decode(\n            id_token,\n            key,\n            algorithms=[\"RS256\"],\n            audience=self.client_id,\n            issuer=f\"{self.idp_base_url}\",\n        )\n\n        if claims.get(\"nonce\") != expected_nonce:\n            raise ValueError(\"Nonce mismatch: potential replay attack\")\n\n        return claims\n```\n\n---\n\n## 3. Security Guidelines & Attack Mitigations\n\n1. **Always Enforce PKCE:** Never allow plain `code_challenge_method=plain`; strictly reject anything except `S256`.\n2. **State Parameter for CSRF:** Generate an unpredictable, encrypted or hashed `state` parameter stored in an HttpOnly session cookie, verified upon redirect.\n3. **Nonce for Replay Prevention:** Include a unique `nonce` in `\u002Fauthorize` requests and verify that the returned `id_token` contains an identical `nonce` claim.\n4. **Refresh Token Rotation (RTR):** Invalidate the old refresh token whenever a new one is issued. If a revoked refresh token is presented, revoke all descended tokens immediately (compromise detection).\n",{"name":5,"metadata":24,"description":7,"compatibility":26},{"category":25},"Identity Auth and Access Management","OAuth 2.1 RFC standards, OIDC Core 1.0, RFC 7636 (PKCE), RFC 7009","main","e905af21e5f1e1c3ca605e9656c3a7930360a84e","Security\u002FIdentity_and_Access_Management_IAM\u002Foauth2-oidc-security-flows",1,"https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills","https:\u002F\u002Fhamzabellouch.github.io\u002F","https:\u002F\u002Fgithub.com\u002Fhamzabellouch","hamzabellouch.github.io","CEO & Founder of @tknoglobal | Researcher in Technology & Applied Sciences.","2026-10-17 03:20:19",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add hamzabellouch\u002Fagent-skills --skill oauth2-oidc-security-flows",{"tool":43,"command":44},"bunx","bunx skills add hamzabellouch\u002Fagent-skills --skill oauth2-oidc-security-flows",{"tool":46,"command":47},"pnpm","pnpm dlx skills add hamzabellouch\u002Fagent-skills --skill oauth2-oidc-security-flows","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Foauth2-oidc-security-flows\u002FSKILL.md",true,[],[52,59,66,73,80,87],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M79FHH2H815A9TAP6WNKH4Q8","security-audit","Comprehensive security guidance, source code audit, vulnerability assessment, and penetration test review for codebases, APIs, microservices, CLI tools, libraries, and LLM-backed applications. Triggers on requests to audit a codebase, conduct security reviews, find vulnerabilities or flaws, pen-test source code, or when the user asks in Arabic (فحص أمني، تدقيق الكود أمنياً، مراجعة الثغرات، فحص أمان المشروع). Supports Guidance mode (focused review) and Full Audit mode (deterministic 6-phase harness).","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FSecurity_Audit_and_Code_Review\u002Fsecurity-audit\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M79FHBGXVBY6VQ1X7ETAZMF1","malware-analysis-reversing","Production malware analysis workflows, reverse engineering methodologies, isolated sandbox triage, static\u002Fdynamic binary analysis, memory forensics, and YARA detection rule authoring.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FOffensive_Security_and_Pentesting\u002Fmalware-analysis-reversing\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M79FH6EACDR801TZCE4R8SAC","application-security-pentesting","Production Application Security (AppSec) standards, OWASP Top 10 vulnerability remediation, SAST\u002FDAST pipeline integration, secure code review, threat modeling, and defensive security posture.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FOffensive_Security_and_Pentesting\u002Fapplication-security-pentesting\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M79FGVVB3R4T88XXD8FRSV5B","jwt-session-management-hardening","Harden JWT-based authentication and session lifecycles using asymmetric signing (RS256\u002FEdDSA), JWKS rotation, strict claims validation, Redis-backed sliding window sessions, revocation lists, and secure HttpOnly cookie storage. Trigger when implementing token validation, session revocation, or hardening API authentication.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Fjwt-session-management-hardening\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M79FGNCPZ85CVEY0B3NE4H3B","soc2-compliance-automation","Best practices for implementing SOC 2 Type II compliance controls, continuous evidence collection, infrastructure policy-as-code, and automated security monitoring. Use when automating Trust Services Criteria (Security, Availability, Confidentiality, Processing Integrity, Privacy), audit logging, IAM least privilege, or CI\u002FCD security gates.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FGovernance_Compliance_and_Legal_Tech\u002Fsoc2-compliance-automation\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M79FGG00V6929XCZBQYJ7G3J","gdpr-ccpa-data-privacy","Engineering patterns for GDPR, CCPA\u002FCPRA, and global data privacy compliance. Use when implementing Data Subject Rights (DSAR) workflows, Right-to-be-Forgotten erasure pipelines, PII pseudonymization\u002Fanonymization, consent management (CMP), data processing logs, and audit trails.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FGovernance_Compliance_and_Legal_Tech\u002Fgdpr-ccpa-data-privacy\u002FSKILL.md",[],[]]