Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Storer ¶
type Storer interface { CreateActionToken(userID, tokenID, action string, expiry time.Time) (interface{}, error) GetActionToken(tokenID string) (interface{}, error) UpdateActionToken(token interface{}) (interface{}, error) }
Storer defines the backing storage required by the token controller
type Token ¶
type Token interface { GetTokenID() string GetUserExtID() string GetAction() string IsUsed() bool GetExpiry() time.Time SetUsed(t time.Time) }
Token defines the interface required for stored tokens
type TokenClaims ¶
type TokenClaims struct { Action api.TokenAction `json:"act"` // Token action jwt.StandardClaims }
Custom claims object
type TokenController ¶
type TokenController struct {
// contains filtered or unexported fields
}
TokenController instance
func NewTokenController ¶
func NewTokenController(address string, hmacSecret string, storer Storer) *TokenController
NewTokenController constructor
func (*TokenController) BuildToken ¶
func (tc *TokenController) BuildToken(userID string, action api.TokenAction, duration time.Duration) (string, error)
BuildToken builds a signed token for the given user id with a provided action and duration for use
func (*TokenController) SetUsed ¶
func (tc *TokenController) SetUsed(tokenString string) error
SetUsed marks a token as used in the backing datastore
func (*TokenController) ValidateToken ¶
func (tc *TokenController) ValidateToken(userID, tokenString string) (*api.TokenAction, error)
ValidateToken validates a token using the provided key and backing store
Click to show internal directories.
Click to hide internal directories.