Token lifecycle

From RedHatProductSecurity/prodsec-skills · View interactive version

Token lifecycle is an AI agent skill from the GitHub repository RedHatProductSecurity/prodsec-skills. Enforce token rotation, revocation, and replay prevention for inference engines. Use when implementing or reviewing refresh token handling, token revocation, or replay protection in inference engine authentication.

How to use this skill

Skill file

Token Lifecycle Management for Inference Engines

Security Requirement

Inference engines and their supporting infrastructure MUST implement proper token lifecycle management including refresh token rotation, replay prevention, and instant revocation capabilities.

Refresh Token Rotation

Require IdP refresh token rotation with one of:

Revocation

Implement a two-layer revocation strategy:

  1. IdP Revocation Endpoint: Use the IdP's /oauth/revoke endpoint as the primary revocation mechanism.
  2. Local Blacklist: Maintain a Redis-based or in-memory JWT blacklist keyed by jti for instant propagation without IdP round-trips.

Implementation Checklist

Example: Revocation Check Flow

Request arrives with JWT
  → Extract `jti` from token
  → Check local Redis blacklist for `jti`
    → If found: reject request (401)
    → If not found: proceed with standard JWT validation
  → On revocation event:
    → Call IdP /oauth/revoke
    → Add `jti` to local Redis blacklist with TTL = token's remaining `exp`
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.