Documentation
¶
Overview ¶
Package refreshtoken manages opaque tokens that renew JWT access tokens.
Index ¶
- Variables
- type Config
- type Issued
- type Manager
- func (manager *Manager) Create(ctx context.Context, sessionID string) (Issued, error)
- func (manager *Manager) Resolve(ctx context.Context, rawToken string) (Record, error)
- func (manager *Manager) RevokeSession(ctx context.Context, rawToken string) error
- func (manager *Manager) RevokeSessionID(ctx context.Context, sessionID string) error
- func (manager *Manager) Rotate(ctx context.Context, rawToken string) (Issued, error)
- type Record
- type Store
- type TokenHash
Constants ¶
This section is empty.
Variables ¶
var ( ErrConflict = errors.New("refresh token conflict") ErrInactive = errors.New("refresh token is inactive") ErrInvalidConfig = errors.New("invalid refresh token configuration") ErrInvalidRecord = errors.New("invalid refresh token record") ErrInvalidToken = token.ErrInvalidToken ErrNotFound = errors.New("refresh token not found") ErrReuseDetected = errors.New("refresh token reuse detected") )
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) RevokeSession ¶
RevokeSession revokes the session associated with rawToken.
func (*Manager) RevokeSessionID ¶
RevokeSessionID revokes a durable access session and all of its refresh tokens.
type Record ¶
type Record struct {
SessionID string
TokenHash TokenHash
CreatedAt time.Time
ExpiresAt time.Time
RotatedAt *time.Time
RevokedAt *time.Time
}
Record is the durable state of one refresh token.
type Store ¶
type Store interface {
Create(ctx context.Context, record Record) error
FindByTokenHash(ctx context.Context, tokenHash TokenHash) (Record, error)
Rotate(ctx context.Context, current TokenHash, replacement Record, rotatedAt time.Time) error
RevokeSession(ctx context.Context, sessionID string, revokedAt time.Time) error
}
Store is the durable authority for refresh tokens.
Rotate atomically consumes current and creates replacement. Reuse invalidates the durable session and all its refresh tokens before returning ErrReuseDetected. RevokeSession performs the same invalidation explicitly.