[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79FGVVB3R4T88XXD8FRSV5B":3,"skill-same:01M79FGVVB3R4T88XXD8FRSV5B":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},"01M79FGVVB3R4T88XXD8FRSV5B","jwt-session-management-hardening",null,"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.","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\u002Fjwt-session-management-hardening\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: jwt-session-management-hardening\nmetadata:\n  category: Identity Auth and Access Management\ndescription: 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.\ncompatibility: RFC 7519 (JWT), RFC 7517 (JWKS), Redis 7+\n---\n\n# JWT Session Management & Hardening Skill Guide\n\nThis skill specifies security rules and architectural implementations for issuing, verifying, storing, and revoking JSON Web Tokens (JWT) in high-security backend environments.\n\n---\n\n## 1. Storage Architecture: HttpOnly Cookies vs Bearer Tokens\n\n```text\n[ Browser Context ]\n   |\n   |-- NEVER store JWT in localStorage or sessionStorage (XSS Vulnerable!)\n   |\n   +---> Uses HttpOnly, Secure, SameSite=Strict \u002F Lax Cookie\n             |\n             v (Automated Cookie Transport)\n[ Reverse Proxy \u002F API Gateway ]\n   |\n   +---> Extracts JWT from Cookie or Authorization: Bearer \u003Ctoken>\n   +---> Validates signature using Public JWKS (Asymmetric RS256\u002FEdDSA)\n   +---> Checks Revocation \u002F Blacklist in Redis\n             |\n             v\n[ Internal Microservices (Context Propagated via Verified Claims) ]\n```\n\n---\n\n## 2. Production Hardening Implementation\n\n### A. JWT Verification & Claim Assertion (Python \u002F PyJWT)\n\n```python\nimport time\nfrom typing import Any\nimport jwt\nfrom jwt import PyJWKClient\n\n\nclass JWTVerifier:\n    def __init__(self, jwks_url: str, expected_issuer: str, expected_audience: str):\n        self.jwks_client = PyJWKClient(jwks_url, cache_jwk_set=True, lifespan=3600)\n        self.issuer = expected_issuer\n        self.audience = expected_audience\n\n    def decode_and_validate(self, token: str) -> dict[str, Any]:\n        # 1. Fetch matching public key by kid header\n        signing_key = self.jwks_client.get_signing_key_from_jwt(token)\n\n        # 2. Strict cryptographic validation\n        payload = jwt.decode(\n            token,\n            signing_key.key,\n            algorithms=[\"RS256\", \"EdDSA\"],  # Explicit algorithm whitelist\n            issuer=self.issuer,\n            audience=self.audience,\n            options={\n                \"require\": [\"exp\", \"iat\", \"nbf\", \"iss\", \"aud\", \"sub\", \"jti\"],\n                \"verify_exp\": True,\n                \"verify_iat\": True,\n                \"verify_nbf\": True,\n                \"verify_iss\": True,\n                \"verify_aud\": True,\n            },\n            leeway=10,  # 10 seconds clock skew tolerance\n        )\n        return payload\n```\n\n### B. Redis Revocation List & Sliding Session (Go)\n\n```go\npackage session\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com\u002Fredis\u002Fgo-redis\u002Fv9\"\n)\n\ntype SessionManager struct {\n\trdb *redis.Client\n}\n\nfunc NewSessionManager(rdb *redis.Client) *SessionManager {\n\treturn &SessionManager{rdb: rdb}\n}\n\n\u002F\u002F RevokeToken marks a JWT ID (jti) as revoked until its natural expiration.\nfunc (sm *SessionManager) RevokeToken(ctx context.Context, jti string, expiresAt time.Time) error {\n\tttl := time.Until(expiresAt)\n\tif ttl \u003C= 0 {\n\t\treturn nil \u002F\u002F Already naturally expired\n\t}\n\tkey := fmt.Sprintf(\"jwt:blacklist:%s\", jti)\n\treturn sm.rdb.Set(ctx, key, \"revoked\", ttl).Err()\n}\n\n\u002F\u002F IsRevoked checks if the token jti is present in the blacklist.\nfunc (sm *SessionManager) IsRevoked(ctx context.Context, jti string) (bool, error) {\n\tkey := fmt.Sprintf(\"jwt:blacklist:%s\", jti)\n\tval, err := sm.rdb.Exists(ctx, key).Result()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn val > 0, nil\n}\n\n\u002F\u002F RefreshSlidingSession extends user activity timestamp.\nfunc (sm *SessionManager) RefreshSlidingSession(ctx context.Context, userID string, maxInactivity time.Duration) error {\n\tkey := fmt.Sprintf(\"user:session:%s\", userID)\n\treturn sm.rdb.Expire(ctx, key, maxInactivity).Err()\n}\n```\n\n---\n\n## 3. Mandatory Security Checklist\n\n- [ ] **Algorithm Whitelisting:** Explicitly allow only `[\"RS256\"]` or `[\"EdDSA\"]`. Strictly disallow `none` or symmetric keys `HS256` if verified against an external IdP.\n- [ ] **Short Access Lifetimes:** Set Access Token expiration between 5 to 15 minutes max.\n- [ ] **Mandatory `jti` Claim:** Ensure every token includes a unique `jti` (UUID v4) to enable individual token blacklisting.\n- [ ] **Cookie Flags:** When using browser cookies, enforce:\n  `Set-Cookie: access_token=...; HttpOnly; Secure; SameSite=Lax; Path=\u002F`\n","# JWT Session Management & Hardening Skill Guide\n\nThis skill specifies security rules and architectural implementations for issuing, verifying, storing, and revoking JSON Web Tokens (JWT) in high-security backend environments.\n\n---\n\n## 1. Storage Architecture: HttpOnly Cookies vs Bearer Tokens\n\n```text\n[ Browser Context ]\n   |\n   |-- NEVER store JWT in localStorage or sessionStorage (XSS Vulnerable!)\n   |\n   +---> Uses HttpOnly, Secure, SameSite=Strict \u002F Lax Cookie\n             |\n             v (Automated Cookie Transport)\n[ Reverse Proxy \u002F API Gateway ]\n   |\n   +---> Extracts JWT from Cookie or Authorization: Bearer \u003Ctoken>\n   +---> Validates signature using Public JWKS (Asymmetric RS256\u002FEdDSA)\n   +---> Checks Revocation \u002F Blacklist in Redis\n             |\n             v\n[ Internal Microservices (Context Propagated via Verified Claims) ]\n```\n\n---\n\n## 2. Production Hardening Implementation\n\n### A. JWT Verification & Claim Assertion (Python \u002F PyJWT)\n\n```python\nimport time\nfrom typing import Any\nimport jwt\nfrom jwt import PyJWKClient\n\n\nclass JWTVerifier:\n    def __init__(self, jwks_url: str, expected_issuer: str, expected_audience: str):\n        self.jwks_client = PyJWKClient(jwks_url, cache_jwk_set=True, lifespan=3600)\n        self.issuer = expected_issuer\n        self.audience = expected_audience\n\n    def decode_and_validate(self, token: str) -> dict[str, Any]:\n        # 1. Fetch matching public key by kid header\n        signing_key = self.jwks_client.get_signing_key_from_jwt(token)\n\n        # 2. Strict cryptographic validation\n        payload = jwt.decode(\n            token,\n            signing_key.key,\n            algorithms=[\"RS256\", \"EdDSA\"],  # Explicit algorithm whitelist\n            issuer=self.issuer,\n            audience=self.audience,\n            options={\n                \"require\": [\"exp\", \"iat\", \"nbf\", \"iss\", \"aud\", \"sub\", \"jti\"],\n                \"verify_exp\": True,\n                \"verify_iat\": True,\n                \"verify_nbf\": True,\n                \"verify_iss\": True,\n                \"verify_aud\": True,\n            },\n            leeway=10,  # 10 seconds clock skew tolerance\n        )\n        return payload\n```\n\n### B. Redis Revocation List & Sliding Session (Go)\n\n```go\npackage session\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com\u002Fredis\u002Fgo-redis\u002Fv9\"\n)\n\ntype SessionManager struct {\n\trdb *redis.Client\n}\n\nfunc NewSessionManager(rdb *redis.Client) *SessionManager {\n\treturn &SessionManager{rdb: rdb}\n}\n\n\u002F\u002F RevokeToken marks a JWT ID (jti) as revoked until its natural expiration.\nfunc (sm *SessionManager) RevokeToken(ctx context.Context, jti string, expiresAt time.Time) error {\n\tttl := time.Until(expiresAt)\n\tif ttl \u003C= 0 {\n\t\treturn nil \u002F\u002F Already naturally expired\n\t}\n\tkey := fmt.Sprintf(\"jwt:blacklist:%s\", jti)\n\treturn sm.rdb.Set(ctx, key, \"revoked\", ttl).Err()\n}\n\n\u002F\u002F IsRevoked checks if the token jti is present in the blacklist.\nfunc (sm *SessionManager) IsRevoked(ctx context.Context, jti string) (bool, error) {\n\tkey := fmt.Sprintf(\"jwt:blacklist:%s\", jti)\n\tval, err := sm.rdb.Exists(ctx, key).Result()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn val > 0, nil\n}\n\n\u002F\u002F RefreshSlidingSession extends user activity timestamp.\nfunc (sm *SessionManager) RefreshSlidingSession(ctx context.Context, userID string, maxInactivity time.Duration) error {\n\tkey := fmt.Sprintf(\"user:session:%s\", userID)\n\treturn sm.rdb.Expire(ctx, key, maxInactivity).Err()\n}\n```\n\n---\n\n## 3. Mandatory Security Checklist\n\n- [ ] **Algorithm Whitelisting:** Explicitly allow only `[\"RS256\"]` or `[\"EdDSA\"]`. Strictly disallow `none` or symmetric keys `HS256` if verified against an external IdP.\n- [ ] **Short Access Lifetimes:** Set Access Token expiration between 5 to 15 minutes max.\n- [ ] **Mandatory `jti` Claim:** Ensure every token includes a unique `jti` (UUID v4) to enable individual token blacklisting.\n- [ ] **Cookie Flags:** When using browser cookies, enforce:\n  `Set-Cookie: access_token=...; HttpOnly; Secure; SameSite=Lax; Path=\u002F`\n",{"name":5,"metadata":24,"description":7,"compatibility":26},{"category":25},"Identity Auth and Access Management","RFC 7519 (JWT), RFC 7517 (JWKS), Redis 7+","main","e905af21e5f1e1c3ca605e9656c3a7930360a84e","Security\u002FIdentity_and_Access_Management_IAM\u002Fjwt-session-management-hardening",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 jwt-session-management-hardening",{"tool":43,"command":44},"bunx","bunx skills add hamzabellouch\u002Fagent-skills --skill jwt-session-management-hardening",{"tool":46,"command":47},"pnpm","pnpm dlx skills add hamzabellouch\u002Fagent-skills --skill jwt-session-management-hardening","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Fjwt-session-management-hardening\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},"01M79FH0VKVT44FK923K520ZQA","oauth2-oidc-security-flows","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.","https:\u002F\u002Fgithub.com\u002Fhamzabellouch\u002Fagent-skills\u002Fblob\u002Fmain\u002FSecurity\u002FIdentity_and_Access_Management_IAM\u002Foauth2-oidc-security-flows\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",[],[]]