实现用户审核功能

This commit is contained in:
GoEdgeLab
2022-01-05 10:44:58 +08:00
parent e9066d8da0
commit 052efe697d
7 changed files with 882 additions and 461 deletions

View File

@@ -39,6 +39,10 @@ type User struct {
Remark string `protobuf:"bytes,7,opt,name=remark,proto3" json:"remark,omitempty"`
IsOn bool `protobuf:"varint,8,opt,name=isOn,proto3" json:"isOn,omitempty"`
CreatedAt int64 `protobuf:"varint,9,opt,name=createdAt,proto3" json:"createdAt,omitempty"`
RegisteredIP string `protobuf:"bytes,12,opt,name=registeredIP,proto3" json:"registeredIP,omitempty"`
IsVerified bool `protobuf:"varint,13,opt,name=isVerified,proto3" json:"isVerified,omitempty"`
IsRejected bool `protobuf:"varint,14,opt,name=isRejected,proto3" json:"isRejected,omitempty"`
RejectReason string `protobuf:"bytes,15,opt,name=rejectReason,proto3" json:"rejectReason,omitempty"`
NodeCluster *NodeCluster `protobuf:"bytes,10,opt,name=nodeCluster,proto3" json:"nodeCluster,omitempty"`
Features []*UserFeature `protobuf:"bytes,11,rep,name=features,proto3" json:"features,omitempty"`
}
@@ -138,6 +142,34 @@ func (x *User) GetCreatedAt() int64 {
return 0
}
func (x *User) GetRegisteredIP() string {
if x != nil {
return x.RegisteredIP
}
return ""
}
func (x *User) GetIsVerified() bool {
if x != nil {
return x.IsVerified
}
return false
}
func (x *User) GetIsRejected() bool {
if x != nil {
return x.IsRejected
}
return false
}
func (x *User) GetRejectReason() string {
if x != nil {
return x.RejectReason
}
return ""
}
func (x *User) GetNodeCluster() *NodeCluster {
if x != nil {
return x.NodeCluster
@@ -161,7 +193,7 @@ var file_models_model_user_proto_rawDesc = []byte{
0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f,
0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x75, 0x73, 0x65,
0x72, 0x5f, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0xb8, 0x02, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
0xc0, 0x03, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72,
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x75, 0x6c, 0x6c, 0x6e, 0x61, 0x6d, 0x65,
@@ -174,14 +206,23 @@ var file_models_model_user_proto_rawDesc = []byte{
0x52, 0x06, 0x72, 0x65, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x73, 0x4f, 0x6e,
0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x69, 0x73, 0x4f, 0x6e, 0x12, 0x1c, 0x0a, 0x09,
0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52,
0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x31, 0x0a, 0x0b, 0x6e, 0x6f,
0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72,
0x52, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x2b, 0x0a,
0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65,
0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65,
0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x65, 0x64, 0x49, 0x50, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0c, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x65, 0x64, 0x49, 0x50, 0x12, 0x1e,
0x0a, 0x0a, 0x69, 0x73, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x18, 0x0d, 0x20, 0x01,
0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x56, 0x65, 0x72, 0x69, 0x66, 0x69, 0x65, 0x64, 0x12, 0x1e,
0x0a, 0x0a, 0x69, 0x73, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x0e, 0x20, 0x01,
0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x52, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x22,
0x0a, 0x0c, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x0f,
0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x61, 0x73,
0x6f, 0x6e, 0x12, 0x31, 0x0a, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65,
0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64,
0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x0b, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c,
0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65,
0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x73, 0x65,
0x72, 0x46, 0x65, 0x61, 0x74, 0x75, 0x72, 0x65, 0x52, 0x08, 0x66, 0x65, 0x61, 0x74, 0x75, 0x72,
0x65, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (

File diff suppressed because it is too large Load Diff

View File

@@ -16,6 +16,11 @@ message User {
string remark = 7;
bool isOn = 8;
int64 createdAt = 9;
string registeredIP = 12;
bool isVerified = 13;
bool isRejected = 14;
string rejectReason = 15;
NodeCluster nodeCluster = 10;
repeated UserFeature features = 11;
}

View File

@@ -13,6 +13,12 @@ service UserService {
// 创建用户
rpc createUser (CreateUserRequest) returns (CreateUserResponse);
// 注册用户
rpc registerUser(RegisterUserRequest) returns (RPCSuccess);
// 审核用户
rpc verifyUser(VerifyUserRequest) returns (RPCSuccess);
// 修改用户
rpc updateUser (UpdateUserRequest) returns (RPCSuccess);
@@ -76,6 +82,24 @@ message CreateUserResponse {
int64 userId = 1;
}
// 注册用户
message RegisterUserRequest {
string username = 1;
string password = 2;
string mobile = 3;
string email = 4;
string fullname = 5;
string ip = 6;
string source = 7;
}
// 审核用户
message VerifyUserRequest {
int64 userId = 1;
bool isRejected = 2;
string rejectReason = 3;
}
// 修改用户
message UpdateUserRequest {
int64 userId = 1;
@@ -146,6 +170,8 @@ message LoginUserResponse {
message UpdateUserInfoRequest {
int64 userId = 1;
string fullname = 2;
string mobile = 3;
string email = 4;
}
// 修改用户登录信息

View File

@@ -12,6 +12,9 @@ const (
SettingCodeAccessLogQueue SettingCode = "accessLogQueue" // 访问日志队列
SettingCodeCheckUpdates SettingCode = "checkUpdates" // 检查自动更新配置
SettingCodeUserUIConfig SettingCode = "userUIConfig" // 用户界面配置
SettingCodeUserRegisterConfig SettingCode = "userRegisterConfig" // 用户注册配置
SettingCodeNSAccessLogSetting SettingCode = "nsAccessLogSetting" // NS相关全局配置
SettingCodeNSNodeMonitor SettingCode = "nsNodeMonitor" // 监控NS节点状态

View File

@@ -11,6 +11,9 @@ const (
UserFeatureCodeServerAccessLog UserFeatureCode = "server.accessLog"
UserFeatureCodeServerViewAccessLog UserFeatureCode = "server.viewAccessLog"
UserFeatureCodePlan UserFeatureCode = "plan"
UserFeatureCodeScript UserFeatureCode = "script"
UserFeatureCodeServerWAF UserFeatureCode = "server.waf"
UserFeatureCodeFinance UserFeatureCode = "finance"
)
// UserFeature 用户功能
@@ -64,12 +67,12 @@ func FindAllUserFeatures() []*UserFeature {
},
{
Name: "开启WAF",
Code: "server.waf",
Code: UserFeatureCodeServerWAF,
Description: "用户可以开启WAF功能并可以设置黑白名单等",
},
{
Name: "费用账单",
Code: "finance",
Code: UserFeatureCodeFinance,
Description: "开启费用账单相关功能",
},
{
@@ -77,6 +80,11 @@ func FindAllUserFeatures() []*UserFeature {
Code: UserFeatureCodePlan,
Description: "用户可以购买和管理套餐",
},
{
Name: "边缘脚本",
Code: UserFeatureCodeScript,
Description: "用户可以在使用边缘脚本过滤请求",
},
}
}

View File

@@ -0,0 +1,27 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package userconfigs
type UserRegisterConfig struct {
IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用用户注册
ClusterId int64 `yaml:"clusterId" json:"clusterId"` // 用户创建服务集群
ServerGroupIds []int64 `yaml:"serverGroupIds" json:"serverGroupIds"` // 用户注册的服务所在分组
ComplexPassword bool `yaml:"complexPassword" json:"complexPassword"` // 必须使用复杂密码
Features []string `yaml:"features" json:"features"` // 默认启用的功能
RequireVerification bool `yaml:"requireVerification" json:"requireVerification"` // 是否需要审核
}
func DefaultUserRegisterConfig() *UserRegisterConfig {
return &UserRegisterConfig{
IsOn: false,
ComplexPassword: true,
Features: []string{
UserFeatureCodeServerAccessLog,
UserFeatureCodeServerViewAccessLog,
UserFeatureCodeServerWAF,
UserFeatureCodeFinance,
UserFeatureCodePlan,
},
RequireVerification: false,
}
}