Documentation
¶
Overview ¶
Package tokens defines a token holder to generate and validate access tokens.
The package also provides an in-memory implementation.
Documentation Last Review: 07.10.2020
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Holder ¶
type Holder interface { // Generate creates a new token that is valid for the provided amount of // time. Generate(expiration time.Duration) string // Verify checks that the given token exists and is still valid. Verify(token string) bool }
Holder is a store for access tokens.
type InMemoryHolder ¶
InMemoryHolder stores access token in memory.
- implements tokens.Holder
func NewInMemoryHolder ¶
func NewInMemoryHolder() *InMemoryHolder
NewInMemoryHolder creates a new empty token holder.
func (*InMemoryHolder) Generate ¶
func (holder *InMemoryHolder) Generate(expiration time.Duration) string
Generate implements tokens.Holder. It generates a token that will expire after a given amount of time.
func (*InMemoryHolder) Verify ¶
func (holder *InMemoryHolder) Verify(token string) bool
Verify implements tokens.Holder. It returns true if the token is valid.
Click to show internal directories.
Click to hide internal directories.