auth

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(hashedPassword, password string) error

Compare compares the encrypted text with the plain text if it's the same

func Encrypt

func Encrypt(source string) (string, error)

Encrypt encrypts the plain text with bcrypt.

func Sign

func Sign(ctx context.Context, payload map[string]any, secret string, timeout int64) (tokenString string, err error)

Sign signs the payload with the specified secret.

Types

type Payload

type Payload struct {
	UserID int
}

Payload is the data of the JSON web token. 主要是配合jwt来生成用户登录token

func Parse

func Parse(tokenString string, secret string) (*Payload, error)

Parse validates the token with the specified secret, and returns the payloads if the token was valid.

Jump to

Keyboard shortcuts

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