auth

package
v0.0.0-...-0473bba Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	UCINFO_SALT = "@**nvwa-io**@"
	KEY_TOKEN   = "Nvwa-Token"
	EXPIRE      = 7 * 24 * 3600
)

Variables

This section is empty.

Functions

This section is empty.

Types

type UCInfo

type UCInfo struct {
	Uid   int64 `json:"uid"`
	Ctime int64 `json:"ctime"`
}

tips: data = json.Marshal(UCInfo) sign = md5(data + salt) Nvwa-Token = 3des(data + SALT + sign)

type UserAuth

type UserAuth struct{}

func NewUserAuth

func NewUserAuth() *UserAuth

func (*UserAuth) ParseUserTokenFromHeader

func (t *UserAuth) ParseUserTokenFromHeader(ctx *context.Context) (*UCInfo, error)

解析 Header 中的 Token

func (*UserAuth) UCInfoDecrypt

func (t *UserAuth) UCInfoDecrypt(data string) (*UCInfo, error)

func (*UserAuth) UCInfoEncrypt

func (t *UserAuth) UCInfoEncrypt(ucInfo *UCInfo) (string, error)

func (*UserAuth) UCInfoEncryptByUid

func (t *UserAuth) UCInfoEncryptByUid(uid int64) (string, int64, error)

Jump to

Keyboard shortcuts

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