API 参考
CyberGo JWT 库提供完整的 JWT 令牌生命周期管理 API。
模块结构
| 模块 | 说明 | 详情 |
|---|---|---|
| 包函数 | New、DefaultConfig、NewRateLimiter 等工厂函数 | 构造与初始化 |
| Processor | 令牌创建、验证、刷新、吊销等核心方法 | 核心操作 |
| Config | Config、BlacklistConfig 配置结构 | 配置管理 |
| Claims | Claims、RegisteredClaims 声明类型 | 令牌声明 |
| 接口定义 | TokenManager、CustomClaims、BlacklistStore 等 | 扩展接口 |
| 类型与常量 | 签名算法常量、NumericDate、StringOrSlice 等 | 辅助类型 |
| 错误 | 17 个哨兵错误、ValidationError | 错误处理 |
快速查找
按使用场景
| 场景 | 相关 API |
|---|---|
| 创建 Processor | jwt.New()、jwt.DefaultConfig() |
| 签发令牌 | Processor.Create()、Processor.CreateRefresh() |
| 验证令牌 | Processor.Validate()、Processor.ValidateInto() |
| 刷新令牌 | Processor.Refresh()、Processor.RefreshInto() |
| 吊销令牌 | Processor.Revoke()、Processor.IsRevoked() |
| 配置签名算法 | Config.SigningMethod |
| 自定义 Claims | CustomClaims 接口 |
| 黑名单管理 | BlacklistStore 接口 |
| 限流保护 | RateLimitProvider 接口 |
| 错误处理 | 哨兵错误 |