From 741fe35c2aa5fc312a42f5b89a7007f37701dabf Mon Sep 17 00:00:00 2001 From: Johnny Date: Sat, 21 Jun 2025 00:00:58 +0800 Subject: [PATCH] refactor: rename session methods in auth service --- proto/api/v1/auth_service.proto | 36 +-- proto/gen/api/v1/activity_service.pb.gw.go | 8 +- proto/gen/api/v1/attachment_service.pb.gw.go | 22 +- proto/gen/api/v1/auth_service.pb.go | 166 +++++----- proto/gen/api/v1/auth_service.pb.gw.go | 124 ++++---- proto/gen/api/v1/auth_service_grpc.pb.go | 100 +++--- proto/gen/api/v1/idp_service.pb.gw.go | 18 +- proto/gen/api/v1/inbox_service.pb.gw.go | 11 +- proto/gen/api/v1/markdown_service.pb.gw.go | 13 +- proto/gen/api/v1/memo_service.pb.gw.go | 61 +++- proto/gen/api/v1/shortcut_service.pb.gw.go | 18 +- proto/gen/api/v1/user_service.pb.gw.go | 52 ++- proto/gen/api/v1/webhook_service.pb.gw.go | 18 +- proto/gen/api/v1/workspace_service.pb.gw.go | 11 +- proto/gen/apidocs.swagger.yaml | 63 ++-- proto/gen/store/user_setting.pb.go | 316 +++++++++++++++++-- proto/store/user_setting.proto | 37 +++ server/router/api/v1/acl_config.go | 4 +- server/router/api/v1/auth_service.go | 4 +- web/src/pages/SignUp.tsx | 2 +- web/src/store/v2/user.ts | 2 +- web/src/types/proto/api/v1/auth_service.ts | 233 +++++++------- 22 files changed, 900 insertions(+), 419 deletions(-) diff --git a/proto/api/v1/auth_service.proto b/proto/api/v1/auth_service.proto index 5a02c5a69..64df3ccb4 100644 --- a/proto/api/v1/auth_service.proto +++ b/proto/api/v1/auth_service.proto @@ -10,10 +10,10 @@ import "google/protobuf/empty.proto"; option go_package = "gen/api/v1"; service AuthService { - // GetAuthStatus returns the current authentication status of the user. - // This method is idempotent and safe, suitable for checking authentication state. - rpc GetAuthStatus(GetAuthStatusRequest) returns (User) { - option (google.api.http) = {get: "/api/v1/auth/status"}; + // GetCurrentSession returns the current active session information. + // This method is idempotent and safe, suitable for checking current session state. + rpc GetCurrentSession(GetCurrentSessionRequest) returns (User) { + option (google.api.http) = {get: "/api/v1/auth/sessions/current"}; } // CreateSession authenticates a user and creates a new session. @@ -25,25 +25,25 @@ service AuthService { }; } - // RegisterUser creates a new user account with username and password. - // Returns the newly created user information upon successful registration. - rpc RegisterUser(RegisterUserRequest) returns (User) { - option (google.api.http) = { - post: "/api/v1/auth/users" - body: "*" - }; - } - // DeleteSession terminates the current user session. // This is an idempotent operation that invalidates the user's authentication. rpc DeleteSession(DeleteSessionRequest) returns (google.protobuf.Empty) { option (google.api.http) = {delete: "/api/v1/auth/sessions/current"}; } + + // SignUp creates a new user account with username and password. + // Returns the newly created user information upon successful registration. + rpc SignUp(SignUpRequest) returns (User) { + option (google.api.http) = { + post: "/api/v1/auth/signup" + body: "*" + }; + } } -message GetAuthStatusRequest {} +message GetCurrentSessionRequest {} -message GetAuthStatusResponse { +message GetCurrentSessionResponse { User user = 1; } @@ -87,7 +87,9 @@ message SSOCredentials { string redirect_uri = 3 [(google.api.field_behavior) = REQUIRED]; } -message RegisterUserRequest { +message DeleteSessionRequest {} + +message SignUpRequest { // The username to sign up with. // Required field that must be unique across the system. string username = 1 [(google.api.field_behavior) = REQUIRED]; @@ -96,5 +98,3 @@ message RegisterUserRequest { // Required field that should meet security requirements. string password = 2 [(google.api.field_behavior) = REQUIRED]; } - -message DeleteSessionRequest {} diff --git a/proto/gen/api/v1/activity_service.pb.gw.go b/proto/gen/api/v1/activity_service.pb.gw.go index cd4e81436..2aba32b20 100644 --- a/proto/gen/api/v1/activity_service.pb.gw.go +++ b/proto/gen/api/v1/activity_service.pb.gw.go @@ -42,7 +42,9 @@ func request_ActivityService_ListActivities_0(ctx context.Context, marshaler run protoReq ListActivitiesRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -74,7 +76,9 @@ func request_ActivityService_GetActivity_0(ctx context.Context, marshaler runtim metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") diff --git a/proto/gen/api/v1/attachment_service.pb.gw.go b/proto/gen/api/v1/attachment_service.pb.gw.go index c4e45204f..d31cc5c93 100644 --- a/proto/gen/api/v1/attachment_service.pb.gw.go +++ b/proto/gen/api/v1/attachment_service.pb.gw.go @@ -45,6 +45,9 @@ func request_AttachmentService_CreateAttachment_0(ctx context.Context, marshaler if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Attachment); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -80,7 +83,9 @@ func request_AttachmentService_ListAttachments_0(ctx context.Context, marshaler protoReq ListAttachmentsRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -112,7 +117,9 @@ func request_AttachmentService_GetAttachment_0(ctx context.Context, marshaler ru metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -151,7 +158,9 @@ func request_AttachmentService_GetAttachmentBinary_0(ctx context.Context, marsha metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -225,6 +234,9 @@ func request_AttachmentService_UpdateAttachment_0(ctx context.Context, marshaler if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Attachment); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Attachment); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) @@ -294,7 +306,9 @@ func request_AttachmentService_DeleteAttachment_0(ctx context.Context, marshaler metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") diff --git a/proto/gen/api/v1/auth_service.pb.go b/proto/gen/api/v1/auth_service.pb.go index f77b83466..f6b897c2b 100644 --- a/proto/gen/api/v1/auth_service.pb.go +++ b/proto/gen/api/v1/auth_service.pb.go @@ -23,26 +23,26 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type GetAuthStatusRequest struct { +type GetCurrentSessionRequest struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *GetAuthStatusRequest) Reset() { - *x = GetAuthStatusRequest{} +func (x *GetCurrentSessionRequest) Reset() { + *x = GetCurrentSessionRequest{} mi := &file_api_v1_auth_service_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetAuthStatusRequest) String() string { +func (x *GetCurrentSessionRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetAuthStatusRequest) ProtoMessage() {} +func (*GetCurrentSessionRequest) ProtoMessage() {} -func (x *GetAuthStatusRequest) ProtoReflect() protoreflect.Message { +func (x *GetCurrentSessionRequest) ProtoReflect() protoreflect.Message { mi := &file_api_v1_auth_service_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -54,32 +54,32 @@ func (x *GetAuthStatusRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetAuthStatusRequest.ProtoReflect.Descriptor instead. -func (*GetAuthStatusRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use GetCurrentSessionRequest.ProtoReflect.Descriptor instead. +func (*GetCurrentSessionRequest) Descriptor() ([]byte, []int) { return file_api_v1_auth_service_proto_rawDescGZIP(), []int{0} } -type GetAuthStatusResponse struct { +type GetCurrentSessionResponse struct { state protoimpl.MessageState `protogen:"open.v1"` User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *GetAuthStatusResponse) Reset() { - *x = GetAuthStatusResponse{} +func (x *GetCurrentSessionResponse) Reset() { + *x = GetCurrentSessionResponse{} mi := &file_api_v1_auth_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetAuthStatusResponse) String() string { +func (x *GetCurrentSessionResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetAuthStatusResponse) ProtoMessage() {} +func (*GetCurrentSessionResponse) ProtoMessage() {} -func (x *GetAuthStatusResponse) ProtoReflect() protoreflect.Message { +func (x *GetCurrentSessionResponse) ProtoReflect() protoreflect.Message { mi := &file_api_v1_auth_service_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -91,12 +91,12 @@ func (x *GetAuthStatusResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetAuthStatusResponse.ProtoReflect.Descriptor instead. -func (*GetAuthStatusResponse) Descriptor() ([]byte, []int) { +// Deprecated: Use GetCurrentSessionResponse.ProtoReflect.Descriptor instead. +func (*GetCurrentSessionResponse) Descriptor() ([]byte, []int) { return file_api_v1_auth_service_proto_rawDescGZIP(), []int{1} } -func (x *GetAuthStatusResponse) GetUser() *User { +func (x *GetCurrentSessionResponse) GetUser() *User { if x != nil { return x.User } @@ -322,32 +322,26 @@ func (x *SSOCredentials) GetRedirectUri() string { return "" } -type RegisterUserRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` - // The username to sign up with. - // Required field that must be unique across the system. - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - // The password to sign up with. - // Required field that should meet security requirements. - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` +type DeleteSessionRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *RegisterUserRequest) Reset() { - *x = RegisterUserRequest{} +func (x *DeleteSessionRequest) Reset() { + *x = DeleteSessionRequest{} mi := &file_api_v1_auth_service_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *RegisterUserRequest) String() string { +func (x *DeleteSessionRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*RegisterUserRequest) ProtoMessage() {} +func (*DeleteSessionRequest) ProtoMessage() {} -func (x *RegisterUserRequest) ProtoReflect() protoreflect.Message { +func (x *DeleteSessionRequest) ProtoReflect() protoreflect.Message { mi := &file_api_v1_auth_service_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -359,45 +353,37 @@ func (x *RegisterUserRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use RegisterUserRequest.ProtoReflect.Descriptor instead. -func (*RegisterUserRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use DeleteSessionRequest.ProtoReflect.Descriptor instead. +func (*DeleteSessionRequest) Descriptor() ([]byte, []int) { return file_api_v1_auth_service_proto_rawDescGZIP(), []int{5} } -func (x *RegisterUserRequest) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *RegisterUserRequest) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -type DeleteSessionRequest struct { - state protoimpl.MessageState `protogen:"open.v1"` +type SignUpRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The username to sign up with. + // Required field that must be unique across the system. + Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` + // The password to sign up with. + // Required field that should meet security requirements. + Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *DeleteSessionRequest) Reset() { - *x = DeleteSessionRequest{} +func (x *SignUpRequest) Reset() { + *x = SignUpRequest{} mi := &file_api_v1_auth_service_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *DeleteSessionRequest) String() string { +func (x *SignUpRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*DeleteSessionRequest) ProtoMessage() {} +func (*SignUpRequest) ProtoMessage() {} -func (x *DeleteSessionRequest) ProtoReflect() protoreflect.Message { +func (x *SignUpRequest) ProtoReflect() protoreflect.Message { mi := &file_api_v1_auth_service_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -409,18 +395,32 @@ func (x *DeleteSessionRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use DeleteSessionRequest.ProtoReflect.Descriptor instead. -func (*DeleteSessionRequest) Descriptor() ([]byte, []int) { +// Deprecated: Use SignUpRequest.ProtoReflect.Descriptor instead. +func (*SignUpRequest) Descriptor() ([]byte, []int) { return file_api_v1_auth_service_proto_rawDescGZIP(), []int{6} } +func (x *SignUpRequest) GetUsername() string { + if x != nil { + return x.Username + } + return "" +} + +func (x *SignUpRequest) GetPassword() string { + if x != nil { + return x.Password + } + return "" +} + var File_api_v1_auth_service_proto protoreflect.FileDescriptor const file_api_v1_auth_service_proto_rawDesc = "" + "\n" + - "\x19api/v1/auth_service.proto\x12\fmemos.api.v1\x1a\x19api/v1/user_service.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x16\n" + - "\x14GetAuthStatusRequest\"?\n" + - "\x15GetAuthStatusResponse\x12&\n" + + "\x19api/v1/auth_service.proto\x12\fmemos.api.v1\x1a\x19api/v1/user_service.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1bgoogle/protobuf/empty.proto\"\x1a\n" + + "\x18GetCurrentSessionRequest\"C\n" + + "\x19GetCurrentSessionResponse\x12&\n" + "\x04user\x18\x01 \x01(\v2\x12.memos.api.v1.UserR\x04user\"\xe9\x01\n" + "\x14CreateSessionRequest\x12V\n" + "\x14password_credentials\x18\x01 \x01(\v2!.memos.api.v1.PasswordCredentialsH\x00R\x13passwordCredentials\x12G\n" + @@ -433,16 +433,16 @@ const file_api_v1_auth_service_proto_rawDesc = "" + "\x0eSSOCredentials\x12\x1a\n" + "\x06idp_id\x18\x01 \x01(\x05B\x03\xe0A\x02R\x05idpId\x12\x17\n" + "\x04code\x18\x02 \x01(\tB\x03\xe0A\x02R\x04code\x12&\n" + - "\fredirect_uri\x18\x03 \x01(\tB\x03\xe0A\x02R\vredirectUri\"W\n" + - "\x13RegisterUserRequest\x12\x1f\n" + + "\fredirect_uri\x18\x03 \x01(\tB\x03\xe0A\x02R\vredirectUri\"\x16\n" + + "\x14DeleteSessionRequest\"Q\n" + + "\rSignUpRequest\x12\x1f\n" + "\busername\x18\x01 \x01(\tB\x03\xe0A\x02R\busername\x12\x1f\n" + - "\bpassword\x18\x02 \x01(\tB\x03\xe0A\x02R\bpassword\"\x16\n" + - "\x14DeleteSessionRequest2\xb8\x03\n" + - "\vAuthService\x12d\n" + - "\rGetAuthStatus\x12\".memos.api.v1.GetAuthStatusRequest\x1a\x12.memos.api.v1.User\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/api/v1/auth/status\x12i\n" + - "\rCreateSession\x12\".memos.api.v1.CreateSessionRequest\x1a\x12.memos.api.v1.User\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/api/v1/auth/sessions\x12d\n" + - "\fRegisterUser\x12!.memos.api.v1.RegisterUserRequest\x1a\x12.memos.api.v1.User\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\"\x12/api/v1/auth/users\x12r\n" + - "\rDeleteSession\x12\".memos.api.v1.DeleteSessionRequest\x1a\x16.google.protobuf.Empty\"%\x82\xd3\xe4\x93\x02\x1f*\x1d/api/v1/auth/sessions/currentB\xa8\x01\n" + + "\bpassword\x18\x02 \x01(\tB\x03\xe0A\x02R\bpassword2\xbf\x03\n" + + "\vAuthService\x12v\n" + + "\x11GetCurrentSession\x12&.memos.api.v1.GetCurrentSessionRequest\x1a\x12.memos.api.v1.User\"%\x82\xd3\xe4\x93\x02\x1f\x12\x1d/api/v1/auth/sessions/current\x12i\n" + + "\rCreateSession\x12\".memos.api.v1.CreateSessionRequest\x1a\x12.memos.api.v1.User\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/api/v1/auth/sessions\x12r\n" + + "\rDeleteSession\x12\".memos.api.v1.DeleteSessionRequest\x1a\x16.google.protobuf.Empty\"%\x82\xd3\xe4\x93\x02\x1f*\x1d/api/v1/auth/sessions/current\x12Y\n" + + "\x06SignUp\x12\x1b.memos.api.v1.SignUpRequest\x1a\x12.memos.api.v1.User\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/api/v1/auth/signupB\xa8\x01\n" + "\x10com.memos.api.v1B\x10AuthServiceProtoP\x01Z0github.com/usememos/memos/proto/gen/api/v1;apiv1\xa2\x02\x03MAX\xaa\x02\fMemos.Api.V1\xca\x02\fMemos\\Api\\V1\xe2\x02\x18Memos\\Api\\V1\\GPBMetadata\xea\x02\x0eMemos::Api::V1b\x06proto3" var ( @@ -459,28 +459,28 @@ func file_api_v1_auth_service_proto_rawDescGZIP() []byte { var file_api_v1_auth_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_api_v1_auth_service_proto_goTypes = []any{ - (*GetAuthStatusRequest)(nil), // 0: memos.api.v1.GetAuthStatusRequest - (*GetAuthStatusResponse)(nil), // 1: memos.api.v1.GetAuthStatusResponse - (*CreateSessionRequest)(nil), // 2: memos.api.v1.CreateSessionRequest - (*PasswordCredentials)(nil), // 3: memos.api.v1.PasswordCredentials - (*SSOCredentials)(nil), // 4: memos.api.v1.SSOCredentials - (*RegisterUserRequest)(nil), // 5: memos.api.v1.RegisterUserRequest - (*DeleteSessionRequest)(nil), // 6: memos.api.v1.DeleteSessionRequest - (*User)(nil), // 7: memos.api.v1.User - (*emptypb.Empty)(nil), // 8: google.protobuf.Empty + (*GetCurrentSessionRequest)(nil), // 0: memos.api.v1.GetCurrentSessionRequest + (*GetCurrentSessionResponse)(nil), // 1: memos.api.v1.GetCurrentSessionResponse + (*CreateSessionRequest)(nil), // 2: memos.api.v1.CreateSessionRequest + (*PasswordCredentials)(nil), // 3: memos.api.v1.PasswordCredentials + (*SSOCredentials)(nil), // 4: memos.api.v1.SSOCredentials + (*DeleteSessionRequest)(nil), // 5: memos.api.v1.DeleteSessionRequest + (*SignUpRequest)(nil), // 6: memos.api.v1.SignUpRequest + (*User)(nil), // 7: memos.api.v1.User + (*emptypb.Empty)(nil), // 8: google.protobuf.Empty } var file_api_v1_auth_service_proto_depIdxs = []int32{ - 7, // 0: memos.api.v1.GetAuthStatusResponse.user:type_name -> memos.api.v1.User + 7, // 0: memos.api.v1.GetCurrentSessionResponse.user:type_name -> memos.api.v1.User 3, // 1: memos.api.v1.CreateSessionRequest.password_credentials:type_name -> memos.api.v1.PasswordCredentials 4, // 2: memos.api.v1.CreateSessionRequest.sso_credentials:type_name -> memos.api.v1.SSOCredentials - 0, // 3: memos.api.v1.AuthService.GetAuthStatus:input_type -> memos.api.v1.GetAuthStatusRequest + 0, // 3: memos.api.v1.AuthService.GetCurrentSession:input_type -> memos.api.v1.GetCurrentSessionRequest 2, // 4: memos.api.v1.AuthService.CreateSession:input_type -> memos.api.v1.CreateSessionRequest - 5, // 5: memos.api.v1.AuthService.RegisterUser:input_type -> memos.api.v1.RegisterUserRequest - 6, // 6: memos.api.v1.AuthService.DeleteSession:input_type -> memos.api.v1.DeleteSessionRequest - 7, // 7: memos.api.v1.AuthService.GetAuthStatus:output_type -> memos.api.v1.User + 5, // 5: memos.api.v1.AuthService.DeleteSession:input_type -> memos.api.v1.DeleteSessionRequest + 6, // 6: memos.api.v1.AuthService.SignUp:input_type -> memos.api.v1.SignUpRequest + 7, // 7: memos.api.v1.AuthService.GetCurrentSession:output_type -> memos.api.v1.User 7, // 8: memos.api.v1.AuthService.CreateSession:output_type -> memos.api.v1.User - 7, // 9: memos.api.v1.AuthService.RegisterUser:output_type -> memos.api.v1.User - 8, // 10: memos.api.v1.AuthService.DeleteSession:output_type -> google.protobuf.Empty + 8, // 9: memos.api.v1.AuthService.DeleteSession:output_type -> google.protobuf.Empty + 7, // 10: memos.api.v1.AuthService.SignUp:output_type -> memos.api.v1.User 7, // [7:11] is the sub-list for method output_type 3, // [3:7] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name diff --git a/proto/gen/api/v1/auth_service.pb.gw.go b/proto/gen/api/v1/auth_service.pb.gw.go index 4a1a47dee..e667ff9f5 100644 --- a/proto/gen/api/v1/auth_service.pb.gw.go +++ b/proto/gen/api/v1/auth_service.pb.gw.go @@ -35,22 +35,24 @@ var ( _ = metadata.Join ) -func request_AuthService_GetAuthStatus_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_AuthService_GetCurrentSession_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq GetAuthStatusRequest + protoReq GetCurrentSessionRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) - msg, err := client.GetAuthStatus(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } + msg, err := client.GetCurrentSession(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_AuthService_GetAuthStatus_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_AuthService_GetCurrentSession_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq GetAuthStatusRequest + protoReq GetCurrentSessionRequest metadata runtime.ServerMetadata ) - msg, err := server.GetAuthStatus(ctx, &protoReq) + msg, err := server.GetCurrentSession(ctx, &protoReq) return msg, metadata, err } @@ -62,6 +64,9 @@ func request_AuthService_CreateSession_0(ctx context.Context, marshaler runtime. if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } msg, err := client.CreateSession(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -78,46 +83,51 @@ func local_request_AuthService_CreateSession_0(ctx context.Context, marshaler ru return msg, metadata, err } -func request_AuthService_RegisterUser_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_AuthService_DeleteSession_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq RegisterUserRequest + protoReq DeleteSessionRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) } - msg, err := client.RegisterUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.DeleteSession(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_AuthService_RegisterUser_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_AuthService_DeleteSession_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq RegisterUserRequest + protoReq DeleteSessionRequest metadata runtime.ServerMetadata ) - if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - msg, err := server.RegisterUser(ctx, &protoReq) + msg, err := server.DeleteSession(ctx, &protoReq) return msg, metadata, err } -func request_AuthService_DeleteSession_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_AuthService_SignUp_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq DeleteSessionRequest + protoReq SignUpRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) - msg, err := client.DeleteSession(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } + msg, err := client.SignUp(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_AuthService_DeleteSession_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_AuthService_SignUp_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var ( - protoReq DeleteSessionRequest + protoReq SignUpRequest metadata runtime.ServerMetadata ) - msg, err := server.DeleteSession(ctx, &protoReq) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.SignUp(ctx, &protoReq) return msg, metadata, err } @@ -127,25 +137,25 @@ func local_request_AuthService_DeleteSession_0(ctx context.Context, marshaler ru // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthServiceHandlerFromEndpoint instead. // GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call. func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServiceServer) error { - mux.Handle(http.MethodGet, pattern_AuthService_GetAuthStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_AuthService_GetCurrentSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/GetAuthStatus", runtime.WithHTTPPathPattern("/api/v1/auth/status")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/GetCurrentSession", runtime.WithHTTPPathPattern("/api/v1/auth/sessions/current")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_AuthService_GetAuthStatus_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_AuthService_GetCurrentSession_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_GetAuthStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_GetCurrentSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_AuthService_CreateSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) @@ -167,45 +177,45 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux } forward_AuthService_CreateSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_AuthService_RegisterUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodDelete, pattern_AuthService_DeleteSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/RegisterUser", runtime.WithHTTPPathPattern("/api/v1/auth/users")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/DeleteSession", runtime.WithHTTPPathPattern("/api/v1/auth/sessions/current")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_AuthService_RegisterUser_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_AuthService_DeleteSession_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_RegisterUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_DeleteSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodDelete, pattern_AuthService_DeleteSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_AuthService_SignUp_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/DeleteSession", runtime.WithHTTPPathPattern("/api/v1/auth/sessions/current")) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AuthService/SignUp", runtime.WithHTTPPathPattern("/api/v1/auth/signup")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_AuthService_DeleteSession_0(annotatedContext, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_AuthService_SignUp_0(annotatedContext, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_DeleteSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_SignUp_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil @@ -247,22 +257,22 @@ func RegisterAuthServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "AuthServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares. func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthServiceClient) error { - mux.Handle(http.MethodGet, pattern_AuthService_GetAuthStatus_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodGet, pattern_AuthService_GetCurrentSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/GetAuthStatus", runtime.WithHTTPPathPattern("/api/v1/auth/status")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/GetCurrentSession", runtime.WithHTTPPathPattern("/api/v1/auth/sessions/current")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_AuthService_GetAuthStatus_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_AuthService_GetCurrentSession_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_GetAuthStatus_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_GetCurrentSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle(http.MethodPost, pattern_AuthService_CreateSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) @@ -281,53 +291,53 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux } forward_AuthService_CreateSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodPost, pattern_AuthService_RegisterUser_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodDelete, pattern_AuthService_DeleteSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/RegisterUser", runtime.WithHTTPPathPattern("/api/v1/auth/users")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/DeleteSession", runtime.WithHTTPPathPattern("/api/v1/auth/sessions/current")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_AuthService_RegisterUser_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_AuthService_DeleteSession_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_RegisterUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_DeleteSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle(http.MethodDelete, pattern_AuthService_DeleteSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle(http.MethodPost, pattern_AuthService_SignUp_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/DeleteSession", runtime.WithHTTPPathPattern("/api/v1/auth/sessions/current")) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AuthService/SignUp", runtime.WithHTTPPathPattern("/api/v1/auth/signup")) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_AuthService_DeleteSession_0(annotatedContext, inboundMarshaler, client, req, pathParams) + resp, md, err := request_AuthService_SignUp_0(annotatedContext, inboundMarshaler, client, req, pathParams) annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) if err != nil { runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) return } - forward_AuthService_DeleteSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_AuthService_SignUp_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) return nil } var ( - pattern_AuthService_GetAuthStatus_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "status"}, "")) - pattern_AuthService_CreateSession_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "sessions"}, "")) - pattern_AuthService_RegisterUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "users"}, "")) - pattern_AuthService_DeleteSession_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"api", "v1", "auth", "sessions", "current"}, "")) + pattern_AuthService_GetCurrentSession_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"api", "v1", "auth", "sessions", "current"}, "")) + pattern_AuthService_CreateSession_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "sessions"}, "")) + pattern_AuthService_DeleteSession_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"api", "v1", "auth", "sessions", "current"}, "")) + pattern_AuthService_SignUp_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "signup"}, "")) ) var ( - forward_AuthService_GetAuthStatus_0 = runtime.ForwardResponseMessage - forward_AuthService_CreateSession_0 = runtime.ForwardResponseMessage - forward_AuthService_RegisterUser_0 = runtime.ForwardResponseMessage - forward_AuthService_DeleteSession_0 = runtime.ForwardResponseMessage + forward_AuthService_GetCurrentSession_0 = runtime.ForwardResponseMessage + forward_AuthService_CreateSession_0 = runtime.ForwardResponseMessage + forward_AuthService_DeleteSession_0 = runtime.ForwardResponseMessage + forward_AuthService_SignUp_0 = runtime.ForwardResponseMessage ) diff --git a/proto/gen/api/v1/auth_service_grpc.pb.go b/proto/gen/api/v1/auth_service_grpc.pb.go index e2436f5a3..a56b43901 100644 --- a/proto/gen/api/v1/auth_service_grpc.pb.go +++ b/proto/gen/api/v1/auth_service_grpc.pb.go @@ -20,28 +20,28 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - AuthService_GetAuthStatus_FullMethodName = "/memos.api.v1.AuthService/GetAuthStatus" - AuthService_CreateSession_FullMethodName = "/memos.api.v1.AuthService/CreateSession" - AuthService_RegisterUser_FullMethodName = "/memos.api.v1.AuthService/RegisterUser" - AuthService_DeleteSession_FullMethodName = "/memos.api.v1.AuthService/DeleteSession" + AuthService_GetCurrentSession_FullMethodName = "/memos.api.v1.AuthService/GetCurrentSession" + AuthService_CreateSession_FullMethodName = "/memos.api.v1.AuthService/CreateSession" + AuthService_DeleteSession_FullMethodName = "/memos.api.v1.AuthService/DeleteSession" + AuthService_SignUp_FullMethodName = "/memos.api.v1.AuthService/SignUp" ) // AuthServiceClient is the client API for AuthService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type AuthServiceClient interface { - // GetAuthStatus returns the current authentication status of the user. - // This method is idempotent and safe, suitable for checking authentication state. - GetAuthStatus(ctx context.Context, in *GetAuthStatusRequest, opts ...grpc.CallOption) (*User, error) + // GetCurrentSession returns the current active session information. + // This method is idempotent and safe, suitable for checking current session state. + GetCurrentSession(ctx context.Context, in *GetCurrentSessionRequest, opts ...grpc.CallOption) (*User, error) // CreateSession authenticates a user and creates a new session. // Returns the authenticated user information upon successful authentication. CreateSession(ctx context.Context, in *CreateSessionRequest, opts ...grpc.CallOption) (*User, error) - // RegisterUser creates a new user account with username and password. - // Returns the newly created user information upon successful registration. - RegisterUser(ctx context.Context, in *RegisterUserRequest, opts ...grpc.CallOption) (*User, error) // DeleteSession terminates the current user session. // This is an idempotent operation that invalidates the user's authentication. DeleteSession(ctx context.Context, in *DeleteSessionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + // SignUp creates a new user account with username and password. + // Returns the newly created user information upon successful registration. + SignUp(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*User, error) } type authServiceClient struct { @@ -52,10 +52,10 @@ func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { return &authServiceClient{cc} } -func (c *authServiceClient) GetAuthStatus(ctx context.Context, in *GetAuthStatusRequest, opts ...grpc.CallOption) (*User, error) { +func (c *authServiceClient) GetCurrentSession(ctx context.Context, in *GetCurrentSessionRequest, opts ...grpc.CallOption) (*User, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(User) - err := c.cc.Invoke(ctx, AuthService_GetAuthStatus_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, AuthService_GetCurrentSession_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -72,20 +72,20 @@ func (c *authServiceClient) CreateSession(ctx context.Context, in *CreateSession return out, nil } -func (c *authServiceClient) RegisterUser(ctx context.Context, in *RegisterUserRequest, opts ...grpc.CallOption) (*User, error) { +func (c *authServiceClient) DeleteSession(ctx context.Context, in *DeleteSessionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(User) - err := c.cc.Invoke(ctx, AuthService_RegisterUser_FullMethodName, in, out, cOpts...) + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, AuthService_DeleteSession_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *authServiceClient) DeleteSession(ctx context.Context, in *DeleteSessionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { +func (c *authServiceClient) SignUp(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*User, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, AuthService_DeleteSession_FullMethodName, in, out, cOpts...) + out := new(User) + err := c.cc.Invoke(ctx, AuthService_SignUp_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -96,18 +96,18 @@ func (c *authServiceClient) DeleteSession(ctx context.Context, in *DeleteSession // All implementations must embed UnimplementedAuthServiceServer // for forward compatibility. type AuthServiceServer interface { - // GetAuthStatus returns the current authentication status of the user. - // This method is idempotent and safe, suitable for checking authentication state. - GetAuthStatus(context.Context, *GetAuthStatusRequest) (*User, error) + // GetCurrentSession returns the current active session information. + // This method is idempotent and safe, suitable for checking current session state. + GetCurrentSession(context.Context, *GetCurrentSessionRequest) (*User, error) // CreateSession authenticates a user and creates a new session. // Returns the authenticated user information upon successful authentication. CreateSession(context.Context, *CreateSessionRequest) (*User, error) - // RegisterUser creates a new user account with username and password. - // Returns the newly created user information upon successful registration. - RegisterUser(context.Context, *RegisterUserRequest) (*User, error) // DeleteSession terminates the current user session. // This is an idempotent operation that invalidates the user's authentication. DeleteSession(context.Context, *DeleteSessionRequest) (*emptypb.Empty, error) + // SignUp creates a new user account with username and password. + // Returns the newly created user information upon successful registration. + SignUp(context.Context, *SignUpRequest) (*User, error) mustEmbedUnimplementedAuthServiceServer() } @@ -118,18 +118,18 @@ type AuthServiceServer interface { // pointer dereference when methods are called. type UnimplementedAuthServiceServer struct{} -func (UnimplementedAuthServiceServer) GetAuthStatus(context.Context, *GetAuthStatusRequest) (*User, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetAuthStatus not implemented") +func (UnimplementedAuthServiceServer) GetCurrentSession(context.Context, *GetCurrentSessionRequest) (*User, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetCurrentSession not implemented") } func (UnimplementedAuthServiceServer) CreateSession(context.Context, *CreateSessionRequest) (*User, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateSession not implemented") } -func (UnimplementedAuthServiceServer) RegisterUser(context.Context, *RegisterUserRequest) (*User, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterUser not implemented") -} func (UnimplementedAuthServiceServer) DeleteSession(context.Context, *DeleteSessionRequest) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteSession not implemented") } +func (UnimplementedAuthServiceServer) SignUp(context.Context, *SignUpRequest) (*User, error) { + return nil, status.Errorf(codes.Unimplemented, "method SignUp not implemented") +} func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} func (UnimplementedAuthServiceServer) testEmbeddedByValue() {} @@ -151,20 +151,20 @@ func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) { s.RegisterService(&AuthService_ServiceDesc, srv) } -func _AuthService_GetAuthStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetAuthStatusRequest) +func _AuthService_GetCurrentSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetCurrentSessionRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServiceServer).GetAuthStatus(ctx, in) + return srv.(AuthServiceServer).GetCurrentSession(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: AuthService_GetAuthStatus_FullMethodName, + FullMethod: AuthService_GetCurrentSession_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).GetAuthStatus(ctx, req.(*GetAuthStatusRequest)) + return srv.(AuthServiceServer).GetCurrentSession(ctx, req.(*GetCurrentSessionRequest)) } return interceptor(ctx, in, info, handler) } @@ -187,38 +187,38 @@ func _AuthService_CreateSession_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } -func _AuthService_RegisterUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(RegisterUserRequest) +func _AuthService_DeleteSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteSessionRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServiceServer).RegisterUser(ctx, in) + return srv.(AuthServiceServer).DeleteSession(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: AuthService_RegisterUser_FullMethodName, + FullMethod: AuthService_DeleteSession_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).RegisterUser(ctx, req.(*RegisterUserRequest)) + return srv.(AuthServiceServer).DeleteSession(ctx, req.(*DeleteSessionRequest)) } return interceptor(ctx, in, info, handler) } -func _AuthService_DeleteSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteSessionRequest) +func _AuthService_SignUp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SignUpRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(AuthServiceServer).DeleteSession(ctx, in) + return srv.(AuthServiceServer).SignUp(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: AuthService_DeleteSession_FullMethodName, + FullMethod: AuthService_SignUp_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AuthServiceServer).DeleteSession(ctx, req.(*DeleteSessionRequest)) + return srv.(AuthServiceServer).SignUp(ctx, req.(*SignUpRequest)) } return interceptor(ctx, in, info, handler) } @@ -231,21 +231,21 @@ var AuthService_ServiceDesc = grpc.ServiceDesc{ HandlerType: (*AuthServiceServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "GetAuthStatus", - Handler: _AuthService_GetAuthStatus_Handler, + MethodName: "GetCurrentSession", + Handler: _AuthService_GetCurrentSession_Handler, }, { MethodName: "CreateSession", Handler: _AuthService_CreateSession_Handler, }, - { - MethodName: "RegisterUser", - Handler: _AuthService_RegisterUser_Handler, - }, { MethodName: "DeleteSession", Handler: _AuthService_DeleteSession_Handler, }, + { + MethodName: "SignUp", + Handler: _AuthService_SignUp_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "api/v1/auth_service.proto", diff --git a/proto/gen/api/v1/idp_service.pb.gw.go b/proto/gen/api/v1/idp_service.pb.gw.go index c303e130b..85cffd215 100644 --- a/proto/gen/api/v1/idp_service.pb.gw.go +++ b/proto/gen/api/v1/idp_service.pb.gw.go @@ -42,7 +42,9 @@ func request_IdentityProviderService_ListIdentityProviders_0(ctx context.Context protoReq ListIdentityProvidersRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -74,7 +76,9 @@ func request_IdentityProviderService_GetIdentityProvider_0(ctx context.Context, metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -115,6 +119,9 @@ func request_IdentityProviderService_CreateIdentityProvider_0(ctx context.Contex if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.IdentityProvider); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -158,6 +165,9 @@ func request_IdentityProviderService_UpdateIdentityProvider_0(ctx context.Contex if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.IdentityProvider); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.IdentityProvider); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) @@ -227,7 +237,9 @@ func request_IdentityProviderService_DeleteIdentityProvider_0(ctx context.Contex metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") diff --git a/proto/gen/api/v1/inbox_service.pb.gw.go b/proto/gen/api/v1/inbox_service.pb.gw.go index e98c07e66..99d6f955e 100644 --- a/proto/gen/api/v1/inbox_service.pb.gw.go +++ b/proto/gen/api/v1/inbox_service.pb.gw.go @@ -43,7 +43,9 @@ func request_InboxService_ListInboxes_0(ctx context.Context, marshaler runtime.M metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["parent"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") @@ -101,6 +103,9 @@ func request_InboxService_UpdateInbox_0(ctx context.Context, marshaler runtime.M if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Inbox); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Inbox); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) @@ -170,7 +175,9 @@ func request_InboxService_DeleteInbox_0(ctx context.Context, marshaler runtime.M metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") diff --git a/proto/gen/api/v1/markdown_service.pb.gw.go b/proto/gen/api/v1/markdown_service.pb.gw.go index 58f07a872..39e162dd7 100644 --- a/proto/gen/api/v1/markdown_service.pb.gw.go +++ b/proto/gen/api/v1/markdown_service.pb.gw.go @@ -43,6 +43,9 @@ func request_MarkdownService_ParseMarkdown_0(ctx context.Context, marshaler runt if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } msg, err := client.ParseMarkdown(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -67,6 +70,9 @@ func request_MarkdownService_RestoreMarkdownNodes_0(ctx context.Context, marshal if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } msg, err := client.RestoreMarkdownNodes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -91,6 +97,9 @@ func request_MarkdownService_StringifyMarkdownNodes_0(ctx context.Context, marsh if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } msg, err := client.StringifyMarkdownNodes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -114,7 +123,9 @@ func request_MarkdownService_GetLinkMetadata_0(ctx context.Context, marshaler ru protoReq GetLinkMetadataRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } diff --git a/proto/gen/api/v1/memo_service.pb.gw.go b/proto/gen/api/v1/memo_service.pb.gw.go index 200f48dff..77ee50303 100644 --- a/proto/gen/api/v1/memo_service.pb.gw.go +++ b/proto/gen/api/v1/memo_service.pb.gw.go @@ -45,6 +45,9 @@ func request_MemoService_CreateMemo_0(ctx context.Context, marshaler runtime.Mar if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Memo); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -80,7 +83,9 @@ func request_MemoService_ListMemos_0(ctx context.Context, marshaler runtime.Mars protoReq ListMemosRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -114,7 +119,9 @@ func request_MemoService_ListMemos_1(ctx context.Context, marshaler runtime.Mars metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["parent"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") @@ -165,7 +172,9 @@ func request_MemoService_GetMemo_0(ctx context.Context, marshaler runtime.Marsha metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -223,6 +232,9 @@ func request_MemoService_UpdateMemo_0(ctx context.Context, marshaler runtime.Mar if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Memo); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Memo); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) @@ -294,7 +306,9 @@ func request_MemoService_DeleteMemo_0(ctx context.Context, marshaler runtime.Mar metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -346,6 +360,9 @@ func request_MemoService_RenameMemoTag_0(ctx context.Context, marshaler runtime. if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["parent"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") @@ -387,7 +404,9 @@ func request_MemoService_DeleteMemoTag_0(ctx context.Context, marshaler runtime. metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["parent"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") @@ -455,6 +474,9 @@ func request_MemoService_SetMemoAttachments_0(ctx context.Context, marshaler run if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -496,7 +518,9 @@ func request_MemoService_ListMemoAttachments_0(ctx context.Context, marshaler ru metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -548,6 +572,9 @@ func request_MemoService_SetMemoRelations_0(ctx context.Context, marshaler runti if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -589,7 +616,9 @@ func request_MemoService_ListMemoRelations_0(ctx context.Context, marshaler runt metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -643,6 +672,9 @@ func request_MemoService_CreateMemoComment_0(ctx context.Context, marshaler runt if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Comment); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -696,7 +728,9 @@ func request_MemoService_ListMemoComments_0(ctx context.Context, marshaler runti metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -747,7 +781,9 @@ func request_MemoService_ListMemoReactions_0(ctx context.Context, marshaler runt metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -799,6 +835,9 @@ func request_MemoService_UpsertMemoReaction_0(ctx context.Context, marshaler run if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -838,7 +877,9 @@ func request_MemoService_DeleteMemoReaction_0(ctx context.Context, marshaler run metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") diff --git a/proto/gen/api/v1/shortcut_service.pb.gw.go b/proto/gen/api/v1/shortcut_service.pb.gw.go index 2afb900a1..0d3228f5e 100644 --- a/proto/gen/api/v1/shortcut_service.pb.gw.go +++ b/proto/gen/api/v1/shortcut_service.pb.gw.go @@ -43,7 +43,9 @@ func request_ShortcutService_ListShortcuts_0(ctx context.Context, marshaler runt metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["parent"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") @@ -92,7 +94,9 @@ func request_ShortcutService_GetShortcut_0(ctx context.Context, marshaler runtim metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -134,6 +138,9 @@ func request_ShortcutService_CreateShortcut_0(ctx context.Context, marshaler run if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Shortcut); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["parent"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") @@ -194,6 +201,9 @@ func request_ShortcutService_UpdateShortcut_0(ctx context.Context, marshaler run if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Shortcut); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Shortcut); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) @@ -263,7 +273,9 @@ func request_ShortcutService_DeleteShortcut_0(ctx context.Context, marshaler run metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") diff --git a/proto/gen/api/v1/user_service.pb.gw.go b/proto/gen/api/v1/user_service.pb.gw.go index a12738246..53ef79ef9 100644 --- a/proto/gen/api/v1/user_service.pb.gw.go +++ b/proto/gen/api/v1/user_service.pb.gw.go @@ -42,7 +42,9 @@ func request_UserService_ListUsers_0(ctx context.Context, marshaler runtime.Mars protoReq ListUsersRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -76,7 +78,9 @@ func request_UserService_GetUser_0(ctx context.Context, marshaler runtime.Marsha metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -129,6 +133,9 @@ func request_UserService_CreateUser_0(ctx context.Context, marshaler runtime.Mar if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -172,6 +179,9 @@ func request_UserService_UpdateUser_0(ctx context.Context, marshaler runtime.Mar if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.User); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.User); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) @@ -243,7 +253,9 @@ func request_UserService_DeleteUser_0(ctx context.Context, marshaler runtime.Mar metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -293,7 +305,9 @@ func request_UserService_SearchUsers_0(ctx context.Context, marshaler runtime.Ma protoReq SearchUsersRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -325,7 +339,9 @@ func request_UserService_GetUserAvatar_0(ctx context.Context, marshaler runtime. metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -363,7 +379,9 @@ func request_UserService_ListAllUserStats_0(ctx context.Context, marshaler runti protoReq ListAllUserStatsRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -395,7 +413,9 @@ func request_UserService_GetUserStats_0(ctx context.Context, marshaler runtime.M metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -432,7 +452,9 @@ func request_UserService_GetUserSetting_0(ctx context.Context, marshaler runtime metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -478,6 +500,9 @@ func request_UserService_UpdateUserSetting_0(ctx context.Context, marshaler runt if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Setting); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Setting); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) @@ -549,7 +574,9 @@ func request_UserService_ListUserAccessTokens_0(ctx context.Context, marshaler r metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["parent"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") @@ -603,6 +630,9 @@ func request_UserService_CreateUserAccessToken_0(ctx context.Context, marshaler if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.AccessToken); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["parent"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") @@ -654,7 +684,9 @@ func request_UserService_DeleteUserAccessToken_0(ctx context.Context, marshaler metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") diff --git a/proto/gen/api/v1/webhook_service.pb.gw.go b/proto/gen/api/v1/webhook_service.pb.gw.go index 54d13c284..03aefd82d 100644 --- a/proto/gen/api/v1/webhook_service.pb.gw.go +++ b/proto/gen/api/v1/webhook_service.pb.gw.go @@ -42,7 +42,9 @@ func request_WebhookService_ListWebhooks_0(ctx context.Context, marshaler runtim protoReq ListWebhooksRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -76,7 +78,9 @@ func request_WebhookService_GetWebhook_0(ctx context.Context, marshaler runtime. metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -129,6 +133,9 @@ func request_WebhookService_CreateWebhook_0(ctx context.Context, marshaler runti if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Webhook); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -172,6 +179,9 @@ func request_WebhookService_UpdateWebhook_0(ctx context.Context, marshaler runti if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Webhook); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Webhook); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) @@ -243,7 +253,9 @@ func request_WebhookService_DeleteWebhook_0(ctx context.Context, marshaler runti metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") diff --git a/proto/gen/api/v1/workspace_service.pb.gw.go b/proto/gen/api/v1/workspace_service.pb.gw.go index 780898b97..acfb832bd 100644 --- a/proto/gen/api/v1/workspace_service.pb.gw.go +++ b/proto/gen/api/v1/workspace_service.pb.gw.go @@ -40,7 +40,9 @@ func request_WorkspaceService_GetWorkspaceProfile_0(ctx context.Context, marshal protoReq GetWorkspaceProfileRequest metadata runtime.ServerMetadata ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } msg, err := client.GetWorkspaceProfile(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } @@ -60,7 +62,9 @@ func request_WorkspaceService_GetWorkspaceSetting_0(ctx context.Context, marshal metadata runtime.ServerMetadata err error ) - io.Copy(io.Discard, req.Body) + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } val, ok := pathParams["name"] if !ok { return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") @@ -106,6 +110,9 @@ func request_WorkspaceService_UpdateWorkspaceSetting_0(ctx context.Context, mars if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Setting); err != nil && !errors.Is(err, io.EOF) { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 { if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Setting); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) diff --git a/proto/gen/apidocs.swagger.yaml b/proto/gen/apidocs.swagger.yaml index 9dd5c61da..29c2738fa 100644 --- a/proto/gen/apidocs.swagger.yaml +++ b/proto/gen/apidocs.swagger.yaml @@ -155,46 +155,45 @@ paths: tags: - AuthService /api/v1/auth/sessions/current: - delete: + get: summary: |- - DeleteSession terminates the current user session. - This is an idempotent operation that invalidates the user's authentication. - operationId: AuthService_DeleteSession + GetCurrentSession returns the current active session information. + This method is idempotent and safe, suitable for checking current session state. + operationId: AuthService_GetCurrentSession responses: "200": description: A successful response. schema: - type: object - properties: {} + $ref: '#/definitions/v1User' default: description: An unexpected error response. schema: $ref: '#/definitions/googlerpcStatus' tags: - AuthService - /api/v1/auth/status: - get: + delete: summary: |- - GetAuthStatus returns the current authentication status of the user. - This method is idempotent and safe, suitable for checking authentication state. - operationId: AuthService_GetAuthStatus + DeleteSession terminates the current user session. + This is an idempotent operation that invalidates the user's authentication. + operationId: AuthService_DeleteSession responses: "200": description: A successful response. schema: - $ref: '#/definitions/v1User' + type: object + properties: {} default: description: An unexpected error response. schema: $ref: '#/definitions/googlerpcStatus' tags: - AuthService - /api/v1/auth/users: + /api/v1/auth/signup: post: summary: |- - RegisterUser creates a new user account with username and password. + SignUp creates a new user account with username and password. Returns the newly created user information upon successful registration. - operationId: AuthService_RegisterUser + operationId: AuthService_SignUp responses: "200": description: A successful response. @@ -209,7 +208,7 @@ paths: in: body required: true schema: - $ref: '#/definitions/v1RegisterUserRequest' + $ref: '#/definitions/v1SignUpRequest' tags: - AuthService /api/v1/identityProviders: @@ -3984,22 +3983,6 @@ definitions: params: type: string description: Additional parameters for the referenced content. - v1RegisterUserRequest: - type: object - properties: - username: - type: string - description: |- - The username to sign up with. - Required field that must be unique across the system. - password: - type: string - description: |- - The password to sign up with. - Required field that should meet security requirements. - required: - - username - - password v1RestoreMarkdownNodesRequest: type: object properties: @@ -4056,6 +4039,22 @@ definitions: type: integer format: int32 description: The total count of matching users. + v1SignUpRequest: + type: object + properties: + username: + type: string + description: |- + The username to sign up with. + Required field that must be unique across the system. + password: + type: string + description: |- + The password to sign up with. + Required field that should meet security requirements. + required: + - username + - password v1SpoilerNode: type: object properties: diff --git a/proto/gen/store/user_setting.pb.go b/proto/gen/store/user_setting.pb.go index 65d066bfc..93c3af7d1 100644 --- a/proto/gen/store/user_setting.pb.go +++ b/proto/gen/store/user_setting.pb.go @@ -9,6 +9,7 @@ package store import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" unsafe "unsafe" @@ -35,6 +36,8 @@ const ( UserSettingKey_MEMO_VISIBILITY UserSettingKey = 4 // The shortcuts of the user. UserSettingKey_SHORTCUTS UserSettingKey = 5 + // User authentication sessions. + UserSettingKey_SESSIONS UserSettingKey = 6 ) // Enum value maps for UserSettingKey. @@ -46,6 +49,7 @@ var ( 3: "APPEARANCE", 4: "MEMO_VISIBILITY", 5: "SHORTCUTS", + 6: "SESSIONS", } UserSettingKey_value = map[string]int32{ "USER_SETTING_KEY_UNSPECIFIED": 0, @@ -54,6 +58,7 @@ var ( "APPEARANCE": 3, "MEMO_VISIBILITY": 4, "SHORTCUTS": 5, + "SESSIONS": 6, } ) @@ -95,6 +100,7 @@ type UserSetting struct { // *UserSetting_Appearance // *UserSetting_MemoVisibility // *UserSetting_Shortcuts + // *UserSetting_Sessions Value isUserSetting_Value `protobuf_oneof:"value"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache @@ -196,6 +202,15 @@ func (x *UserSetting) GetShortcuts() *ShortcutsUserSetting { return nil } +func (x *UserSetting) GetSessions() *SessionsUserSetting { + if x != nil { + if x, ok := x.Value.(*UserSetting_Sessions); ok { + return x.Sessions + } + } + return nil +} + type isUserSetting_Value interface { isUserSetting_Value() } @@ -220,6 +235,10 @@ type UserSetting_Shortcuts struct { Shortcuts *ShortcutsUserSetting `protobuf:"bytes,7,opt,name=shortcuts,proto3,oneof"` } +type UserSetting_Sessions struct { + Sessions *SessionsUserSetting `protobuf:"bytes,8,opt,name=sessions,proto3,oneof"` +} + func (*UserSetting_AccessTokens) isUserSetting_Value() {} func (*UserSetting_Locale) isUserSetting_Value() {} @@ -230,6 +249,8 @@ func (*UserSetting_MemoVisibility) isUserSetting_Value() {} func (*UserSetting_Shortcuts) isUserSetting_Value() {} +func (*UserSetting_Sessions) isUserSetting_Value() {} + type AccessTokensUserSetting struct { state protoimpl.MessageState `protogen:"open.v1"` AccessTokens []*AccessTokensUserSetting_AccessToken `protobuf:"bytes,1,rep,name=access_tokens,json=accessTokens,proto3" json:"access_tokens,omitempty"` @@ -318,6 +339,50 @@ func (x *ShortcutsUserSetting) GetShortcuts() []*ShortcutsUserSetting_Shortcut { return nil } +type SessionsUserSetting struct { + state protoimpl.MessageState `protogen:"open.v1"` + Sessions []*SessionsUserSetting_Session `protobuf:"bytes,1,rep,name=sessions,proto3" json:"sessions,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SessionsUserSetting) Reset() { + *x = SessionsUserSetting{} + mi := &file_store_user_setting_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SessionsUserSetting) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SessionsUserSetting) ProtoMessage() {} + +func (x *SessionsUserSetting) ProtoReflect() protoreflect.Message { + mi := &file_store_user_setting_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SessionsUserSetting.ProtoReflect.Descriptor instead. +func (*SessionsUserSetting) Descriptor() ([]byte, []int) { + return file_store_user_setting_proto_rawDescGZIP(), []int{3} +} + +func (x *SessionsUserSetting) GetSessions() []*SessionsUserSetting_Session { + if x != nil { + return x.Sessions + } + return nil +} + type AccessTokensUserSetting_AccessToken struct { state protoimpl.MessageState `protogen:"open.v1"` // The access token is a JWT token. @@ -331,7 +396,7 @@ type AccessTokensUserSetting_AccessToken struct { func (x *AccessTokensUserSetting_AccessToken) Reset() { *x = AccessTokensUserSetting_AccessToken{} - mi := &file_store_user_setting_proto_msgTypes[3] + mi := &file_store_user_setting_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -343,7 +408,7 @@ func (x *AccessTokensUserSetting_AccessToken) String() string { func (*AccessTokensUserSetting_AccessToken) ProtoMessage() {} func (x *AccessTokensUserSetting_AccessToken) ProtoReflect() protoreflect.Message { - mi := &file_store_user_setting_proto_msgTypes[3] + mi := &file_store_user_setting_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -384,7 +449,7 @@ type ShortcutsUserSetting_Shortcut struct { func (x *ShortcutsUserSetting_Shortcut) Reset() { *x = ShortcutsUserSetting_Shortcut{} - mi := &file_store_user_setting_proto_msgTypes[4] + mi := &file_store_user_setting_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -396,7 +461,7 @@ func (x *ShortcutsUserSetting_Shortcut) String() string { func (*ShortcutsUserSetting_Shortcut) ProtoMessage() {} func (x *ShortcutsUserSetting_Shortcut) ProtoReflect() protoreflect.Message { - mi := &file_store_user_setting_proto_msgTypes[4] + mi := &file_store_user_setting_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -433,11 +498,182 @@ func (x *ShortcutsUserSetting_Shortcut) GetFilter() string { return "" } +type SessionsUserSetting_Session struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Unique session identifier. + SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"` + // Timestamp when the session was created. + CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` + // Timestamp when the session expires. + ExpireTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=expire_time,json=expireTime,proto3" json:"expire_time,omitempty"` + // Timestamp when the session was last accessed. + LastAccessedTime *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=last_accessed_time,json=lastAccessedTime,proto3" json:"last_accessed_time,omitempty"` + // Client information associated with this session. + ClientInfo *SessionsUserSetting_ClientInfo `protobuf:"bytes,5,opt,name=client_info,json=clientInfo,proto3" json:"client_info,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SessionsUserSetting_Session) Reset() { + *x = SessionsUserSetting_Session{} + mi := &file_store_user_setting_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SessionsUserSetting_Session) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SessionsUserSetting_Session) ProtoMessage() {} + +func (x *SessionsUserSetting_Session) ProtoReflect() protoreflect.Message { + mi := &file_store_user_setting_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SessionsUserSetting_Session.ProtoReflect.Descriptor instead. +func (*SessionsUserSetting_Session) Descriptor() ([]byte, []int) { + return file_store_user_setting_proto_rawDescGZIP(), []int{3, 0} +} + +func (x *SessionsUserSetting_Session) GetSessionId() string { + if x != nil { + return x.SessionId + } + return "" +} + +func (x *SessionsUserSetting_Session) GetCreateTime() *timestamppb.Timestamp { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *SessionsUserSetting_Session) GetExpireTime() *timestamppb.Timestamp { + if x != nil { + return x.ExpireTime + } + return nil +} + +func (x *SessionsUserSetting_Session) GetLastAccessedTime() *timestamppb.Timestamp { + if x != nil { + return x.LastAccessedTime + } + return nil +} + +func (x *SessionsUserSetting_Session) GetClientInfo() *SessionsUserSetting_ClientInfo { + if x != nil { + return x.ClientInfo + } + return nil +} + +type SessionsUserSetting_ClientInfo struct { + state protoimpl.MessageState `protogen:"open.v1"` + // User agent string of the client. + UserAgent string `protobuf:"bytes,1,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"` + // IP address of the client. + IpAddress string `protobuf:"bytes,2,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty"` + // Optional. Device type (e.g., "mobile", "desktop", "tablet"). + DeviceType string `protobuf:"bytes,3,opt,name=device_type,json=deviceType,proto3" json:"device_type,omitempty"` + // Optional. Operating system (e.g., "iOS 17.0", "Windows 11"). + Os string `protobuf:"bytes,4,opt,name=os,proto3" json:"os,omitempty"` + // Optional. Browser name and version (e.g., "Chrome 119.0"). + Browser string `protobuf:"bytes,5,opt,name=browser,proto3" json:"browser,omitempty"` + // Optional. Geographic location (country code, e.g., "US"). + Country string `protobuf:"bytes,6,opt,name=country,proto3" json:"country,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SessionsUserSetting_ClientInfo) Reset() { + *x = SessionsUserSetting_ClientInfo{} + mi := &file_store_user_setting_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SessionsUserSetting_ClientInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SessionsUserSetting_ClientInfo) ProtoMessage() {} + +func (x *SessionsUserSetting_ClientInfo) ProtoReflect() protoreflect.Message { + mi := &file_store_user_setting_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SessionsUserSetting_ClientInfo.ProtoReflect.Descriptor instead. +func (*SessionsUserSetting_ClientInfo) Descriptor() ([]byte, []int) { + return file_store_user_setting_proto_rawDescGZIP(), []int{3, 1} +} + +func (x *SessionsUserSetting_ClientInfo) GetUserAgent() string { + if x != nil { + return x.UserAgent + } + return "" +} + +func (x *SessionsUserSetting_ClientInfo) GetIpAddress() string { + if x != nil { + return x.IpAddress + } + return "" +} + +func (x *SessionsUserSetting_ClientInfo) GetDeviceType() string { + if x != nil { + return x.DeviceType + } + return "" +} + +func (x *SessionsUserSetting_ClientInfo) GetOs() string { + if x != nil { + return x.Os + } + return "" +} + +func (x *SessionsUserSetting_ClientInfo) GetBrowser() string { + if x != nil { + return x.Browser + } + return "" +} + +func (x *SessionsUserSetting_ClientInfo) GetCountry() string { + if x != nil { + return x.Country + } + return "" +} + var File_store_user_setting_proto protoreflect.FileDescriptor const file_store_user_setting_proto_rawDesc = "" + "\n" + - "\x18store/user_setting.proto\x12\vmemos.store\"\xd5\x02\n" + + "\x18store/user_setting.proto\x12\vmemos.store\x1a\x1fgoogle/protobuf/timestamp.proto\"\x95\x03\n" + "\vUserSetting\x12\x17\n" + "\auser_id\x18\x01 \x01(\x05R\x06userId\x12-\n" + "\x03key\x18\x02 \x01(\x0e2\x1b.memos.store.UserSettingKeyR\x03key\x12K\n" + @@ -447,7 +683,8 @@ const file_store_user_setting_proto_rawDesc = "" + "appearance\x18\x05 \x01(\tH\x00R\n" + "appearance\x12)\n" + "\x0fmemo_visibility\x18\x06 \x01(\tH\x00R\x0ememoVisibility\x12A\n" + - "\tshortcuts\x18\a \x01(\v2!.memos.store.ShortcutsUserSettingH\x00R\tshortcutsB\a\n" + + "\tshortcuts\x18\a \x01(\v2!.memos.store.ShortcutsUserSettingH\x00R\tshortcuts\x12>\n" + + "\bsessions\x18\b \x01(\v2 .memos.store.SessionsUserSettingH\x00R\bsessionsB\a\n" + "\x05value\"\xc4\x01\n" + "\x17AccessTokensUserSetting\x12U\n" + "\raccess_tokens\x18\x01 \x03(\v20.memos.store.AccessTokensUserSetting.AccessTokenR\faccessTokens\x1aR\n" + @@ -459,7 +696,30 @@ const file_store_user_setting_proto_rawDesc = "" + "\bShortcut\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x14\n" + "\x05title\x18\x02 \x01(\tR\x05title\x12\x16\n" + - "\x06filter\x18\x03 \x01(\tR\x06filter*\x85\x01\n" + + "\x06filter\x18\x03 \x01(\tR\x06filter\"\xca\x04\n" + + "\x13SessionsUserSetting\x12D\n" + + "\bsessions\x18\x01 \x03(\v2(.memos.store.SessionsUserSetting.SessionR\bsessions\x1a\xba\x02\n" + + "\aSession\x12\x1d\n" + + "\n" + + "session_id\x18\x01 \x01(\tR\tsessionId\x12;\n" + + "\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\n" + + "createTime\x12;\n" + + "\vexpire_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\n" + + "expireTime\x12H\n" + + "\x12last_accessed_time\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\x10lastAccessedTime\x12L\n" + + "\vclient_info\x18\x05 \x01(\v2+.memos.store.SessionsUserSetting.ClientInfoR\n" + + "clientInfo\x1a\xaf\x01\n" + + "\n" + + "ClientInfo\x12\x1d\n" + + "\n" + + "user_agent\x18\x01 \x01(\tR\tuserAgent\x12\x1d\n" + + "\n" + + "ip_address\x18\x02 \x01(\tR\tipAddress\x12\x1f\n" + + "\vdevice_type\x18\x03 \x01(\tR\n" + + "deviceType\x12\x0e\n" + + "\x02os\x18\x04 \x01(\tR\x02os\x12\x18\n" + + "\abrowser\x18\x05 \x01(\tR\abrowser\x12\x18\n" + + "\acountry\x18\x06 \x01(\tR\acountry*\x93\x01\n" + "\x0eUserSettingKey\x12 \n" + "\x1cUSER_SETTING_KEY_UNSPECIFIED\x10\x00\x12\x11\n" + "\rACCESS_TOKENS\x10\x01\x12\n" + @@ -468,7 +728,8 @@ const file_store_user_setting_proto_rawDesc = "" + "\n" + "APPEARANCE\x10\x03\x12\x13\n" + "\x0fMEMO_VISIBILITY\x10\x04\x12\r\n" + - "\tSHORTCUTS\x10\x05B\x9b\x01\n" + + "\tSHORTCUTS\x10\x05\x12\f\n" + + "\bSESSIONS\x10\x06B\x9b\x01\n" + "\x0fcom.memos.storeB\x10UserSettingProtoP\x01Z)github.com/usememos/memos/proto/gen/store\xa2\x02\x03MSX\xaa\x02\vMemos.Store\xca\x02\vMemos\\Store\xe2\x02\x17Memos\\Store\\GPBMetadata\xea\x02\fMemos::Storeb\x06proto3" var ( @@ -484,26 +745,36 @@ func file_store_user_setting_proto_rawDescGZIP() []byte { } var file_store_user_setting_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_store_user_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_store_user_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_store_user_setting_proto_goTypes = []any{ (UserSettingKey)(0), // 0: memos.store.UserSettingKey (*UserSetting)(nil), // 1: memos.store.UserSetting (*AccessTokensUserSetting)(nil), // 2: memos.store.AccessTokensUserSetting (*ShortcutsUserSetting)(nil), // 3: memos.store.ShortcutsUserSetting - (*AccessTokensUserSetting_AccessToken)(nil), // 4: memos.store.AccessTokensUserSetting.AccessToken - (*ShortcutsUserSetting_Shortcut)(nil), // 5: memos.store.ShortcutsUserSetting.Shortcut + (*SessionsUserSetting)(nil), // 4: memos.store.SessionsUserSetting + (*AccessTokensUserSetting_AccessToken)(nil), // 5: memos.store.AccessTokensUserSetting.AccessToken + (*ShortcutsUserSetting_Shortcut)(nil), // 6: memos.store.ShortcutsUserSetting.Shortcut + (*SessionsUserSetting_Session)(nil), // 7: memos.store.SessionsUserSetting.Session + (*SessionsUserSetting_ClientInfo)(nil), // 8: memos.store.SessionsUserSetting.ClientInfo + (*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp } var file_store_user_setting_proto_depIdxs = []int32{ - 0, // 0: memos.store.UserSetting.key:type_name -> memos.store.UserSettingKey - 2, // 1: memos.store.UserSetting.access_tokens:type_name -> memos.store.AccessTokensUserSetting - 3, // 2: memos.store.UserSetting.shortcuts:type_name -> memos.store.ShortcutsUserSetting - 4, // 3: memos.store.AccessTokensUserSetting.access_tokens:type_name -> memos.store.AccessTokensUserSetting.AccessToken - 5, // 4: memos.store.ShortcutsUserSetting.shortcuts:type_name -> memos.store.ShortcutsUserSetting.Shortcut - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 0, // 0: memos.store.UserSetting.key:type_name -> memos.store.UserSettingKey + 2, // 1: memos.store.UserSetting.access_tokens:type_name -> memos.store.AccessTokensUserSetting + 3, // 2: memos.store.UserSetting.shortcuts:type_name -> memos.store.ShortcutsUserSetting + 4, // 3: memos.store.UserSetting.sessions:type_name -> memos.store.SessionsUserSetting + 5, // 4: memos.store.AccessTokensUserSetting.access_tokens:type_name -> memos.store.AccessTokensUserSetting.AccessToken + 6, // 5: memos.store.ShortcutsUserSetting.shortcuts:type_name -> memos.store.ShortcutsUserSetting.Shortcut + 7, // 6: memos.store.SessionsUserSetting.sessions:type_name -> memos.store.SessionsUserSetting.Session + 9, // 7: memos.store.SessionsUserSetting.Session.create_time:type_name -> google.protobuf.Timestamp + 9, // 8: memos.store.SessionsUserSetting.Session.expire_time:type_name -> google.protobuf.Timestamp + 9, // 9: memos.store.SessionsUserSetting.Session.last_accessed_time:type_name -> google.protobuf.Timestamp + 8, // 10: memos.store.SessionsUserSetting.Session.client_info:type_name -> memos.store.SessionsUserSetting.ClientInfo + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_store_user_setting_proto_init() } @@ -517,6 +788,7 @@ func file_store_user_setting_proto_init() { (*UserSetting_Appearance)(nil), (*UserSetting_MemoVisibility)(nil), (*UserSetting_Shortcuts)(nil), + (*UserSetting_Sessions)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -524,7 +796,7 @@ func file_store_user_setting_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_user_setting_proto_rawDesc), len(file_store_user_setting_proto_rawDesc)), NumEnums: 1, - NumMessages: 5, + NumMessages: 8, NumExtensions: 0, NumServices: 0, }, diff --git a/proto/store/user_setting.proto b/proto/store/user_setting.proto index 5e2d4566f..9f2ae877d 100644 --- a/proto/store/user_setting.proto +++ b/proto/store/user_setting.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package memos.store; +import "google/protobuf/timestamp.proto"; + option go_package = "gen/store"; enum UserSettingKey { @@ -16,6 +18,8 @@ enum UserSettingKey { MEMO_VISIBILITY = 4; // The shortcuts of the user. SHORTCUTS = 5; + // User authentication sessions. + SESSIONS = 6; } message UserSetting { @@ -27,6 +31,7 @@ message UserSetting { string appearance = 5; string memo_visibility = 6; ShortcutsUserSetting shortcuts = 7; + SessionsUserSetting sessions = 8; } } @@ -49,3 +54,35 @@ message ShortcutsUserSetting { } repeated Shortcut shortcuts = 1; } + +message SessionsUserSetting { + message Session { + // Unique session identifier. + string session_id = 1; + // Timestamp when the session was created. + google.protobuf.Timestamp create_time = 2; + // Timestamp when the session expires. + google.protobuf.Timestamp expire_time = 3; + // Timestamp when the session was last accessed. + google.protobuf.Timestamp last_accessed_time = 4; + // Client information associated with this session. + ClientInfo client_info = 5; + } + + message ClientInfo { + // User agent string of the client. + string user_agent = 1; + // IP address of the client. + string ip_address = 2; + // Optional. Device type (e.g., "mobile", "desktop", "tablet"). + string device_type = 3; + // Optional. Operating system (e.g., "iOS 17.0", "Windows 11"). + string os = 4; + // Optional. Browser name and version (e.g., "Chrome 119.0"). + string browser = 5; + // Optional. Geographic location (country code, e.g., "US"). + string country = 6; + } + + repeated Session sessions = 1; +} diff --git a/server/router/api/v1/acl_config.go b/server/router/api/v1/acl_config.go index dc1fadeab..7de891678 100644 --- a/server/router/api/v1/acl_config.go +++ b/server/router/api/v1/acl_config.go @@ -5,9 +5,9 @@ var authenticationAllowlistMethods = map[string]bool{ "/memos.api.v1.WorkspaceService/GetWorkspaceSetting": true, "/memos.api.v1.IdentityProviderService/GetIdentityProvider": true, "/memos.api.v1.IdentityProviderService/ListIdentityProviders": true, - "/memos.api.v1.AuthService/GetAuthStatus": true, + "/memos.api.v1.AuthService/GetCurrentSession": true, "/memos.api.v1.AuthService/CreateSession": true, - "/memos.api.v1.AuthService/RegisterUser": true, + "/memos.api.v1.AuthService/SignUp": true, "/memos.api.v1.AuthService/DeleteSession": true, "/memos.api.v1.UserService/GetUser": true, "/memos.api.v1.UserService/GetUserAvatar": true, diff --git a/server/router/api/v1/auth_service.go b/server/router/api/v1/auth_service.go index 58f7fe294..bb87a9701 100644 --- a/server/router/api/v1/auth_service.go +++ b/server/router/api/v1/auth_service.go @@ -29,7 +29,7 @@ const ( unmatchedUsernameAndPasswordError = "unmatched username and password" ) -func (s *APIV1Service) GetAuthStatus(ctx context.Context, _ *v1pb.GetAuthStatusRequest) (*v1pb.User, error) { +func (s *APIV1Service) GetCurrentSession(ctx context.Context, _ *v1pb.GetCurrentSessionRequest) (*v1pb.User, error) { user, err := s.GetCurrentUser(ctx) if err != nil { return nil, status.Errorf(codes.Unauthenticated, "failed to get current user: %v", err) @@ -189,7 +189,7 @@ func (s *APIV1Service) doSignIn(ctx context.Context, user *store.User, expireTim return nil } -func (s *APIV1Service) RegisterUser(ctx context.Context, request *v1pb.RegisterUserRequest) (*v1pb.User, error) { +func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest) (*v1pb.User, error) { workspaceGeneralSetting, err := s.Store.GetWorkspaceGeneralSetting(ctx) if err != nil { return nil, status.Errorf(codes.Internal, "failed to get workspace general setting, error: %v", err) diff --git a/web/src/pages/SignUp.tsx b/web/src/pages/SignUp.tsx index b27b0cb42..7dc6af4f4 100644 --- a/web/src/pages/SignUp.tsx +++ b/web/src/pages/SignUp.tsx @@ -47,7 +47,7 @@ const SignUp = observer(() => { try { actionBtnLoadingState.setLoading(); - await authServiceClient.registerUser({ username, password }); + await authServiceClient.signUp({ username, password }); await initialUserStore(); navigateTo("/"); } catch (error: any) { diff --git a/web/src/store/v2/user.ts b/web/src/store/v2/user.ts index f7b25300e..f8e4f96da 100644 --- a/web/src/store/v2/user.ts +++ b/web/src/store/v2/user.ts @@ -231,7 +231,7 @@ const userStore = (() => { export const initialUserStore = async () => { try { - const currentUser = await authServiceClient.getAuthStatus({}); + const currentUser = await authServiceClient.getCurrentSession({}); const userSetting = await userServiceClient.getUserSetting({ name: currentUser.name }); userStore.state.setPartial({ currentUser: currentUser.name, diff --git a/web/src/types/proto/api/v1/auth_service.ts b/web/src/types/proto/api/v1/auth_service.ts index 02fa1c626..06978e593 100644 --- a/web/src/types/proto/api/v1/auth_service.ts +++ b/web/src/types/proto/api/v1/auth_service.ts @@ -11,10 +11,10 @@ import { User } from "./user_service"; export const protobufPackage = "memos.api.v1"; -export interface GetAuthStatusRequest { +export interface GetCurrentSessionRequest { } -export interface GetAuthStatusResponse { +export interface GetCurrentSessionResponse { user?: User | undefined; } @@ -65,7 +65,10 @@ export interface SSOCredentials { redirectUri: string; } -export interface RegisterUserRequest { +export interface DeleteSessionRequest { +} + +export interface SignUpRequest { /** * The username to sign up with. * Required field that must be unique across the system. @@ -78,22 +81,19 @@ export interface RegisterUserRequest { password: string; } -export interface DeleteSessionRequest { -} - -function createBaseGetAuthStatusRequest(): GetAuthStatusRequest { +function createBaseGetCurrentSessionRequest(): GetCurrentSessionRequest { return {}; } -export const GetAuthStatusRequest: MessageFns = { - encode(_: GetAuthStatusRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { +export const GetCurrentSessionRequest: MessageFns = { + encode(_: GetCurrentSessionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): GetAuthStatusRequest { + decode(input: BinaryReader | Uint8Array, length?: number): GetCurrentSessionRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseGetAuthStatusRequest(); + const message = createBaseGetCurrentSessionRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -106,31 +106,31 @@ export const GetAuthStatusRequest: MessageFns = { return message; }, - create(base?: DeepPartial): GetAuthStatusRequest { - return GetAuthStatusRequest.fromPartial(base ?? {}); + create(base?: DeepPartial): GetCurrentSessionRequest { + return GetCurrentSessionRequest.fromPartial(base ?? {}); }, - fromPartial(_: DeepPartial): GetAuthStatusRequest { - const message = createBaseGetAuthStatusRequest(); + fromPartial(_: DeepPartial): GetCurrentSessionRequest { + const message = createBaseGetCurrentSessionRequest(); return message; }, }; -function createBaseGetAuthStatusResponse(): GetAuthStatusResponse { +function createBaseGetCurrentSessionResponse(): GetCurrentSessionResponse { return { user: undefined }; } -export const GetAuthStatusResponse: MessageFns = { - encode(message: GetAuthStatusResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { +export const GetCurrentSessionResponse: MessageFns = { + encode(message: GetCurrentSessionResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.user !== undefined) { User.encode(message.user, writer.uint32(10).fork()).join(); } return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): GetAuthStatusResponse { + decode(input: BinaryReader | Uint8Array, length?: number): GetCurrentSessionResponse { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseGetAuthStatusResponse(); + const message = createBaseGetCurrentSessionResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -151,11 +151,11 @@ export const GetAuthStatusResponse: MessageFns = { return message; }, - create(base?: DeepPartial): GetAuthStatusResponse { - return GetAuthStatusResponse.fromPartial(base ?? {}); + create(base?: DeepPartial): GetCurrentSessionResponse { + return GetCurrentSessionResponse.fromPartial(base ?? {}); }, - fromPartial(object: DeepPartial): GetAuthStatusResponse { - const message = createBaseGetAuthStatusResponse(); + fromPartial(object: DeepPartial): GetCurrentSessionResponse { + const message = createBaseGetCurrentSessionResponse(); message.user = (object.user !== undefined && object.user !== null) ? User.fromPartial(object.user) : undefined; return message; }, @@ -363,12 +363,46 @@ export const SSOCredentials: MessageFns = { }, }; -function createBaseRegisterUserRequest(): RegisterUserRequest { +function createBaseDeleteSessionRequest(): DeleteSessionRequest { + return {}; +} + +export const DeleteSessionRequest: MessageFns = { + encode(_: DeleteSessionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { + return writer; + }, + + decode(input: BinaryReader | Uint8Array, length?: number): DeleteSessionRequest { + const reader = input instanceof BinaryReader ? input : new BinaryReader(input); + let end = length === undefined ? reader.len : reader.pos + length; + const message = createBaseDeleteSessionRequest(); + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + } + if ((tag & 7) === 4 || tag === 0) { + break; + } + reader.skip(tag & 7); + } + return message; + }, + + create(base?: DeepPartial): DeleteSessionRequest { + return DeleteSessionRequest.fromPartial(base ?? {}); + }, + fromPartial(_: DeepPartial): DeleteSessionRequest { + const message = createBaseDeleteSessionRequest(); + return message; + }, +}; + +function createBaseSignUpRequest(): SignUpRequest { return { username: "", password: "" }; } -export const RegisterUserRequest: MessageFns = { - encode(message: RegisterUserRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { +export const SignUpRequest: MessageFns = { + encode(message: SignUpRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { if (message.username !== "") { writer.uint32(10).string(message.username); } @@ -378,10 +412,10 @@ export const RegisterUserRequest: MessageFns = { return writer; }, - decode(input: BinaryReader | Uint8Array, length?: number): RegisterUserRequest { + decode(input: BinaryReader | Uint8Array, length?: number): SignUpRequest { const reader = input instanceof BinaryReader ? input : new BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseRegisterUserRequest(); + const message = createBaseSignUpRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -410,63 +444,29 @@ export const RegisterUserRequest: MessageFns = { return message; }, - create(base?: DeepPartial): RegisterUserRequest { - return RegisterUserRequest.fromPartial(base ?? {}); + create(base?: DeepPartial): SignUpRequest { + return SignUpRequest.fromPartial(base ?? {}); }, - fromPartial(object: DeepPartial): RegisterUserRequest { - const message = createBaseRegisterUserRequest(); + fromPartial(object: DeepPartial): SignUpRequest { + const message = createBaseSignUpRequest(); message.username = object.username ?? ""; message.password = object.password ?? ""; return message; }, }; -function createBaseDeleteSessionRequest(): DeleteSessionRequest { - return {}; -} - -export const DeleteSessionRequest: MessageFns = { - encode(_: DeleteSessionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { - return writer; - }, - - decode(input: BinaryReader | Uint8Array, length?: number): DeleteSessionRequest { - const reader = input instanceof BinaryReader ? input : new BinaryReader(input); - let end = length === undefined ? reader.len : reader.pos + length; - const message = createBaseDeleteSessionRequest(); - while (reader.pos < end) { - const tag = reader.uint32(); - switch (tag >>> 3) { - } - if ((tag & 7) === 4 || tag === 0) { - break; - } - reader.skip(tag & 7); - } - return message; - }, - - create(base?: DeepPartial): DeleteSessionRequest { - return DeleteSessionRequest.fromPartial(base ?? {}); - }, - fromPartial(_: DeepPartial): DeleteSessionRequest { - const message = createBaseDeleteSessionRequest(); - return message; - }, -}; - export type AuthServiceDefinition = typeof AuthServiceDefinition; export const AuthServiceDefinition = { name: "AuthService", fullName: "memos.api.v1.AuthService", methods: { /** - * GetAuthStatus returns the current authentication status of the user. - * This method is idempotent and safe, suitable for checking authentication state. + * GetCurrentSession returns the current active session information. + * This method is idempotent and safe, suitable for checking current session state. */ - getAuthStatus: { - name: "GetAuthStatus", - requestType: GetAuthStatusRequest, + getCurrentSession: { + name: "GetCurrentSession", + requestType: GetCurrentSessionRequest, requestStream: false, responseType: User, responseStream: false, @@ -474,9 +474,9 @@ export const AuthServiceDefinition = { _unknownFields: { 578365826: [ new Uint8Array([ - 21, + 31, 18, - 19, + 29, 47, 97, 112, @@ -491,11 +491,21 @@ export const AuthServiceDefinition = { 104, 47, 115, - 116, - 97, - 116, - 117, + 101, + 115, 115, + 105, + 111, + 110, + 115, + 47, + 99, + 117, + 114, + 114, + 101, + 110, + 116, ]), ], }, @@ -548,25 +558,22 @@ export const AuthServiceDefinition = { }, }, /** - * RegisterUser creates a new user account with username and password. - * Returns the newly created user information upon successful registration. + * DeleteSession terminates the current user session. + * This is an idempotent operation that invalidates the user's authentication. */ - registerUser: { - name: "RegisterUser", - requestType: RegisterUserRequest, + deleteSession: { + name: "DeleteSession", + requestType: DeleteSessionRequest, requestStream: false, - responseType: User, + responseType: Empty, responseStream: false, options: { _unknownFields: { 578365826: [ new Uint8Array([ - 23, - 58, - 1, + 31, 42, - 34, - 18, + 29, 47, 97, 112, @@ -580,33 +587,47 @@ export const AuthServiceDefinition = { 116, 104, 47, - 117, 115, 101, - 114, 115, + 115, + 105, + 111, + 110, + 115, + 47, + 99, + 117, + 114, + 114, + 101, + 110, + 116, ]), ], }, }, }, /** - * DeleteSession terminates the current user session. - * This is an idempotent operation that invalidates the user's authentication. + * SignUp creates a new user account with username and password. + * Returns the newly created user information upon successful registration. */ - deleteSession: { - name: "DeleteSession", - requestType: DeleteSessionRequest, + signUp: { + name: "SignUp", + requestType: SignUpRequest, requestStream: false, - responseType: Empty, + responseType: User, responseStream: false, options: { _unknownFields: { 578365826: [ new Uint8Array([ - 31, + 24, + 58, + 1, 42, - 29, + 34, + 19, 47, 97, 112, @@ -621,21 +642,11 @@ export const AuthServiceDefinition = { 104, 47, 115, - 101, - 115, - 115, 105, - 111, + 103, 110, - 115, - 47, - 99, 117, - 114, - 114, - 101, - 110, - 116, + 112, ]), ], },