Documentation
¶
Index ¶
Constants ¶
const JWTTokenKey = "tonto_http_token_key"
JWTTokenKey is used to store token to context
Variables ¶
var ( // JWTAlgHS256 represents HMAC SHA256 token signing alg JWTAlgHS256 = jwt.SigningMethodHS256 // JWTAlgHS384 represents HMAC SHA384 token signing alg JWTAlgHS384 = jwt.SigningMethodHS384 // JWTAlgHS512 represents HMAC SHA512 token signing alg JWTAlgHS512 = jwt.SigningMethodHS512 )
Functions ¶
func WithJWTAuth ¶
func WithJWTAuth(alg JWTAlg, key []byte, callback AuthCallbackFunc) http.Adapter
WithJWTAuth represents jwt authentication adapter It looks for bearer token in Authorization header, and if found tries to validate it against provided alg and key, if successful callback func is called to perform client side auth check.
Types ¶
type AuthCallbackFunc ¶
AuthCallbackFunc represents auth callback that needs to be passed in to JWTAuth middleware. This func is called after token has been successfully verified by adapter so client can do additional business auth check based on the token itself and claims extracted from it Actuall AuthCallbackFunc implementors should return error upon failed auth check or nil on success
type CORSOption ¶
type CORSOption func(*corsCfg)
CORSOption represents cors option
func WithCORSAllowHeaders ¶
func WithCORSAllowHeaders(headers ...string) CORSOption
WithCORSAllowHeaders sets allowed headers
func WithCORSAllowMethods ¶
func WithCORSAllowMethods(methods ...string) CORSOption
WithCORSAllowMethods sets allowed methods
func WithCORSAllowOrigins ¶
func WithCORSAllowOrigins(origins ...string) CORSOption
WithCORSAllowOrigins sets allowed origins