Documentation
¶
Index ¶
- Constants
- Variables
- func AuthTokenKey(tokenID string) string
- func AuthTokenSetKey(userID int) string
- func SessionTokenKey(tokenID string) string
- func SessionTokenSetKey(userID int) string
- type Storage
- func (s *Storage) List(token *Token) ([]Token, error)
- func (s *Storage) ListAll(userID int) (map[string][]Token, error)
- func (s *Storage) LoadAuthToken(tokenID string) (*Token, error)
- func (s *Storage) LoadSessionToken(tokenID string) (*Token, error)
- func (s *Storage) NewAuthToken(userID int) *Token
- func (s *Storage) NewSessionToken(userID int) *Token
- type Token
- type Type
Constants ¶
const ( // AuthPrefix is the prefix for Auth tokens AuthPrefix = "auth" // SessionPrefix is the prefix for Session tokens SessionPrefix = "session" )
const SessionSetExpirationKey = "tokenset-session-expiration"
SessionSetExpirationKey is the key to the set which holds information about session expiration
Variables ¶
var ErrNoToken = errors.New("non-existent token")
ErrNoToken is returned when a token isn't found
Functions ¶
func AuthTokenKey ¶
AuthTokenKey returns the key used to store the Auth token
func AuthTokenSetKey ¶
AuthTokenSetKey returns the key used to store Auth token in its set
func SessionTokenKey ¶
SessionTokenKey returns the key used to store the Session token
func SessionTokenSetKey ¶
SessionTokenSetKey returns the key used to store Session token in its set
Types ¶
type Storage ¶
Storage holds the underlying token storage
func (*Storage) LoadAuthToken ¶
LoadAuthToken loads an existing Auth token from storage
func (*Storage) LoadSessionToken ¶
LoadSessionToken loads an existing Session token from storage
func (*Storage) NewAuthToken ¶
NewAuthToken creates a new Auth token
func (*Storage) NewSessionToken ¶
NewSessionToken creates a new Session token
type Token ¶
type Token struct { Cache storage.Cache `json:"-"` Key string `json:"-"` SetKey string `json:"-"` Type Type `json:"-"` UserID int `db:"user_id" json:"-"` ID string `db:"id" json:"id"` Client string `db:"client" json:"client"` IP string `db:"ip" json:"ip"` CreatedAt time.Time `db:"created_at" json:"created_at"` ExpiresAt time.Time `db:"expires_at" json:"expires_at"` LastUsedAt time.Time `db:"last_used_at" json:"last_used_at"` }
Token holds all the token information
func (*Token) SetExpiration ¶
SetExpiration sets the token expiration date
func (*Token) UpdateLastUsed ¶
UpdateLastUsed updates the LastUsedAt token information