middleware

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenExpired     error  = errors.New("Token is expired")
	TokenNotValidYet error  = errors.New("Token not active yet")
	TokenMalformed   error  = errors.New("That's not even a token")
	TokenInvalid     error  = errors.New("Couldn't handle this token:")
	TokenNoSet       error  = errors.New("Token is not set")
	SignKey          string = config.GetString("auth.sign_key")
)

Functions

func AuthRequired

func AuthRequired() gin.HandlerFunc

func GetSignKey

func GetSignKey() string

func SetSignKey

func SetSignKey(key string) string

Types

type CustomClaims

type CustomClaims struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
	//Email string `json:"email"`
	jwt.StandardClaims
}

type JWT

type JWT struct {
	SigningKey []byte
}

func NewJWT

func NewJWT() *JWT

func (*JWT) CreateToken

func (j *JWT) CreateToken(claims CustomClaims) (string, error)

func (*JWT) ParseToken

func (j *JWT) ParseToken(tokenString string) (*CustomClaims, error)

func (*JWT) RefreshToken

func (j *JWT) RefreshToken(tokenString string) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL