security

package
v0.0.0-...-b9c356b Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: AGPL-3.0 Imports: 20 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ScenarioSignup       = "signup"
	ScenarioFindPassword = "findPassword"
)
View Source
const Key string = "zAr92gmhb9fujgsYgk9Wf6trkfxneuaNG"

Key 加密密钥

Variables

This section is empty.

Functions

func GenerateAdminAccessToken

func GenerateAdminAccessToken(admin *entity.Admin) (tokenStr string, exp int64, expIn int64, err error)

func GenerateAdminRefreshToken

func GenerateAdminRefreshToken(admin *entity.Admin) (tokenStr string, exp int64, expIn int64, err error)

func GenerateParamsSign

func GenerateParamsSign(dataMap map[string]interface{}, privateKey string) (sign string)

GenerateParamsSign 生成验签sign

func GeneratePassword

func GeneratePassword(password string) (re string, err error)

GeneratePassword 生成密码

func GenerateUserAccessToken

func GenerateUserAccessToken(user *entity.User) (tokenStr string, exp int64, expIn int64, err error)

GenerateUserAccessToken 生成Token

func GenerateUserRefreshToken

func GenerateUserRefreshToken(user *entity.User) (tokenStr string, exp int64, expIn int64, err error)

func HostUrl

func HostUrl(r ...*ghttp.Request) (re string, err error)

func ValidateEmailCodeIsRight

func ValidateEmailCodeIsRight(scenario string, email string, code string) (err error)

ValidateEmailCodeIsRight 校验是否正确 不管什么错,直接返回错

func ValidateParamsSign

func ValidateParamsSign(dataMap map[string]interface{}, privateKey string) bool

ValidateParamsSign 校验sign是否正确

func ValidatePassword

func ValidatePassword(password, passwordHash string) bool

ValidatePassword 校验密码

Types

type EmailCodeRe

type EmailCodeRe struct {
	Code           string
	IntervalSecond int64
	ExpireIn       int64
}

func GenerateEmailCode

func GenerateEmailCode(scenario string, email string, ip string) (re *EmailCodeRe, err error)

GenerateEmailCode 生成4位验证码 传入场景不同的场景不同的验证码互不干扰

type ParseAdminTokenRe

type ParseAdminTokenRe struct {
	Admin     *entity.Admin
	IsRefresh bool
	DeviceId  string
}

func ParseAdminToken

func ParseAdminToken(tokenStr string) (re *ParseAdminTokenRe, err error)

ParseAdminToken 解析管理员Token

type ParseUserTokenRe

type ParseUserTokenRe struct {
	User      *entity.User
	IsRefresh bool
	DeviceId  string
}

func ParseUserToken

func ParseUserToken(tokenStr string) (re *ParseUserTokenRe, err error)

ParseUserToken 解析Token

type ValidateEmailCodeRe

type ValidateEmailCodeRe struct {
	IsRight   bool
	IsExpired bool
}

func ValidateEmailCode

func ValidateEmailCode(scenario string, email string, code string) (re *ValidateEmailCodeRe, err error)

ValidateEmailCode 校验验证码

Jump to

Keyboard shortcuts

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