Skip to content

Commit

Permalink
feat: 分离sts模块,实现auth (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lansongxx authored Dec 28, 2023
1 parent e2dda5a commit 3324b35
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 36 deletions.
19 changes: 19 additions & 0 deletions cloudmind/core_api/user.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
syntax = "proto3";
package cloudmind.core_api;
option go_package = "cloudmind/core_api";
import "cloudmind/user/common.proto";
import "basic/pagination.proto";

message SearchUserReq{
oneof searchOption {
string name = 1;
string userId = 2;
}
optional basic.PaginationOptions paginationOptions = 3;
}

message SearchUserResp{
repeated user.User users = 1;
int32 total = 2;
}

99 changes: 99 additions & 0 deletions cloudmind/sts/auth.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
syntax = "proto3";
package cloudmind.sts;
option go_package = "cloudmind/sts";

message Auth {
string id = 1;
int32 type = 2;
string key = 3;
string userId = 4;
int32 role = 5;
string Password = 6;
}

enum AuthType {
UnKnown = 0;
email = 1;
qq = 2;
wechat = 3;
}
message EmailOptions {
string email = 1;
string code = 2;
}

message UserIdOptions{
string userId = 1;
string password = 2;
}


message Point {
int32 x = 1;
int32 y = 2;
}

message SendEmailReq {
string email = 1;
string subject = 2;
}

message SendEmailResp {
string error = 2;
}

message CreateCaptchaReq{
}

message CreateCaptchaResp{
string originalImageBase64 = 1;
string jigsawImageBase64 = 2;
string key = 3;
string error = 4;
}

message CheckCaptchaReq{
Point point = 1;
string key = 2;
}

message CheckCaptchaResp{
string error = 1;
}

message SetPasswordReq{
oneof Key {
UserIdOptions userIdOptions = 1;
EmailOptions emailOptions = 2;
}
string password = 3;
}
message SetPasswordResp{
string error = 1;
}

message CheckEmailReq{
string email = 1;
string code = 2;
}

message CheckEmailResp{
string error = 1;
}

message AddAuthReq{
Auth auth = 1;
}

message AddAuthResp{
string error = 1;
}

service StsService {
rpc CreateCaptcha(CreateCaptchaReq) returns(CreateCaptchaResp);
rpc CheckCaptcha(CheckCaptchaReq) returns(CheckCaptchaResp);
rpc SetPassword(SetPasswordReq) returns(SetPasswordResp);
rpc SendEmail(SendEmailReq) returns(SendEmailResp);
rpc CheckEmail(CheckEmailReq) returns(CheckEmailResp);
rpc AddAuth(AddAuthReq) returns(AddAuthResp);
}
22 changes: 22 additions & 0 deletions cloudmind/user/common.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";
package cloudmind.user;
option go_package = "cloudmind/user";

message User {
string userId = 1;
string name = 2;
string url = 3;
}

message UserDetail {
string userId = 1;
string email = 2;
string name = 3;
int32 sex = 4;
string fullName = 5;
string idCard = 6;
int64 createdAt = 7;
int64 updatedAt = 8;
string description = 9;
string url = 10;
}
48 changes: 12 additions & 36 deletions cloudmind/user/user.proto
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
syntax = "proto3";
package user;
option go_package = "user";
package cloudmind.user;
option go_package = "cloudmind/user";

import "basic/pagination.proto";
import "cloudmind/user/common.proto";

enum Sex {
UnKnown = 0; // 未知
Expand All @@ -14,33 +15,6 @@ message Point {
int32 x = 1;
int32 y = 2;
}
message Token {
string accessToken = 1; // 用户ID
string refreshToken = 2; // 用户ID
string chatToken = 3; // 用户ID
}

message UserDetail {
string userId = 1;
string email = 2;
string name = 3;
int32 sex = 4;
string fullName = 5;
string idCard = 6;
int64 createdAt = 7;
int64 updatedAt = 8;
int64 money = 9;
int64 flow = 10;
int64 memory = 11;
string description = 12;
string url = 13;
}

message User {
string userId = 1;
string name = 2;
string url = 3;
}

message SendEmailReq {
string email = 1;
Expand All @@ -53,7 +27,6 @@ message SendEmailResp {

message UpdateUserReq{
UserDetail user = 1;
string Code = 2; // 邮箱验证码 修改邮箱号需要填邮箱验证码
}
message UpdateUserResp{
string error = 1;
Expand Down Expand Up @@ -97,7 +70,8 @@ message SearchUserReq{
message SearchUserResp{
repeated User users = 1;
int32 total = 2;
string error = 3;
string lastToken = 3;
string error = 4;
}

message CreateUserReq{
Expand All @@ -109,22 +83,24 @@ message CreateUserResp{
}

message GetUserDetailReq{
oneof UserKey {
string userId = 1;
string email = 2;
}
}

message GetUserDetailResp {
UserDetail user = 1;
string Error = 2;
}

service UserService {
// 用户
rpc UpdateUser(UpdateUserReq) returns(UpdateUserResp);
rpc GetUser(GetUserReq) returns(GetUserResp);
rpc GetUserDetail(GetUserDetailReq) returns(GetUserDetailResp);
rpc GetCaptcha(GetCaptchaReq) returns(GetCaptchaResp);
rpc CreateCaptcha(CreateCaptchaReq) returns(CreateCaptchaResp);
rpc SearchUser(SearchUserReq) returns(SearchUserResp);
rpc CreateUser(CreateUserReq) returns(CreateUserResp);
// // 鉴权
// rpc GetCaptcha(GetCaptchaReq) returns(GetCaptchaResp);
// rpc CreateCaptcha(CreateCaptchaReq) returns(CreateCaptchaResp);
// rpc SetPassWord(SetPassWordReq) returns(SetPassWordResp);

}

0 comments on commit 3324b35

Please sign in to comment.