authorization

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticator

func Authenticator(c *gin.Context) (claims jwt.MapClaims, err error)

Authenticator function

The authenticator will sends a 401 Unauthorized responses for any unverified tokens and return claims if passed

func ComparePasswords

func ComparePasswords(hashedPwd string, plainPwd []byte) bool

ComparePasswords function to compare password login and exists data

func GenerateHash

func GenerateHash(password string) string

GenerateHash to generate hash from plain password

func GenerateToken

func GenerateToken(c *gin.Context, id string, write, delete bool) (t string, rt string, tExp int64, err error)

GenerateToken function

Generate JWT token by user uuid, and set user can use write or delete action

func GenerateUniqueCode

func GenerateUniqueCode(max int) (string, error)

GenerateUniqueCode to generate a unique string with 6 letters

func HashAndSalt

func HashAndSalt(pwd []byte) string

HashAndSalt to create hash password with salt and return hash string

func HashCompare

func HashCompare(password, hashedPwd string) bool

HashCompare to compare your password with your stored hash password

func RefreshAuthenticator

func RefreshAuthenticator(c *gin.Context) (string, error)

RefreshAuthenticator function

The refresh authenticator used for renewing the access token.

Types

type Refresher

type Refresher struct {
	UserUUID  string
	IPAddress string
	Exp       int64
}

Refresher struct, to set refresh token on redis

Jump to

Keyboard shortcuts

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