/
data.go
139 lines (115 loc) · 4 KB
/
data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
// Copyright 2014 Eryx <evorui аt gmаil dοt cοm>, All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package iamapi
import (
"github.com/lynkdb/iomix/utils"
)
const (
dataPrefix = "iam"
dataAppInstance = "ai" // kv2
dataUser = "u" // kv2
dataUserAuth = "ua" // skip
dataUserAuthDeny = "uad" // skip
dataPassReset = "pr" // skip
dataAccessKey = "ak2" // hauth
dataRole = "r" // skip
dataRolePrivilege = "rp" // skip
dataUserProfile = "up" // kv2
dataAccUser = "au" // kv2
dataAccFundUser = "af" // kv2
dataAccFundMgr = "afm" // kv2
dataAccChargeUser = "ac" // kv2
dataAccChargeMgr = "acm" // kv2
dataSysConfig = "sc" // kv2
dataMsgQueue = "mq" // kv2
dataMsgSent = "ms" // kv2
)
func ObjKeyAppInstance(key string) []byte {
return []byte(dataPrefix + ":" + dataAppInstance + ":" + key)
}
func ObjKeyUser(uname string) []byte {
return []byte(dataPrefix + ":" + dataUser + ":" +
UserNameFilter(uname))
}
func ObjKeyUserProfile(uname string) []byte {
return []byte(dataPrefix + ":" + dataUserProfile + ":" +
UserNameFilter(uname))
}
func ObjKeyPasswordReset(id string) []byte {
return []byte(dataPrefix + ":" + dataPassReset + ":" + id)
}
func DataUserAuthDeny(uname, remote_ip string) []byte {
return []byte(dataPrefix + ":" + dataUserAuthDeny + ":" +
uname + ":" + remote_ip)
}
func ObjKeyUserAuthDeny(uname, remote_ip string) []byte {
return []byte(dataPrefix + ":" + dataUserAuthDeny + ":" +
UserNameFilter(uname) + ":" + remote_ip)
}
func DataUserAuth(uname string, created uint32) []byte {
return []byte(dataPrefix + ":" + dataUserAuth + ":" +
uname + ":" + utils.Uint32ToHexString(created))
}
func ObjKeyUserAuth(uname string, created uint32) []byte {
return []byte(dataPrefix + ":" + dataUserAuth + ":" +
UserNameFilter(uname) + ":" + utils.Uint32ToHexString(created))
}
func NsAccessKey(uname, id string) []byte {
if uname == "" {
return []byte(dataPrefix + ":" + dataAccessKey + ":")
}
return []byte(dataPrefix + ":" + dataAccessKey + ":" +
UserNameFilter(uname) + ":" + id)
}
func ObjKeySysConfig(name string) []byte {
return []byte(dataPrefix + ":" + dataSysConfig + ":" + name)
}
func ObjKeyAccUser(uname string) []byte {
return []byte(dataPrefix + ":" + dataAccUser + ":" +
UserNameFilter(uname))
}
func ObjKeyAccFundUser(uname, id string) []byte {
return []byte(dataPrefix + ":" + dataAccFundUser + ":" +
UserNameFilter(uname) + ":" + id)
}
func ObjKeyAccFundMgr(id string) []byte {
return []byte(dataPrefix + ":" + dataAccFundMgr + ":" + id)
}
func ObjKeyAccChargeUser(uname, id string) []byte {
return []byte(dataPrefix + ":" + dataAccChargeUser + ":" +
UserNameFilter(uname) + ":" + id)
}
func ObjKeyAccChargeMgr(id string) []byte {
return []byte(dataPrefix + ":" + dataAccChargeMgr + ":" + id)
}
func PrevDataMsgQueue(id string) []byte {
return []byte(dataPrefix + ":" + dataMsgQueue + ":" + id)
}
func PrevDataMsgSent(id string) []byte {
return []byte(dataPrefix + ":" + dataMsgSent + ":" + id)
}
func ObjKeyRole(name string) []byte {
return []byte(dataPrefix + ":" + dataRole + ":" +
UserNameFilter(name))
}
func ObjKeyRolePrivilege(rid uint32, appid string) []byte {
return []byte(dataPrefix + ":" + dataRolePrivilege + ":" +
utils.Uint32ToHexString(rid) + ":" + appid)
}
func ObjKeyMsgQueue(id string) []byte {
return []byte(dataPrefix + ":" + dataMsgQueue + ":" + id)
}
func ObjKeyMsgSent(id string) []byte {
return []byte(dataPrefix + ":" + dataMsgSent + ":" + id)
}