iamapi

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: Apache-2.0 Imports: 15 Imported by: 13

Documentation

Index

Constants

View Source
const (
	AccountCurrencyTypeCash    uint8 = 1
	AccountCurrencyTypeVirtual uint8 = 32
	AccountCurrencyTypeCard    uint8 = 33
)
View Source
const (
	PayTypeLease uint8 = 1
	PayTypeOrder uint8 = 2
)
View Source
const (
	AccountChargeTypePrepay uint8 = 1
	AccountChargeTypePayout uint8 = 2

	AccountChargeCycleHour  uint32 = 3600
	AccountChargeCycleDay   uint32 = 86400
	AccountChargeCycleMonth uint32 = 2592000
)
View Source
const (
	AccessTokenKey = "_iam_at"
	UserKeyDefault = "std"

	ErrCodeAccessDenied    = "AccessDenied"
	ErrCodeUnauthorized    = "Unauthorized" // Need to login and fetch a new access-token
	ErrCodeInvalidArgument = "InvalidArgument"
	ErrCodeUnavailable     = "Unavailable"
	ErrCodeServerError     = "ServerError"
	ErrCodeInternalError   = "InternalError"
	ErrCodeNotFound        = "NotFound"
	ErrCodeAccChargeOut    = "AccChargeOut"
)
View Source
const (
	UserTypeGroup uint32 = 1 << 1
)

Variables

View Source
var (
	UsernameRE = regexp.MustCompile("^[a-z]{1}[a-z0-9-]{2,18}[a-z0-9]{1}$")
	EmailRE    = regexp.MustCompile("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,10})$")
	AppIdRE    = regexp.MustCompile("^[a-f0-9]{16,24}$")
)
View Source
var (
	AccGenIdReg = regexp.MustCompile("^[0-9a-f]{16,24}$")
)

Functions

func AccountChargeCycleTimeClose

func AccountChargeCycleTimeClose(cycle, ctc uint32) uint32

func AccountChargeCycleTimeCloseNow

func AccountChargeCycleTimeCloseNow(cycle uint32) uint32

func AccountChargeId

func AccountChargeId(prod types.NameIdentifier, start uint32) ([]byte, string)

func AccountChargeTimeNow

func AccountChargeTimeNow() uint32

func AccountCurrencyTypeValid

func AccountCurrencyTypeValid(v uint8) bool

func AccountFloat64Round

func AccountFloat64Round(f float64, pa_num int64) float64

func ArrayStringDel

func ArrayStringDel(ls *[]string, a string) bool

func ArrayStringEqual

func ArrayStringEqual(lsa, lsb []string) bool

func ArrayStringHas

func ArrayStringHas(ls []string, a string) bool

func ArrayStringSet

func ArrayStringSet(ls *[]string, a string) bool

func BytesToHexString

func BytesToHexString(bs []byte) string

func DataUserAuth

func DataUserAuth(uname string, created uint32) []byte

func DataUserAuthDeny

func DataUserAuthDeny(uname, remote_ip string) []byte

func Hash32

func Hash32(v string) uint32

func HexStringToBytes

func HexStringToBytes(s string) []byte

func NsAccessKey

func NsAccessKey(uname, id string) []byte

func ObjKeyAccChargeMgr

func ObjKeyAccChargeMgr(id string) []byte

func ObjKeyAccChargeUser

func ObjKeyAccChargeUser(uname, id string) []byte

func ObjKeyAccFundMgr

func ObjKeyAccFundMgr(id string) []byte

func ObjKeyAccFundUser

func ObjKeyAccFundUser(uname, id string) []byte

func ObjKeyAccUser

func ObjKeyAccUser(uname string) []byte

func ObjKeyAppInstance

func ObjKeyAppInstance(key string) []byte

func ObjKeyMsgQueue

func ObjKeyMsgQueue(id string) []byte

func ObjKeyMsgSent

func ObjKeyMsgSent(id string) []byte

func ObjKeyPasswordReset

func ObjKeyPasswordReset(id string) []byte

func ObjKeyRole

func ObjKeyRole(name string) []byte

func ObjKeyRolePrivilege

func ObjKeyRolePrivilege(rid uint32, appid string) []byte

func ObjKeySysConfig

func ObjKeySysConfig(name string) []byte

func ObjKeyUser

func ObjKeyUser(uname string) []byte

func ObjKeyUserAuth

func ObjKeyUserAuth(uname string, created uint32) []byte

func ObjKeyUserAuthDeny

func ObjKeyUserAuthDeny(uname, remote_ip string) []byte

func ObjKeyUserProfile

func ObjKeyUserProfile(uname string) []byte

func OpActionAllow

func OpActionAllow(opbase, op uint32) bool

func OpActionAppend

func OpActionAppend(opbase, op uint32) uint32

func OpActionRemove

func OpActionRemove(opbase, op uint32) uint32

func PrevDataMsgQueue

func PrevDataMsgQueue(id string) []byte

func PrevDataMsgSent

func PrevDataMsgSent(id string) []byte

func ServiceRedirectTokenValid

func ServiceRedirectTokenValid(tokenstr string) bool

func Uint32ToBytes

func Uint32ToBytes(v uint32) []byte

func Uint32ToHexString

func Uint32ToHexString(v uint32) string

func Uint64ToBytes

func Uint64ToBytes(v uint64) []byte

func Uint64ToHexString

func Uint64ToHexString(v uint64) string

func UserId

func UserId(name string) string

func UserIdBytes

func UserIdBytes(name string) []byte

func UserNameFilter

func UserNameFilter(name string) string

func UserNameValid

func UserNameValid(user string) error

Types

type AccessKeyAuth

type AccessKeyAuth struct {
	Type  string `json:"t" toml:"t"`
	User  string `json:"u" toml:"u"`
	Key   string `json:"k" toml:"k"`
	Time  int64  `json:"rt" toml:"rt"`
	Token string `json:"tk" toml:"tk"`
}

func AccessKeyAuthDecode

func AccessKeyAuthDecode(auth string) (AccessKeyAuth, error)

func (AccessKeyAuth) Encode

func (t AccessKeyAuth) Encode() string

func (AccessKeyAuth) Valid

func (t AccessKeyAuth) Valid() error

type AccessKeyBound

type AccessKeyBound struct {
	Name    string         `json:"name" toml:"name"`
	Created types.MetaTime `json:"created,omitempty" toml:"created,omitempty"`
}

func (AccessKeyBound) IterKey

func (it AccessKeyBound) IterKey() string

type AccessKeyBounds

type AccessKeyBounds []AccessKeyBound

type AccessKeyDep

type AccessKeyDep struct {
	User        string           `json:"user,omitempty" toml:"user,omitempty"`
	AccessKey   string           `json:"access_key" toml:"access_key"`
	SecretKey   string           `json:"secret_key,omitempty" toml:"secret_key,omitempty"`
	Created     types.MetaTime   `json:"created,omitempty" toml:"created,omitempty"`
	Action      uint16           `json:"action,omitempty" toml:"action,omitempty"`
	Description string           `json:"desc,omitempty" toml:"desc,omitempty"`
	Bounds      []AccessKeyBound `json:"bounds,omitempty" toml:"bounds,omitempty"`
}

type AccessKeySession

type AccessKeySession struct {
	AccessKey string            `json:"ak" toml:"ak"`
	SecretKey string            `json:"sk" toml:"sk"`
	User      string            `json:"ur" toml:"ur"`
	Roles     types.ArrayUint32 `json:"rs" toml:"rs"`
	Expired   int64             `json:"ex" toml:"ex"` // unix seconds
}

Access Key SESSION K1(2)VERIFY-SIGNATURE(36)PAYLOAD-DATA

type AccountCharge

type AccountCharge struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Id             string               `json:"id" toml:"id"`
	Fund           string               `json:"fund" toml:"fund"`
	User           string               `json:"user" toml:"user"`
	Product        types.NameIdentifier `json:"product" toml:"product"`
	Prepay         float64              `json:"prepay" toml:"prepay"`
	Payout         float64              `json:"payout" toml:"payout"`
	TimeStart      uint32               `json:"time_start" toml:"time_start"`
	TimeClose      uint32               `json:"time_close" toml:"time_close"`
	Created        types.MetaTime       `json:"created" toml:"created"`
	Updated        types.MetaTime       `json:"updated" toml:"updated"`
	Comment        string               `json:"comment,omitempty" toml:"comment,omitempty"`
}

iam/acc_charge/user-id/hash-id iam/acc_charge_mgr/hash-id

type AccountChargePayout

type AccountChargePayout struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Id             string               `json:"id" toml:"id"`
	User           string               `json:"user" toml:"user"`
	Product        types.NameIdentifier `json:"product" toml:"product"`
	Payout         float64              `json:"payout" toml:"payout"`
	TimeStart      uint32               `json:"time_start" toml:"time_start"`
	TimeClose      uint32               `json:"time_close" toml:"time_close"`
	Comment        string               `json:"comment,omitempty" toml:"comment,omitempty"`
}

func (*AccountChargePayout) Valid

func (this *AccountChargePayout) Valid() error

type AccountChargePrepay

type AccountChargePrepay struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	User           string               `json:"user" toml:"user"`
	Product        types.NameIdentifier `json:"product" toml:"product"`
	Prepay         float64              `json:"prepay" toml:"prepay"`
	TimeStart      uint32               `json:"time_start" toml:"time_start"`
	TimeClose      uint32               `json:"time_close" toml:"time_close"`
	Comment        string               `json:"comment,omitempty" toml:"comment,omitempty"`
}

func (*AccountChargePrepay) Valid

func (this *AccountChargePrepay) Valid() error

type AccountCurrencyOption

type AccountCurrencyOption struct {
	Name  string       `json:"name" toml:"name"`
	Items types.Labels `json:"items,omitempty" toml:"items,omitempty"`
}

type AccountFund

type AccountFund struct {
	Id               string                    `json:"id" toml:"id"`
	Type             uint8                     `json:"type" toml:"type"`
	User             string                    `json:"user" toml:"user"`
	Operator         string                    `json:"operator,omitempty" toml:"operator,omitempty"`
	CashType         uint16                    `json:"cash_type,omitempty" toml:"cash_type,omitempty"`
	CashAmount       float32                   `json:"cash_amount,omitempty" toml:"cash_amount,omitempty"`
	Amount           float64                   `json:"amount" toml:"amount"`
	Prepay           float64                   `json:"prepay" toml:"prepay"`
	Payout           float64                   `json:"payout" toml:"payout"`
	Priority         uint8                     `json:"priority" toml:"priority"`
	Options          types.Labels              `json:"options,emitempty" toml:"options,emitempty"`
	Created          types.MetaTime            `json:"created" toml:"created"`
	Updated          types.MetaTime            `json:"updated" toml:"updated"`
	Comment          string                    `json:"comment,omitempty" toml:"comment,omitempty"`
	ExpProductLimits types.ArrayNameIdentifier `json:"exp_product_limits,omitempty" toml:"exp_product_limits,omitempty"`
	ExpProductMax    int                       `json:"exp_product_max,omitempty" toml:"exp_product_max,omitempty"`
	ExpProductInpay  types.ArrayNameIdentifier `json:"exp_product_inpay,omitempty" toml:"exp_product_inpay,omitempty"`
}

iam/acc_fund/user-id/rand-id iam/acc_fund_mgr/rand-id

type AccountUser

type AccountUser struct {
	User    string         `json:"user" toml:"user"`
	Balance float64        `json:"balance" toml:"balance"`
	Prepay  float64        `json:"prepay" toml:"prepay"`
	Updated types.MetaTime `json:"updated" toml:"updated"`
}

iam/acc_user/user-id

type AppAuthInfo

type AppAuthInfo struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	InstanceID     string `json:"instance_id" toml:"instance_id"`
	AppID          string `json:"app_id" toml:"app_id"`
}

type AppInstance

type AppInstance struct {
	Meta       types.InnerObjectMeta `json:"meta,omitempty" toml:"meta,omitempty"`
	AppID      string                `json:"app_id,omitempty" toml:"app_id,omitempty"`
	AppTitle   string                `json:"app_title,omitempty" toml:"app_title,omitempty"`
	Version    string                `json:"version,omitempty" toml:"version,omitempty"`
	Status     uint8                 `json:"status,omitempty" toml:"status,omitempty"`
	Url        string                `json:"url,omitempty" toml:"url,omitempty"`
	Privileges []AppPrivilege        `json:"privileges,omitempty" toml:"privileges,omitempty"`
	SecretKey  string                `json:"secret_key,omitempty" toml:"secret_key,omitempty"`
}

type AppInstanceList

type AppInstanceList struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Meta           types.ListMeta `json:"meta,omitempty" toml:"meta,omitempty"`
	Items          []AppInstance  `json:"items,omitempty" toml:"items,omitempty"`
}

type AppInstanceRegister

type AppInstanceRegister struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	AccessToken    string      `json:"access_token,omitempty" toml:"access_token,omitempty"`
	Instance       AppInstance `json:"instance" toml:"instance"`
}

type AppPrivilege

type AppPrivilege struct {
	// ID        uint32   `json:"id,omitempty" toml:"id,omitempty"`
	Privilege string            `json:"privilege" toml:"privilege"`
	Desc      string            `json:"desc,omitempty" toml:"desc,omitempty"`
	Roles     types.ArrayUint32 `json:"roles,omitempty" toml:"roles,omitempty"`
}

type ServiceLoginAuth

type ServiceLoginAuth struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	RedirectUri    string `json:"redirect_uri,omitempty" toml:"redirect_uri,omitempty"`
	AccessToken    string `json:"access_token,omitempty" toml:"access_token,omitempty"`
}

type ServiceRedirectToken

type ServiceRedirectToken struct {
	RedirectUri string `json:"uri,omitempty" toml:"uri,omitempty"`
	State       string `json:"state,omitempty" toml:"state,omitempty"`
	ClientId    string `json:"cid,omitempty" toml:"cid,omitempty"`
	Persistent  int    `json:"pt,omitempty" toml:"pt,omitempty"`
}

func ServiceRedirectTokenDecode

func ServiceRedirectTokenDecode(tokenstr string) ServiceRedirectToken

func (*ServiceRedirectToken) Encode

func (s *ServiceRedirectToken) Encode() string

type SysConfigList

type SysConfigList struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Items          types.Labels `json:"items,omitempty" toml:"items,omitempty"`
}

type SysConfigMailer

type SysConfigMailer struct {
	SmtpHost string `json:"smtp_host" toml:"smtp_host"`
	SmtpPort string `json:"smtp_port" toml:"smtp_port"`
	SmtpUser string `json:"smtp_user" toml:"smtp_user"`
	SmtpPass string `json:"smtp_pass" toml:"smtp_pass"`
}

type User

type User struct {
	// Id          string            `json:"id,omitempty" toml:"id,omitempty"`
	Name        string            `json:"name" toml:"name"`
	Email       string            `json:"email,omitempty" toml:"email,omitempty"`
	DisplayName string            `json:"display_name,omitempty" toml:"display_name,omitempty"`
	Keys        types.KvPairs     `json:"keys,omitempty" toml:"keys,omitempty"`
	Roles       types.ArrayUint32 `json:"roles,omitempty" toml:"roles,omitempty"`
	Type        uint32            `json:"type,omitempty" toml:"type,omitempty"`
	Owners      []string          `json:"owners,omitempty" toml:"owners,omitempty"`
	Members     []string          `json:"members,omitempty" toml:"members,omitempty"`
	Status      uint8             `json:"status,omitempty" toml:"status,omitempty"`
	Created     types.MetaTime    `json:"created,omitempty" toml:"created,omitempty"`
	Updated     types.MetaTime    `json:"updated,omitempty" toml:"updated,omitempty"`
}

type UserAccessEntry

type UserAccessEntry struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	AccessToken    string `json:"access_token" toml:"access_token"`
	Privilege      string `json:"privilege" toml:"privilege"`
	InstanceID     string `json:"instance_id,omitempty" toml:"instance_id,omitempty"`
}

type UserEmailSet

type UserEmailSet struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Auth           string `json:"auth,omitempty" toml:"auth,omitempty"`
	Email          string `json:"email,omitempty" toml:"email,omitempty"`
}

type UserEntry

type UserEntry struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Login          User         `json:"login,omitempty" toml:"login,omitempty"`
	Profile        *UserProfile `json:"profile,omitempty" toml:"profile,omitempty"`
}

type UserGroupItem

type UserGroupItem struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Name           string         `json:"name" toml:"name"`
	DisplayName    string         `json:"display_name,omitempty" toml:"display_name,omitempty"`
	Owners         []string       `json:"owners,omitempty" toml:"owners,omitempty"`
	Members        []string       `json:"members,omitempty" toml:"members,omitempty"`
	Status         uint8          `json:"status" toml:"status"`
	Created        types.MetaTime `json:"created" toml:"created"`
	Updated        types.MetaTime `json:"updated" toml:"updated"`
}

type UserGroupList

type UserGroupList struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Items          []*UserGroupItem `json:"items,omitempty" toml:"items,omitempty"`
}

type UserList

type UserList struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Meta           types.ListMeta `json:"meta,omitempty" toml:"meta,omitempty"`
	Items          []User         `json:"items,omitempty" toml:"items,omitempty"`
}

type UserPasswordReset

type UserPasswordReset struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Id             string `json:"id,omitempty" toml:"id,omitempty"`
	UserName       string `json:"username,omitempty" toml:"username,omitempty"`
	Email          string `json:"email,omitempty" toml:"email,omitempty"`
	Expired        string `json:"expired,omitempty" toml:"expired,omitempty"`
}

type UserPasswordSet

type UserPasswordSet struct {
	types.TypeMeta  `json:",inline" toml:",inline"`
	CurrentPassword string `json:"current_password,omitempty" toml:"current_password,omitempty"`
	NewPassword     string `json:"new_password,omitempty" toml:"new_password,omitempty"`
}

type UserPhotoSet

type UserPhotoSet struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Name           string `json:"name,omitempty" toml:"name,omitempty"`
	Size           int    `json:"size,omitempty" toml:"size,omitempty"`
	Data           string `json:"data,omitempty" toml:"data,omitempty"`
}

type UserPrivilege

type UserPrivilege struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Meta           types.InnerObjectMeta `json:"meta,omitempty" toml:"meta,omitempty"`
	Instance       string                `json:"instance" toml:"instance"`
	Desc           string                `json:"desc,omitempty" toml:"desc,omitempty"`
}

type UserPrivilegeList

type UserPrivilegeList struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Items          []UserPrivilege `json:"items,omitempty" toml:"items,omitempty"`
}

type UserProfile

type UserProfile struct {
	Login       *User          `json:"login,omitempty" toml:"login,omitempty"`
	Gender      uint8          `json:"gender,omitempty" toml:"gender,omitempty"`
	Photo       string         `json:"photo,omitempty" toml:"photo,omitempty"`
	PhotoSource string         `json:"photo_source,omitempty" toml:"photo_source,omitempty"`
	Birthday    string         `json:"birthday,omitempty" toml:"birthday,omitempty"`
	About       string         `json:"about,omitempty" toml:"about,omitempty"`
	Updated     types.MetaTime `json:"updated,omitempty" toml:"updated,omitempty"`
}

type UserRole

type UserRole struct {
	Id         uint32         `json:"id" toml:"id"`
	Name       string         `json:"name" toml:"name"`
	User       string         `json:"user,omitempty" toml:"user,omitempty"`
	Status     uint8          `json:"status,omitempty" toml:"status,omitempty"`
	Desc       string         `json:"desc,omitempty" toml:"desc,omitempty"`
	Privileges []string       `json:"privileges,omitempty" toml:"privileges,omitempty"`
	Created    types.MetaTime `json:"created,omitempty" toml:"created,omitempty"`
	Updated    types.MetaTime `json:"updated,omitempty" toml:"updated,omitempty"`
}

type UserRoleList

type UserRoleList struct {
	types.TypeMeta `json:",inline" toml:",inline"`
	Items          []UserRole `json:"items,omitempty" toml:"items,omitempty"`
}

type UserSession

type UserSession struct {
	AccessToken  string            `json:"access_token" toml:"access_token"`
	RefreshToken string            `json:"refresh_token,omitempty" toml:"refresh_token,omitempty"`
	UserName     string            `json:"username" toml:"username"`
	DisplayName  string            `json:"display_name,omitempty" toml:"display_name,omitempty"`
	Roles        types.ArrayUint32 `json:"roles,omitempty" toml:"roles,omitempty"`
	Groups       []string          `json:"groups,omitempty" toml:"groups,omitempty"`
	ClientAddr   string            `json:"client_addr,omitempty" toml:"client_addr,omitempty"`
	Created      int64             `json:"created" toml:"created"`
	Expired      int64             `json:"expired" toml:"expired"`
	Cached       int64             `json:"cached,omitempty" toml:"cached,omitempty"`
}

func (*UserSession) AccessAllow

func (s *UserSession) AccessAllow(name string) bool

func (*UserSession) IsLogin

func (s *UserSession) IsLogin() bool

func (*UserSession) UserId

func (s *UserSession) UserId() string

type WebServiceKind

type WebServiceKind struct {
	Kind  string           `json:"kind" toml:"kind"`
	Error *types.ErrorMeta `json:"error,omitempty" toml:"error,omitempty"`
	Data  proto.Message    `json:"data,omitempty" toml:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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