Documentation
¶
Overview ¶
Package authenticate - user authentication
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IntrospectFunc ¶ added in v0.4.0
IntrospectFunc signature for a function to call to introspect
type Introspector ¶ added in v0.4.0
type Introspector interface {
/*
VerifyToken verify a given token
@param ctxt context.Context - the operating context
@param token string - the original token
@param expire int64 - when the token expires
@param timestamp time.Time - the current timestamp
@return whether token is valid
*/
VerifyToken(ctxt context.Context, token string, expire int64, timestamp time.Time) (bool, error)
}
Introspector perform introspection on given token
func DefineIntrospector ¶ added in v0.4.0
func DefineIntrospector(cache TokenCache, introspectCB IntrospectFunc) Introspector
DefineIntrospector defines a new introspector object
@param cache TokenCache - token cache @param introspectCB IntrospectFunc - callback function to use to perform introspection @return new introspector
type TokenCache ¶ added in v0.4.0
type TokenCache interface {
/*
RecordToken cache a new token
@param ctxt context.Context - the operating context
@param token string - the original token
@param expire int64 - when the token expires
@param timestamp time.Time - the current timestamp
@return whether caching was successful
*/
RecordToken(ctxt context.Context, token string, expire int64, timestamp time.Time) error
/*
RecordToken remote a token from cache
@param ctxt context.Context - the operating context
@param token string - the original token
@return whether delete was successful
*/
RemoveToken(ctxt context.Context, token string) error
/*
ValidTokenInCache check whether this token is already cached and valid.
If the token is present, but requires re-validation, this function will remove the
token from cache and indicate no valid token is cached.
@param ctxt context.Context - the operating context
@param token string - the original token
@param timestamp time.Time - the current timestamp
@return whether it is present and valid
*/
ValidTokenInCache(ctxt context.Context, token string, timestamp time.Time) (bool, error)
/*
RemoveExpiredFromCache remove all expired tokens from cache
@param ctxt context.Context - the operating context
@param timestamp time.Time - the current timestamp
@return whether successful
*/
RemoveExpiredFromCache(ctxt context.Context, timestamp time.Time) error
/*
ClearCache remove all entries from cache
@param ctxt context.Context - the operating context
*/
ClearCache(ctxt context.Context)
}
TokenCache cache for recording and fetching tokens encountered
func DefineTokenCache ¶ added in v0.4.0
func DefineTokenCache(refreshInt time.Duration) TokenCache
DefineTokenCache defines a new token cache object
@param refreshInt time.Duration - a token must to be re-validated after this duration @return new cache instance
Click to show internal directories.
Click to hide internal directories.