Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthGen ¶
type AuthGen interface { GetUserData(user string) (*UserData, bool) Authenticate(user string, token string) (string, error) GenerateToken(user string, pass string) (string, error) }
AuthGen is an interface that generates token authenticates the same
type JWT ¶
JWT contains the configuration for JWT tokens
func (*JWT) Authenticate ¶
Authenticate authenticates the given token
func (*JWT) CheckUpdateNewCred ¶
func (*JWT) GenerateToken ¶
GenerateToken generates a new token for the given user
func (*JWT) SetNewCred ¶
type JWTMiddleware ¶
type JWTMiddleware struct {
AuthGen AuthGen
}
JWTMiddleware is an AuthGen implementation that uses JWT tokens
func NewMiddleware ¶
func NewMiddleware(a AuthGen) *JWTMiddleware
NewMiddleware creates a new JWTMiddleware
func (*JWTMiddleware) AuthHandler ¶
func (m *JWTMiddleware) AuthHandler(next http.Handler) http.Handler
Handler is a middleware handler
func (*JWTMiddleware) LoginHandler ¶
func (m *JWTMiddleware) LoginHandler(w http.ResponseWriter, r *http.Request)
Handler is a middleware handler
type ResponseStatusWriter ¶
type ResponseStatusWriter interface { http.ResponseWriter Status() int }
ResponseStatusWriter wraps http.ResponseWriter to save HTTP status code
Click to show internal directories.
Click to hide internal directories.