entity

package
v0.0.0-...-20fd351 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SaltLen     = 32
	TokenExpire = 2 * 60 * 60
)
View Source
const (
	ErrCodeInvalidParam    = 1001
	ErrCodeInvalidToken    = 1002
	ErrCodeExpiredToken    = 1003
	ErrCodeInvalidPassword = 1004
	ErrCodeUserExists      = 2001
	ErrCodeUserNotExist    = 2002
	ErrCodeRoleExists      = 2003
	ErrCodeRoleNotExist    = 2004
	ErrCodeRoleNotMatch    = 2005
	ErrCodeGenToken        = 3001
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CommRsp

type CommRsp struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

CommRsp common response

type Role

type Role struct {
	RoleName   string `json:"role_name,omitempty"`
	CreateTime int64  `json:"create_time,omitempty"`
}

Role role

func (*Role) Key

func (r *Role) Key() string

Key for searching

type RoleReq

type RoleReq struct {
	RoleName string `json:"role_name,omitempty"`
}

RoleReq create or delete role request

type Token

type Token struct {
	UserName  string `json:"user_name,omitempty"`
	Password  []byte `json:"password,omitempty"`
	Rand      string `json:"rand,omitempty"`
	Timestamp int64  `json:"ts,omitempty"`
	Expire    int64  `json:"expire,omitempty"`
}

Token token

type User

type User struct {
	UserName   string `json:"user_name,omitempty"`
	Salt       []byte `json:"salt,omitempty"`
	Password   []byte `json:"password,omitempty"`
	CreateTime int64  `json:"create_time,omitempty"`
}

User user

func (*User) Key

func (u *User) Key() string

Key for searching

func (*User) UserRolesKey

func (u *User) UserRolesKey() string

UserRolesKey for searching all roles

type UserReq

type UserReq struct {
	UserName string `json:"user_name,omitempty"`
	Password string `json:"password,omitempty"`
}

UserReq create or delete user request

type UserRoleReq

type UserRoleReq struct {
	UserName string `json:"user_name,omitempty"`
	Password string `json:"password,omitempty"`
	RoleName string `json:"role_name,omitempty"`
	Token    string `json:"token,omitempty"`
}

UserRoleReq add role to user, check role request

func (*UserRoleReq) Key

func (ur *UserRoleReq) Key() string

Key user-role key

type UserRoleRsp

type UserRoleRsp struct {
	Code        int      `json:"code"`
	Msg         string   `json:"msg"`
	Token       string   `json:"token,omitempty"`
	CheckResult bool     `json:"check_result,omitempty"`
	Roles       []string `json:"roles,omitempty"`
}

UserRoleRsp authenticate, invalidate, check role, all roles response

Jump to

Keyboard shortcuts

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