Documentation
¶
Overview ¶
Package refreshtoken is the ESP User refresh-token service: it owns the token lifecycle — mint a family on login, rotate-on-use with reuse=theft detection, and revoke — over the espuser-refresh-tokens store. Tokens are signed, self-describing structures (not opaque random strings): each carries user_id|client_id|family_id|counter with an HMAC, so validity is a signature check plus a single family-row counter compare, and nothing per-token is stored. It mirrors the jwt package (a stateful service over a lower layer): this sits over db/refresh_tokens_db, which stays a pure DynamoDB store.
Index ¶
Constants ¶
const (
TokenTTL = 365 * 24 * time.Hour // 1 year; sliding window, re-stamped on each rotation
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Rotation ¶
Rotation is the result of redeeming a refresh token: the freshly-minted token plus the user/scope carried on the family, from which the caller re-mints the access/id tokens.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service issues and rotates signed refresh tokens against the refresh-tokens store.
func NewService ¶
func NewService(rmngCtx *rmngctx.RmngContext) *Service
NewService builds a refresh-token service bound to the request context.
func (*Service) MintRefreshtoken ¶
MintRefreshtoken creates a new rotation family for a login: a family row at counter 0 and the first signed token. The family carries user + scope so a later Rotate re-mints the access/id tokens.
func (*Service) RevokeAllForUser ¶
RevokeAllForUser ends every session for a user — "sign out everywhere", password reset, or compromise response — by deleting all their family rows in one user-partition query.
func (*Service) RevokeFamily ¶
RevokeFamily terminates the whole family a token belongs to — the /oauth2/revoke endpoint (RFC 7009 §2.1: revoking a token MAY revoke the underlying grant), sign-out, and detected theft all end the login by deleting its family row. An unparseable token is a no-op error.