Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( InvalidToken error = errors.New("invalid-token") ExpiredToken error = errors.New("token-expired") ErrNoSignKey = errors.New("no-sign-key") ErrNoVerifyKey = errors.New("no-verify-key") )
View Source
var (
ErrNoAuthToken = errors.New("no-auth-token")
)
Functions ¶
func ReadPublicKey ¶
Types ¶
type CheckScope ¶
type CryptoService ¶
type GetScopesFromToken ¶
type HttpHandler ¶
type HttpHandler func(auth Context, resp http.ResponseWriter, req *http.Request)
type IsAuthOn ¶
type IsAuthOn func() bool
Function to override checking of flag. This is useful for testing to turn off auth.
type Service ¶
type Service interface { NewToken() (token *Token) SignedStringForHttpRequest(token *Token, req *http.Request) (tokenString string, err error) SignedString(token *Token, f SignKey) (tokenString string, err error) Parse(tokenString string, f VerifyKey) (token *Token, err error) ParseForHttpRequest(tokenString string, req *http.Request) (token *Token, err error) RequiresAuth(scope string, get_scopes GetScopesFromToken, handler HttpHandler) func(http.ResponseWriter, *http.Request) }
type Settings ¶
type Settings struct { TTLHours time.Duration IsAuthOn IsAuthOn CheckScope CheckScope SignKeyFromHttpRequest func(*http.Request) []byte VerifyKeyFromHttpRequest func(*http.Request) []byte ErrorRenderer func(http.ResponseWriter, *http.Request, string, int) error AuthIntercept func(bool, Context) (bool, Context) }
Sign keys and verifcation keys are both function of the input which is the http request.
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
func (*Token) SetExpiration ¶
Click to show internal directories.
Click to hide internal directories.