middleware

package
v0.0.0-...-034a78d Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(user models.User) (string, error)

CreateLToken returns token use jwt with custom claims

func Md5Encrypt

func Md5Encrypt(user models.User) string

Md5Encrypt returns secret key use Mk5 encryption with username and password

Types

type CustomClaims

type CustomClaims struct {
	jwt.StandardClaims
	UserName string `json:"username"`
	Password string `json:"password"`
}

CustomClaims represents jwt custom claims param need username and password and some standard claims

func ParseToken

func ParseToken(tokenString string, user models.User) (*CustomClaims, error)

ParseToken returns jwt claims by token get secret key use Md5Encrypt method with username and password then jwt parse token by secret key

func (*CustomClaims) Valid

func (*CustomClaims) Valid() error

Valid rewrites jwt.Claims valid method return nil

type UserAuthentication

type UserAuthentication struct {
	// contains filtered or unexported fields
}

UserAuthentication represents authentication param

func NewUserAuthentication

func NewUserAuthentication(user models.User) *UserAuthentication

NewUserAuthentication creates authentication api instance

func (*UserAuthentication) ValidateMiddleware

func (u *UserAuthentication) ValidateMiddleware(next http.Handler) http.Handler

ValidateTokenMiddleware creates middleware for user permissions validation by request header Authorization if not authorization throw error else perform the next action

Jump to

Keyboard shortcuts

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