middleware

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(r *gin.Engine, h ...gin.HandlerFunc)

Add adds middlewares to gin engine

Types

type JWT

type JWT struct {
	// Realm name to display to the user.
	Realm string

	// Secret key used for signing.
	Key []byte

	// Duration for which the jwt token is valid.
	Duration time.Duration

	// JWT signing algorithm
	Algo string
}

JWT provides a Json-Web-Token authentication implementation

func NewJWT

func NewJWT(c *config.JWT) *JWT

NewJWT generates new JWT variable necessery for auth middleware

func (*JWT) GenerateToken

func (j *JWT) GenerateToken(u *model.User) (string, string, error)

GenerateToken generates new JWT token and populates it with user data

func (*JWT) MWFunc

func (j *JWT) MWFunc() gin.HandlerFunc

MWFunc makes JWT implement the Middleware interface.

func (*JWT) ParseToken

func (j *JWT) ParseToken(c *gin.Context) (*jwt.Token, error)

ParseToken parses token from Authorization header

Jump to

Keyboard shortcuts

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