Documentation ¶
Index ¶
Constants ¶
View Source
const KeyLength = 32
Variables ¶
View Source
var NotFoundError = errors.New("token not found")
Functions ¶
This section is empty.
Types ¶
type Payload ¶
func NewPayload ¶
type Store ¶
type Store interface { // Generate creates a random token for user with payload and saves to store Generate(username string, data string, lifetime time.Duration) (string, error) // StoreToken saves a token and data to store with limited lifetime StoreToken(username, token, data string, lifetime time.Duration) error // DeleteToken removes a sigle token from store DeleteToken(t string) error // GetData returns the stored data of the token GetData(token string) (data string, err error) // GetUserTokens returns list of tokens of the given user GetUserTokens(username string) ([]string, error) // DeleteUserTokens removes all tokens of the user DeleteUserTokens(username string) error }
Store contains methods to manage tokens
func NewEtcdStore ¶
NewEtcdStore creates a Store managing access tokens. A token `x` is stored at both place:
- $(indexKeyPrefix)/users/${u}/x: this key is used for indexing and listing tokens of user `u`.
- $(payloadKeyPrefix)/x: this key contains actual payload data of the token. It's used for fast lookup tokens
Click to show internal directories.
Click to hide internal directories.