Documentation ¶
Overview ¶
Package token implements Token.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTokenCache = &memoryCache{}
DefaultTokenCache provides default implementation for token cache.
Functions ¶
This section is empty.
Types ¶
type Token ¶
type Token struct { Value string `json:"value"` Deadline time.Time `json:"deadline"` // By default Token is non-expirable. // It becomes expirable when either Expire() or SetExpiration() is applied. // SetExpiration() is used to take explicit expires_in field into effect. // Expire() is used to invalidate the Token, since the server // refused it and a new one must be retrieved. // Expirable bool `json:"expirable"` }
Token holds a token.
func NewTokenFromJSON ¶
NewTokenFromJSON creates token from json.
func (Token) ExportJSON ¶
ExportJSON exports token as json.
func (*Token) IsValid ¶
func (t *Token) IsValid(now time.Time, softExpire time.Duration, debugf func(format string, v ...any)) bool
IsValid checks whether token is valid.
func (*Token) SetExpiration ¶
SetExpiration schedules token expiration time.
Click to show internal directories.
Click to hide internal directories.