Documentation ¶
Index ¶
Constants ¶
const (
ScopeAll = "all"
)
Scopes
Variables ¶
var ( ErrNotAuthorized = errors.New("not authorized") ErrInvalidClient = errors.New("invalid client") ErrInvalidAuth = errors.New("invalid auth") ErrMissingRedirect = errors.New("missing redirect_uri") ErrInvalidResponseType = errors.New("response_type unsupported") )
Error Values
var ( ErrExpectStringValue = errors.New("TokenCache expects the value to be a string") ErrExpectStringSlice = errors.New("TokenCache expects the value list to be a []string") )
Errors
Functions ¶
func NewRequestChecker ¶
func NewRequestChecker(cache *TokenCache, users *user.Registry) common.RequestChecker
NewRequestChecker returns a Bearer Token request checker
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler provides OAuth2 capabilities.
func NewHandler ¶
NewHandler creates and initializes a new OAuthHandler
func (*Handler) Authorized ¶
Authorized returns the authorized scopes for a request, or an error if the request does not have sufficient authorization.
type Options ¶
type Options struct { TokenTTL time.Duration GrantTTL time.Duration Cache store.Cache TokenCache *TokenCache Clients *client.Registry Users *user.Registry }
Options encapsulates OAuth Handler options.
type TokenCache ¶
type TokenCache struct {
// contains filtered or unexported fields
}
TokenCache provides a forward/backward lookup cache for clients and tokens.
There is an n->1 relationship between tokens and client id, so this cache abstracts managing the lookup and expiration of tokens per client id.
func NewTokenCache ¶
func NewTokenCache(clients store.Cache, tokens store.Cache) *TokenCache
NewTokenCache creates a new TokenCache from the provided store.Cache's representing client tokens, and token clients.
func (*TokenCache) Delete ¶
func (c *TokenCache) Delete(token string) error
Delete removes token from the cache.
func (*TokenCache) Get ¶
func (c *TokenCache) Get(token string) (interface{}, error)
Get expects to be given a token, and to return a client id.
func (*TokenCache) Put ¶
func (c *TokenCache) Put(key string, value interface{}) error
Put expects value to be a string token.