Defines a Redis‑backed cache for JWT refresh tokens with replay protection and token family management.
// Source: https://github.com/Wei-Shaw/sub2api | License: LGPL-3.0 | Modified files must remain under LGPL-3.0
// Modifications to this file must remain under LGPL-3.0.
// Provided via justclaw.it.com; keep this notice with the code.
package service
import (
"context"
"errors"
"time"
)
// ErrRefreshTokenNotFound is returned when a refresh token is not found in cache.
// This is used to abstract away the underlying cache implementation (e.g., redis.Nil).
var ErrRefreshTokenNotFound = errors.New("refresh token not found")
// RefreshTokenData 存储在Redis中的Refresh Token数据
type RefreshTokenData struct {
UserID int64 `json:"user_id"`
TokenVersion int64 `json:"token_version"` // 用于检测密码更改后的Token失效
FamilyID string `json:"family_id"` // Token家族ID,用于防重
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key