Documentation ¶
Index ¶
- Constants
- Variables
- func RestrictScope(server string, token string, scope []string) (string, error)
- type HTTPError
- type Manager
- type TokenStore
- func ConstStore(token string) TokenStore
- func DirStore(dirname string) TokenStore
- func DirStoreWithFormat(dirname, format string) TokenStore
- func FileStore(filename string) TokenStore
- func FileStoreWithNameFn(dirname string, nameFn func(string) string) TokenStore
- func MemoryStore() TokenStore
- func RedisStore(client *redis.Client) TokenStore
Constants ¶
const TTLMargin = 5 * time.Second
Variables ¶
var NullStore = &nullStore{}
NullStore is a TokenStore that does not store tokens at all
Functions ¶
Types ¶
type Manager ¶
type Manager interface { // Get a token for the specified scope TokenForScope(scope string) (string, error) }
Manager represent all types that can manage tokens
func HTTPManager ¶
func HTTPManager(server, token string, store TokenStore) Manager
HTTPManager creates a new token manager that uses the specified store to store and retrieve tokens
type TokenStore ¶
type TokenStore interface { // Get gets a token from the TokenStore, returning // the empty string if the token does not exist Get(parent string, scope string) (string, error) // Set saves a token, but only stores it for a given time Set(parent string, scope []string, token string, TTL time.Duration) error }
TokenStore is the interface of all the token storage engines
func ConstStore ¶
func ConstStore(token string) TokenStore
ConstStore creates a TokensStore that always returns the same token
func DirStore ¶
func DirStore(dirname string) TokenStore
DirStore creates a filestore that stores tokens in the specified directory
func DirStoreWithFormat ¶
func DirStoreWithFormat(dirname, format string) TokenStore
DirStoreWithFormat creates a filestore that stores tokens in the specified directory under with a custom filename
func FileStore ¶
func FileStore(filename string) TokenStore
func FileStoreWithNameFn ¶
func FileStoreWithNameFn(dirname string, nameFn func(string) string) TokenStore
DirStoreWithNameFn creates a filestore that stores tokens in the specified directory under with a custom filename
func MemoryStore ¶
func MemoryStore() TokenStore
MemoryStore returns a new TokenStore that stores the tokens in memory
func RedisStore ¶
func RedisStore(client *redis.Client) TokenStore
RedisStore returns a TokenStore that stores tokens in redis