mw

package
v0.0.0-...-555e775 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: MIT Imports: 8 Imported by: 3

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

func SecureHeaders

func SecureHeaders() gin.HandlerFunc

SecureHeaders adds general security headers for basic security measures

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