From 6db8611a585af28a03147655906bc20c5bf96b46 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 6 Aug 2024 21:56:00 +0800 Subject: [PATCH] chore: update auth service --- frontend/web/src/pages/SignIn.tsx | 2 +- frontend/web/src/pages/SignUp.tsx | 2 +- frontend/web/src/stores/user.ts | 2 +- proto/api/v1/auth_service.proto | 36 +- proto/buf.yaml | 2 +- proto/gen/api/v1/README.md | 62 +--- proto/gen/api/v1/auth_service.pb.go | 423 ++++++++--------------- proto/gen/api/v1/auth_service.pb.gw.go | 87 +++++ proto/gen/api/v1/auth_service_grpc.pb.go | 89 +++-- proto/gen/apidocs.swagger.yaml | 62 ++-- server/route/api/v1/auth_service.go | 24 +- 11 files changed, 377 insertions(+), 414 deletions(-) diff --git a/frontend/web/src/pages/SignIn.tsx b/frontend/web/src/pages/SignIn.tsx index 27f882d..8fcfdd1 100644 --- a/frontend/web/src/pages/SignIn.tsx +++ b/frontend/web/src/pages/SignIn.tsx @@ -44,7 +44,7 @@ const SignIn: React.FC = () => { try { actionBtnLoadingState.setLoading(); - const { user } = await authServiceClient.signIn({ email, password }); + const user = await authServiceClient.signIn({ email, password }); if (user) { userStore.setCurrentUserId(user.id); await userStore.fetchCurrentUser(); diff --git a/frontend/web/src/pages/SignUp.tsx b/frontend/web/src/pages/SignUp.tsx index 2b32f4f..e1ab923 100644 --- a/frontend/web/src/pages/SignUp.tsx +++ b/frontend/web/src/pages/SignUp.tsx @@ -51,7 +51,7 @@ const SignUp: React.FC = () => { try { actionBtnLoadingState.setLoading(); - const { user } = await authServiceClient.signUp({ + const user = await authServiceClient.signUp({ email, nickname, password, diff --git a/frontend/web/src/stores/user.ts b/frontend/web/src/stores/user.ts index 05d71bd..bedfcdc 100644 --- a/frontend/web/src/stores/user.ts +++ b/frontend/web/src/stores/user.ts @@ -38,7 +38,7 @@ const useUserStore = create()((set, get) => ({ return users; }, fetchCurrentUser: async () => { - const { user } = await authServiceClient.getAuthStatus({}); + const user = await authServiceClient.getAuthStatus({}); if (!user) { throw new Error("User not found"); } diff --git a/proto/api/v1/auth_service.proto b/proto/api/v1/auth_service.proto index 3730725..49d0b86 100644 --- a/proto/api/v1/auth_service.proto +++ b/proto/api/v1/auth_service.proto @@ -4,49 +4,53 @@ package slash.api.v1; import "api/v1/user_service.proto"; import "google/api/annotations.proto"; +import "google/protobuf/empty.proto"; option go_package = "gen/api/v1"; service AuthService { - rpc GetAuthStatus(GetAuthStatusRequest) returns (GetAuthStatusResponse) { + // GetAuthStatus returns the current auth status of the user. + rpc GetAuthStatus(GetAuthStatusRequest) returns (User) { option (google.api.http) = {post: "/api/v1/auth/status"}; } - rpc SignIn(SignInRequest) returns (SignInResponse) { + // SignIn signs in the user with the given username and password. + rpc SignIn(SignInRequest) returns (User) { option (google.api.http) = {post: "/api/v1/auth/signin"}; } - rpc SignUp(SignUpRequest) returns (SignUpResponse) { + // SignInWithSSO signs in the user with the given SSO code. + rpc SignInWithSSO(SignInWithSSORequest) returns (User) { + option (google.api.http) = {post: "/api/v1/auth/signin/sso"}; + } + // SignUp signs up the user with the given username and password. + rpc SignUp(SignUpRequest) returns (User) { option (google.api.http) = {post: "/api/v1/auth/signup"}; } - rpc SignOut(SignOutRequest) returns (SignOutResponse) { + // SignOut signs out the user. + rpc SignOut(SignOutRequest) returns (google.protobuf.Empty) { option (google.api.http) = {post: "/api/v1/auth/signout"}; } } message GetAuthStatusRequest {} -message GetAuthStatusResponse { - User user = 1; -} - message SignInRequest { string email = 1; string password = 2; } -message SignInResponse { - User user = 1; -} - message SignUpRequest { string email = 1; string nickname = 2; string password = 3; } -message SignUpResponse { - User user = 1; +message SignInWithSSORequest { + // The name of the SSO provider. + int32 idp_name = 1; + // The code to sign in with. + string code = 2; + // The redirect URI. + string redirect_uri = 3; } message SignOutRequest {} - -message SignOutResponse {} diff --git a/proto/buf.yaml b/proto/buf.yaml index 1508df9..cc13421 100644 --- a/proto/buf.yaml +++ b/proto/buf.yaml @@ -5,7 +5,7 @@ breaking: - FILE lint: use: - - DEFAULT + - BASIC except: - ENUM_VALUE_PREFIX - PACKAGE_DIRECTORY_MATCH diff --git a/proto/gen/api/v1/README.md b/proto/gen/api/v1/README.md index 32d9bb0..b5569cb 100644 --- a/proto/gen/api/v1/README.md +++ b/proto/gen/api/v1/README.md @@ -33,13 +33,10 @@ - [api/v1/auth_service.proto](#api_v1_auth_service-proto) - [GetAuthStatusRequest](#slash-api-v1-GetAuthStatusRequest) - - [GetAuthStatusResponse](#slash-api-v1-GetAuthStatusResponse) - [SignInRequest](#slash-api-v1-SignInRequest) - - [SignInResponse](#slash-api-v1-SignInResponse) + - [SignInWithSSORequest](#slash-api-v1-SignInWithSSORequest) - [SignOutRequest](#slash-api-v1-SignOutRequest) - - [SignOutResponse](#slash-api-v1-SignOutResponse) - [SignUpRequest](#slash-api-v1-SignUpRequest) - - [SignUpResponse](#slash-api-v1-SignUpResponse) - [AuthService](#slash-api-v1-AuthService) @@ -501,21 +498,6 @@ - - -### GetAuthStatusResponse - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| user | [User](#slash-api-v1-User) | | | - - - - - - ### SignInRequest @@ -532,15 +514,17 @@ - + -### SignInResponse +### SignInWithSSORequest | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| user | [User](#slash-api-v1-User) | | | +| idp_name | [int32](#int32) | | The name of the SSO provider. | +| code | [string](#string) | | The code to sign in with. | +| redirect_uri | [string](#string) | | The redirect URI. | @@ -557,16 +541,6 @@ - - -### SignOutResponse - - - - - - - ### SignUpRequest @@ -583,21 +557,6 @@ - - - -### SignUpResponse - - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| user | [User](#slash-api-v1-User) | | | - - - - - @@ -612,10 +571,11 @@ | Method Name | Request Type | Response Type | Description | | ----------- | ------------ | ------------- | ------------| -| GetAuthStatus | [GetAuthStatusRequest](#slash-api-v1-GetAuthStatusRequest) | [GetAuthStatusResponse](#slash-api-v1-GetAuthStatusResponse) | | -| SignIn | [SignInRequest](#slash-api-v1-SignInRequest) | [SignInResponse](#slash-api-v1-SignInResponse) | | -| SignUp | [SignUpRequest](#slash-api-v1-SignUpRequest) | [SignUpResponse](#slash-api-v1-SignUpResponse) | | -| SignOut | [SignOutRequest](#slash-api-v1-SignOutRequest) | [SignOutResponse](#slash-api-v1-SignOutResponse) | | +| GetAuthStatus | [GetAuthStatusRequest](#slash-api-v1-GetAuthStatusRequest) | [User](#slash-api-v1-User) | GetAuthStatus returns the current auth status of the user. | +| SignIn | [SignInRequest](#slash-api-v1-SignInRequest) | [User](#slash-api-v1-User) | SignIn signs in the user with the given username and password. | +| SignInWithSSO | [SignInWithSSORequest](#slash-api-v1-SignInWithSSORequest) | [User](#slash-api-v1-User) | SignInWithSSO signs in the user with the given SSO code. | +| SignUp | [SignUpRequest](#slash-api-v1-SignUpRequest) | [User](#slash-api-v1-User) | SignUp signs up the user with the given username and password. | +| SignOut | [SignOutRequest](#slash-api-v1-SignOutRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | SignOut signs out the user. | diff --git a/proto/gen/api/v1/auth_service.pb.go b/proto/gen/api/v1/auth_service.pb.go index 9ff6cdd..b8f4aa2 100644 --- a/proto/gen/api/v1/auth_service.pb.go +++ b/proto/gen/api/v1/auth_service.pb.go @@ -10,6 +10,7 @@ import ( _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" ) @@ -59,53 +60,6 @@ func (*GetAuthStatusRequest) Descriptor() ([]byte, []int) { return file_api_v1_auth_service_proto_rawDescGZIP(), []int{0} } -type GetAuthStatusResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` -} - -func (x *GetAuthStatusResponse) Reset() { - *x = GetAuthStatusResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_v1_auth_service_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *GetAuthStatusResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*GetAuthStatusResponse) ProtoMessage() {} - -func (x *GetAuthStatusResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_v1_auth_service_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use GetAuthStatusResponse.ProtoReflect.Descriptor instead. -func (*GetAuthStatusResponse) Descriptor() ([]byte, []int) { - return file_api_v1_auth_service_proto_rawDescGZIP(), []int{1} -} - -func (x *GetAuthStatusResponse) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - type SignInRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -118,7 +72,7 @@ type SignInRequest struct { func (x *SignInRequest) Reset() { *x = SignInRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_v1_auth_service_proto_msgTypes[2] + mi := &file_api_v1_auth_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -131,7 +85,7 @@ func (x *SignInRequest) String() string { func (*SignInRequest) ProtoMessage() {} func (x *SignInRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_v1_auth_service_proto_msgTypes[2] + mi := &file_api_v1_auth_service_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -144,7 +98,7 @@ func (x *SignInRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SignInRequest.ProtoReflect.Descriptor instead. func (*SignInRequest) Descriptor() ([]byte, []int) { - return file_api_v1_auth_service_proto_rawDescGZIP(), []int{2} + return file_api_v1_auth_service_proto_rawDescGZIP(), []int{1} } func (x *SignInRequest) GetEmail() string { @@ -161,53 +115,6 @@ func (x *SignInRequest) GetPassword() string { return "" } -type SignInResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` -} - -func (x *SignInResponse) Reset() { - *x = SignInResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_v1_auth_service_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SignInResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SignInResponse) ProtoMessage() {} - -func (x *SignInResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_v1_auth_service_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SignInResponse.ProtoReflect.Descriptor instead. -func (*SignInResponse) Descriptor() ([]byte, []int) { - return file_api_v1_auth_service_proto_rawDescGZIP(), []int{3} -} - -func (x *SignInResponse) GetUser() *User { - if x != nil { - return x.User - } - return nil -} - type SignUpRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -221,7 +128,7 @@ type SignUpRequest struct { func (x *SignUpRequest) Reset() { *x = SignUpRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_v1_auth_service_proto_msgTypes[4] + mi := &file_api_v1_auth_service_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -234,7 +141,7 @@ func (x *SignUpRequest) String() string { func (*SignUpRequest) ProtoMessage() {} func (x *SignUpRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_v1_auth_service_proto_msgTypes[4] + mi := &file_api_v1_auth_service_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -247,7 +154,7 @@ func (x *SignUpRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SignUpRequest.ProtoReflect.Descriptor instead. func (*SignUpRequest) Descriptor() ([]byte, []int) { - return file_api_v1_auth_service_proto_rawDescGZIP(), []int{4} + return file_api_v1_auth_service_proto_rawDescGZIP(), []int{2} } func (x *SignUpRequest) GetEmail() string { @@ -271,31 +178,36 @@ func (x *SignUpRequest) GetPassword() string { return "" } -type SignUpResponse struct { +type SignInWithSSORequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + // The name of the SSO provider. + IdpName int32 `protobuf:"varint,1,opt,name=idp_name,json=idpName,proto3" json:"idp_name,omitempty"` + // The code to sign in with. + Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` + // The redirect URI. + RedirectUri string `protobuf:"bytes,3,opt,name=redirect_uri,json=redirectUri,proto3" json:"redirect_uri,omitempty"` } -func (x *SignUpResponse) Reset() { - *x = SignUpResponse{} +func (x *SignInWithSSORequest) Reset() { + *x = SignInWithSSORequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_v1_auth_service_proto_msgTypes[5] + mi := &file_api_v1_auth_service_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } } -func (x *SignUpResponse) String() string { +func (x *SignInWithSSORequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*SignUpResponse) ProtoMessage() {} +func (*SignInWithSSORequest) ProtoMessage() {} -func (x *SignUpResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_v1_auth_service_proto_msgTypes[5] +func (x *SignInWithSSORequest) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_auth_service_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -306,16 +218,30 @@ func (x *SignUpResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use SignUpResponse.ProtoReflect.Descriptor instead. -func (*SignUpResponse) Descriptor() ([]byte, []int) { - return file_api_v1_auth_service_proto_rawDescGZIP(), []int{5} +// Deprecated: Use SignInWithSSORequest.ProtoReflect.Descriptor instead. +func (*SignInWithSSORequest) Descriptor() ([]byte, []int) { + return file_api_v1_auth_service_proto_rawDescGZIP(), []int{3} } -func (x *SignUpResponse) GetUser() *User { +func (x *SignInWithSSORequest) GetIdpName() int32 { if x != nil { - return x.User + return x.IdpName } - return nil + return 0 +} + +func (x *SignInWithSSORequest) GetCode() string { + if x != nil { + return x.Code + } + return "" +} + +func (x *SignInWithSSORequest) GetRedirectUri() string { + if x != nil { + return x.RedirectUri + } + return "" } type SignOutRequest struct { @@ -327,7 +253,7 @@ type SignOutRequest struct { func (x *SignOutRequest) Reset() { *x = SignOutRequest{} if protoimpl.UnsafeEnabled { - mi := &file_api_v1_auth_service_proto_msgTypes[6] + mi := &file_api_v1_auth_service_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -340,7 +266,7 @@ func (x *SignOutRequest) String() string { func (*SignOutRequest) ProtoMessage() {} func (x *SignOutRequest) ProtoReflect() protoreflect.Message { - mi := &file_api_v1_auth_service_proto_msgTypes[6] + mi := &file_api_v1_auth_service_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -353,45 +279,7 @@ func (x *SignOutRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SignOutRequest.ProtoReflect.Descriptor instead. func (*SignOutRequest) Descriptor() ([]byte, []int) { - return file_api_v1_auth_service_proto_rawDescGZIP(), []int{6} -} - -type SignOutResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *SignOutResponse) Reset() { - *x = SignOutResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_api_v1_auth_service_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *SignOutResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*SignOutResponse) ProtoMessage() {} - -func (x *SignOutResponse) ProtoReflect() protoreflect.Message { - mi := &file_api_v1_auth_service_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use SignOutResponse.ProtoReflect.Descriptor instead. -func (*SignOutResponse) Descriptor() ([]byte, []int) { - return file_api_v1_auth_service_proto_rawDescGZIP(), []int{7} + return file_api_v1_auth_service_proto_rawDescGZIP(), []int{4} } var File_api_v1_auth_service_proto protoreflect.FileDescriptor @@ -403,70 +291,70 @@ var file_api_v1_auth_service_proto_rawDesc = []byte{ 0x31, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0x16, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x3f, 0x0a, 0x15, 0x47, 0x65, - 0x74, 0x41, 0x75, 0x74, 0x68, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, - 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x41, 0x0a, 0x0d, 0x53, - 0x69, 0x67, 0x6e, 0x49, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, - 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, - 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x38, - 0x0a, 0x0e, 0x53, 0x69, 0x67, 0x6e, 0x49, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x26, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, - 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x5d, 0x0a, 0x0d, 0x53, 0x69, 0x67, 0x6e, - 0x55, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, - 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, - 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, - 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, - 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x38, 0x0a, 0x0e, 0x53, 0x69, 0x67, 0x6e, 0x55, - 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x04, 0x75, 0x73, 0x65, - 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, - 0x72, 0x22, 0x10, 0x0a, 0x0e, 0x53, 0x69, 0x67, 0x6e, 0x4f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x22, 0x11, 0x0a, 0x0f, 0x53, 0x69, 0x67, 0x6e, 0x4f, 0x75, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xae, 0x03, 0x0a, 0x0b, 0x41, 0x75, 0x74, 0x68, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x75, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, - 0x68, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x22, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x73, 0x6c, - 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x75, - 0x74, 0x68, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x22, 0x13, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, - 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x60, 0x0a, - 0x06, 0x53, 0x69, 0x67, 0x6e, 0x49, 0x6e, 0x12, 0x1b, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, - 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x49, 0x6e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, - 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x49, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x22, 0x13, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x12, - 0x60, 0x0a, 0x06, 0x53, 0x69, 0x67, 0x6e, 0x55, 0x70, 0x12, 0x1b, 0x2e, 0x73, 0x6c, 0x61, 0x73, - 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x55, 0x70, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, - 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x55, 0x70, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x22, 0x13, 0x2f, 0x61, - 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x75, - 0x70, 0x12, 0x64, 0x0a, 0x07, 0x53, 0x69, 0x67, 0x6e, 0x4f, 0x75, 0x74, 0x12, 0x1c, 0x2e, 0x73, - 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, - 0x4f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x73, 0x6c, 0x61, - 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4f, 0x75, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, - 0x16, 0x22, 0x14, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, - 0x73, 0x69, 0x67, 0x6e, 0x6f, 0x75, 0x74, 0x42, 0xae, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, - 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x10, 0x41, 0x75, - 0x74, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x75, - 0x72, 0x73, 0x65, 0x6c, 0x66, 0x68, 0x6f, 0x73, 0x74, 0x65, 0x64, 0x2f, 0x73, 0x6c, 0x61, 0x73, - 0x68, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, - 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x41, 0x58, 0xaa, 0x02, - 0x0c, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0c, - 0x53, 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x18, 0x53, - 0x6c, 0x61, 0x73, 0x68, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x3a, - 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x6f, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x16, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x41, 0x0a, 0x0d, 0x53, 0x69, 0x67, 0x6e, 0x49, + 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, + 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, + 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x5d, 0x0a, 0x0d, 0x53, 0x69, + 0x67, 0x6e, 0x55, 0x70, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, + 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, + 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x68, 0x0a, 0x14, 0x53, 0x69, 0x67, + 0x6e, 0x49, 0x6e, 0x57, 0x69, 0x74, 0x68, 0x53, 0x53, 0x4f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x64, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x07, 0x69, 0x64, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, + 0x12, 0x21, 0x0a, 0x0c, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x5f, 0x75, 0x72, 0x69, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, + 0x55, 0x72, 0x69, 0x22, 0x10, 0x0a, 0x0e, 0x53, 0x69, 0x67, 0x6e, 0x4f, 0x75, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x32, 0xec, 0x03, 0x0a, 0x0b, 0x41, 0x75, 0x74, 0x68, 0x53, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x64, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x22, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x41, 0x75, 0x74, 0x68, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x73, 0x6c, 0x61, + 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x1b, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x22, 0x13, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, + 0x61, 0x75, 0x74, 0x68, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x56, 0x0a, 0x06, 0x53, + 0x69, 0x67, 0x6e, 0x49, 0x6e, 0x12, 0x1b, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, + 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x49, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, 0x22, 0x13, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x73, 0x69, 0x67, + 0x6e, 0x69, 0x6e, 0x12, 0x68, 0x0a, 0x0d, 0x53, 0x69, 0x67, 0x6e, 0x49, 0x6e, 0x57, 0x69, 0x74, + 0x68, 0x53, 0x53, 0x4f, 0x12, 0x22, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x49, 0x6e, 0x57, 0x69, 0x74, 0x68, 0x53, 0x53, + 0x4f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x1f, 0x82, 0xd3, + 0xe4, 0x93, 0x02, 0x19, 0x22, 0x17, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, + 0x74, 0x68, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x2f, 0x73, 0x73, 0x6f, 0x12, 0x56, 0x0a, + 0x06, 0x53, 0x69, 0x67, 0x6e, 0x55, 0x70, 0x12, 0x1b, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, + 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x55, 0x70, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, + 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x22, 0x1b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x15, + 0x22, 0x13, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x73, + 0x69, 0x67, 0x6e, 0x75, 0x70, 0x12, 0x5d, 0x0a, 0x07, 0x53, 0x69, 0x67, 0x6e, 0x4f, 0x75, 0x74, + 0x12, 0x1c, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, + 0x53, 0x69, 0x67, 0x6e, 0x4f, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x22, 0x14, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x73, 0x69, 0x67, + 0x6e, 0x6f, 0x75, 0x74, 0x42, 0xae, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x6c, 0x61, + 0x73, 0x68, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x10, 0x41, 0x75, 0x74, 0x68, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x79, 0x6f, 0x75, 0x72, 0x73, 0x65, + 0x6c, 0x66, 0x68, 0x6f, 0x73, 0x74, 0x65, 0x64, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, + 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x53, 0x6c, + 0x61, 0x73, 0x68, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0c, 0x53, 0x6c, 0x61, + 0x73, 0x68, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x18, 0x53, 0x6c, 0x61, 0x73, + 0x68, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x3a, 0x3a, 0x41, 0x70, + 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -481,35 +369,32 @@ func file_api_v1_auth_service_proto_rawDescGZIP() []byte { return file_api_v1_auth_service_proto_rawDescData } -var file_api_v1_auth_service_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_api_v1_auth_service_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_api_v1_auth_service_proto_goTypes = []any{ - (*GetAuthStatusRequest)(nil), // 0: slash.api.v1.GetAuthStatusRequest - (*GetAuthStatusResponse)(nil), // 1: slash.api.v1.GetAuthStatusResponse - (*SignInRequest)(nil), // 2: slash.api.v1.SignInRequest - (*SignInResponse)(nil), // 3: slash.api.v1.SignInResponse - (*SignUpRequest)(nil), // 4: slash.api.v1.SignUpRequest - (*SignUpResponse)(nil), // 5: slash.api.v1.SignUpResponse - (*SignOutRequest)(nil), // 6: slash.api.v1.SignOutRequest - (*SignOutResponse)(nil), // 7: slash.api.v1.SignOutResponse - (*User)(nil), // 8: slash.api.v1.User + (*GetAuthStatusRequest)(nil), // 0: slash.api.v1.GetAuthStatusRequest + (*SignInRequest)(nil), // 1: slash.api.v1.SignInRequest + (*SignUpRequest)(nil), // 2: slash.api.v1.SignUpRequest + (*SignInWithSSORequest)(nil), // 3: slash.api.v1.SignInWithSSORequest + (*SignOutRequest)(nil), // 4: slash.api.v1.SignOutRequest + (*User)(nil), // 5: slash.api.v1.User + (*emptypb.Empty)(nil), // 6: google.protobuf.Empty } var file_api_v1_auth_service_proto_depIdxs = []int32{ - 8, // 0: slash.api.v1.GetAuthStatusResponse.user:type_name -> slash.api.v1.User - 8, // 1: slash.api.v1.SignInResponse.user:type_name -> slash.api.v1.User - 8, // 2: slash.api.v1.SignUpResponse.user:type_name -> slash.api.v1.User - 0, // 3: slash.api.v1.AuthService.GetAuthStatus:input_type -> slash.api.v1.GetAuthStatusRequest - 2, // 4: slash.api.v1.AuthService.SignIn:input_type -> slash.api.v1.SignInRequest - 4, // 5: slash.api.v1.AuthService.SignUp:input_type -> slash.api.v1.SignUpRequest - 6, // 6: slash.api.v1.AuthService.SignOut:input_type -> slash.api.v1.SignOutRequest - 1, // 7: slash.api.v1.AuthService.GetAuthStatus:output_type -> slash.api.v1.GetAuthStatusResponse - 3, // 8: slash.api.v1.AuthService.SignIn:output_type -> slash.api.v1.SignInResponse - 5, // 9: slash.api.v1.AuthService.SignUp:output_type -> slash.api.v1.SignUpResponse - 7, // 10: slash.api.v1.AuthService.SignOut:output_type -> slash.api.v1.SignOutResponse - 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 - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 0, // 0: slash.api.v1.AuthService.GetAuthStatus:input_type -> slash.api.v1.GetAuthStatusRequest + 1, // 1: slash.api.v1.AuthService.SignIn:input_type -> slash.api.v1.SignInRequest + 3, // 2: slash.api.v1.AuthService.SignInWithSSO:input_type -> slash.api.v1.SignInWithSSORequest + 2, // 3: slash.api.v1.AuthService.SignUp:input_type -> slash.api.v1.SignUpRequest + 4, // 4: slash.api.v1.AuthService.SignOut:input_type -> slash.api.v1.SignOutRequest + 5, // 5: slash.api.v1.AuthService.GetAuthStatus:output_type -> slash.api.v1.User + 5, // 6: slash.api.v1.AuthService.SignIn:output_type -> slash.api.v1.User + 5, // 7: slash.api.v1.AuthService.SignInWithSSO:output_type -> slash.api.v1.User + 5, // 8: slash.api.v1.AuthService.SignUp:output_type -> slash.api.v1.User + 6, // 9: slash.api.v1.AuthService.SignOut:output_type -> google.protobuf.Empty + 5, // [5:10] is the sub-list for method output_type + 0, // [0:5] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name } func init() { file_api_v1_auth_service_proto_init() } @@ -532,18 +417,6 @@ func file_api_v1_auth_service_proto_init() { } } file_api_v1_auth_service_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*GetAuthStatusResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_v1_auth_service_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*SignInRequest); i { case 0: return &v.state @@ -555,19 +428,7 @@ func file_api_v1_auth_service_proto_init() { return nil } } - file_api_v1_auth_service_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*SignInResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_api_v1_auth_service_proto_msgTypes[4].Exporter = func(v any, i int) any { + file_api_v1_auth_service_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*SignUpRequest); i { case 0: return &v.state @@ -579,8 +440,8 @@ func file_api_v1_auth_service_proto_init() { return nil } } - file_api_v1_auth_service_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*SignUpResponse); i { + file_api_v1_auth_service_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*SignInWithSSORequest); i { case 0: return &v.state case 1: @@ -591,7 +452,7 @@ func file_api_v1_auth_service_proto_init() { return nil } } - file_api_v1_auth_service_proto_msgTypes[6].Exporter = func(v any, i int) any { + file_api_v1_auth_service_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*SignOutRequest); i { case 0: return &v.state @@ -603,18 +464,6 @@ func file_api_v1_auth_service_proto_init() { return nil } } - file_api_v1_auth_service_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*SignOutResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } type x struct{} out := protoimpl.TypeBuilder{ @@ -622,7 +471,7 @@ func file_api_v1_auth_service_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_api_v1_auth_service_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 5, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/gen/api/v1/auth_service.pb.gw.go b/proto/gen/api/v1/auth_service.pb.gw.go index fcc7f1b..696b6fe 100644 --- a/proto/gen/api/v1/auth_service.pb.gw.go +++ b/proto/gen/api/v1/auth_service.pb.gw.go @@ -85,6 +85,42 @@ func local_request_AuthService_SignIn_0(ctx context.Context, marshaler runtime.M } +var ( + filter_AuthService_SignInWithSSO_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_AuthService_SignInWithSSO_0(ctx context.Context, marshaler runtime.Marshaler, client AuthServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SignInWithSSORequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_SignInWithSSO_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SignInWithSSO(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_AuthService_SignInWithSSO_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq SignInWithSSORequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_AuthService_SignInWithSSO_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SignInWithSSO(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_AuthService_SignUp_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -196,6 +232,31 @@ func RegisterAuthServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux }) + mux.Handle("POST", pattern_AuthService_SignInWithSSO_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) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/slash.api.v1.AuthService/SignInWithSSO", runtime.WithHTTPPathPattern("/api/v1/auth/signin/sso")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_AuthService_SignInWithSSO_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_SignInWithSSO_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("POST", pattern_AuthService_SignUp_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -331,6 +392,28 @@ func RegisterAuthServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux }) + mux.Handle("POST", pattern_AuthService_SignInWithSSO_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) + var err error + var annotatedContext context.Context + annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/slash.api.v1.AuthService/SignInWithSSO", runtime.WithHTTPPathPattern("/api/v1/auth/signin/sso")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_AuthService_SignInWithSSO_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_SignInWithSSO_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("POST", pattern_AuthService_SignUp_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -383,6 +466,8 @@ var ( pattern_AuthService_SignIn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "signin"}, "")) + pattern_AuthService_SignInWithSSO_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"api", "v1", "auth", "signin", "sso"}, "")) + pattern_AuthService_SignUp_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "signup"}, "")) pattern_AuthService_SignOut_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "auth", "signout"}, "")) @@ -393,6 +478,8 @@ var ( forward_AuthService_SignIn_0 = runtime.ForwardResponseMessage + forward_AuthService_SignInWithSSO_0 = runtime.ForwardResponseMessage + forward_AuthService_SignUp_0 = runtime.ForwardResponseMessage forward_AuthService_SignOut_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 d8cc830..e816761 100644 --- a/proto/gen/api/v1/auth_service_grpc.pb.go +++ b/proto/gen/api/v1/auth_service_grpc.pb.go @@ -11,6 +11,7 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -21,6 +22,7 @@ const _ = grpc.SupportPackageIsVersion9 const ( AuthService_GetAuthStatus_FullMethodName = "/slash.api.v1.AuthService/GetAuthStatus" AuthService_SignIn_FullMethodName = "/slash.api.v1.AuthService/SignIn" + AuthService_SignInWithSSO_FullMethodName = "/slash.api.v1.AuthService/SignInWithSSO" AuthService_SignUp_FullMethodName = "/slash.api.v1.AuthService/SignUp" AuthService_SignOut_FullMethodName = "/slash.api.v1.AuthService/SignOut" ) @@ -29,10 +31,16 @@ const ( // // 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(ctx context.Context, in *GetAuthStatusRequest, opts ...grpc.CallOption) (*GetAuthStatusResponse, error) - SignIn(ctx context.Context, in *SignInRequest, opts ...grpc.CallOption) (*SignInResponse, error) - SignUp(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*SignUpResponse, error) - SignOut(ctx context.Context, in *SignOutRequest, opts ...grpc.CallOption) (*SignOutResponse, error) + // GetAuthStatus returns the current auth status of the user. + GetAuthStatus(ctx context.Context, in *GetAuthStatusRequest, opts ...grpc.CallOption) (*User, error) + // SignIn signs in the user with the given username and password. + SignIn(ctx context.Context, in *SignInRequest, opts ...grpc.CallOption) (*User, error) + // SignInWithSSO signs in the user with the given SSO code. + SignInWithSSO(ctx context.Context, in *SignInWithSSORequest, opts ...grpc.CallOption) (*User, error) + // SignUp signs up the user with the given username and password. + SignUp(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*User, error) + // SignOut signs out the user. + SignOut(ctx context.Context, in *SignOutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) } type authServiceClient struct { @@ -43,9 +51,9 @@ func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient { return &authServiceClient{cc} } -func (c *authServiceClient) GetAuthStatus(ctx context.Context, in *GetAuthStatusRequest, opts ...grpc.CallOption) (*GetAuthStatusResponse, error) { +func (c *authServiceClient) GetAuthStatus(ctx context.Context, in *GetAuthStatusRequest, opts ...grpc.CallOption) (*User, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(GetAuthStatusResponse) + out := new(User) err := c.cc.Invoke(ctx, AuthService_GetAuthStatus_FullMethodName, in, out, cOpts...) if err != nil { return nil, err @@ -53,9 +61,9 @@ func (c *authServiceClient) GetAuthStatus(ctx context.Context, in *GetAuthStatus return out, nil } -func (c *authServiceClient) SignIn(ctx context.Context, in *SignInRequest, opts ...grpc.CallOption) (*SignInResponse, error) { +func (c *authServiceClient) SignIn(ctx context.Context, in *SignInRequest, opts ...grpc.CallOption) (*User, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(SignInResponse) + out := new(User) err := c.cc.Invoke(ctx, AuthService_SignIn_FullMethodName, in, out, cOpts...) if err != nil { return nil, err @@ -63,9 +71,19 @@ func (c *authServiceClient) SignIn(ctx context.Context, in *SignInRequest, opts return out, nil } -func (c *authServiceClient) SignUp(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*SignUpResponse, error) { +func (c *authServiceClient) SignInWithSSO(ctx context.Context, in *SignInWithSSORequest, opts ...grpc.CallOption) (*User, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(SignUpResponse) + out := new(User) + err := c.cc.Invoke(ctx, AuthService_SignInWithSSO_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *authServiceClient) SignUp(ctx context.Context, in *SignUpRequest, opts ...grpc.CallOption) (*User, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(User) err := c.cc.Invoke(ctx, AuthService_SignUp_FullMethodName, in, out, cOpts...) if err != nil { return nil, err @@ -73,9 +91,9 @@ func (c *authServiceClient) SignUp(ctx context.Context, in *SignUpRequest, opts return out, nil } -func (c *authServiceClient) SignOut(ctx context.Context, in *SignOutRequest, opts ...grpc.CallOption) (*SignOutResponse, error) { +func (c *authServiceClient) SignOut(ctx context.Context, in *SignOutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(SignOutResponse) + out := new(emptypb.Empty) err := c.cc.Invoke(ctx, AuthService_SignOut_FullMethodName, in, out, cOpts...) if err != nil { return nil, err @@ -87,10 +105,16 @@ func (c *authServiceClient) SignOut(ctx context.Context, in *SignOutRequest, opt // All implementations must embed UnimplementedAuthServiceServer // for forward compatibility. type AuthServiceServer interface { - GetAuthStatus(context.Context, *GetAuthStatusRequest) (*GetAuthStatusResponse, error) - SignIn(context.Context, *SignInRequest) (*SignInResponse, error) - SignUp(context.Context, *SignUpRequest) (*SignUpResponse, error) - SignOut(context.Context, *SignOutRequest) (*SignOutResponse, error) + // GetAuthStatus returns the current auth status of the user. + GetAuthStatus(context.Context, *GetAuthStatusRequest) (*User, error) + // SignIn signs in the user with the given username and password. + SignIn(context.Context, *SignInRequest) (*User, error) + // SignInWithSSO signs in the user with the given SSO code. + SignInWithSSO(context.Context, *SignInWithSSORequest) (*User, error) + // SignUp signs up the user with the given username and password. + SignUp(context.Context, *SignUpRequest) (*User, error) + // SignOut signs out the user. + SignOut(context.Context, *SignOutRequest) (*emptypb.Empty, error) mustEmbedUnimplementedAuthServiceServer() } @@ -101,16 +125,19 @@ type AuthServiceServer interface { // pointer dereference when methods are called. type UnimplementedAuthServiceServer struct{} -func (UnimplementedAuthServiceServer) GetAuthStatus(context.Context, *GetAuthStatusRequest) (*GetAuthStatusResponse, error) { +func (UnimplementedAuthServiceServer) GetAuthStatus(context.Context, *GetAuthStatusRequest) (*User, error) { return nil, status.Errorf(codes.Unimplemented, "method GetAuthStatus not implemented") } -func (UnimplementedAuthServiceServer) SignIn(context.Context, *SignInRequest) (*SignInResponse, error) { +func (UnimplementedAuthServiceServer) SignIn(context.Context, *SignInRequest) (*User, error) { return nil, status.Errorf(codes.Unimplemented, "method SignIn not implemented") } -func (UnimplementedAuthServiceServer) SignUp(context.Context, *SignUpRequest) (*SignUpResponse, error) { +func (UnimplementedAuthServiceServer) SignInWithSSO(context.Context, *SignInWithSSORequest) (*User, error) { + return nil, status.Errorf(codes.Unimplemented, "method SignInWithSSO not implemented") +} +func (UnimplementedAuthServiceServer) SignUp(context.Context, *SignUpRequest) (*User, error) { return nil, status.Errorf(codes.Unimplemented, "method SignUp not implemented") } -func (UnimplementedAuthServiceServer) SignOut(context.Context, *SignOutRequest) (*SignOutResponse, error) { +func (UnimplementedAuthServiceServer) SignOut(context.Context, *SignOutRequest) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method SignOut not implemented") } func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {} @@ -170,6 +197,24 @@ func _AuthService_SignIn_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _AuthService_SignInWithSSO_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SignInWithSSORequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).SignInWithSSO(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_SignInWithSSO_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).SignInWithSSO(ctx, req.(*SignInWithSSORequest)) + } + return interceptor(ctx, in, info, handler) +} + 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 { @@ -221,6 +266,10 @@ var AuthService_ServiceDesc = grpc.ServiceDesc{ MethodName: "SignIn", Handler: _AuthService_SignIn_Handler, }, + { + MethodName: "SignInWithSSO", + Handler: _AuthService_SignInWithSSO_Handler, + }, { MethodName: "SignUp", Handler: _AuthService_SignUp_Handler, diff --git a/proto/gen/apidocs.swagger.yaml b/proto/gen/apidocs.swagger.yaml index 4282207..20064b6 100644 --- a/proto/gen/apidocs.swagger.yaml +++ b/proto/gen/apidocs.swagger.yaml @@ -17,12 +17,13 @@ produces: paths: /api/v1/auth/signin: post: + summary: SignIn signs in the user with the given username and password. operationId: AuthService_SignIn responses: "200": description: A successful response. schema: - $ref: '#/definitions/v1SignInResponse' + $ref: '#/definitions/v1User' default: description: An unexpected error response. schema: @@ -38,14 +39,48 @@ paths: type: string tags: - AuthService + /api/v1/auth/signin/sso: + post: + summary: SignInWithSSO signs in the user with the given SSO code. + operationId: AuthService_SignInWithSSO + responses: + "200": + description: A successful response. + schema: + $ref: '#/definitions/v1User' + default: + description: An unexpected error response. + schema: + $ref: '#/definitions/rpcStatus' + parameters: + - name: idpName + description: The name of the SSO provider. + in: query + required: false + type: integer + format: int32 + - name: code + description: The code to sign in with. + in: query + required: false + type: string + - name: redirectUri + description: The redirect URI. + in: query + required: false + type: string + tags: + - AuthService /api/v1/auth/signout: post: + summary: SignOut signs out the user. operationId: AuthService_SignOut responses: "200": description: A successful response. schema: - $ref: '#/definitions/v1SignOutResponse' + type: object + properties: {} default: description: An unexpected error response. schema: @@ -54,12 +89,13 @@ paths: - AuthService /api/v1/auth/signup: post: + summary: SignUp signs up the user with the given username and password. operationId: AuthService_SignUp responses: "200": description: A successful response. schema: - $ref: '#/definitions/v1SignUpResponse' + $ref: '#/definitions/v1User' default: description: An unexpected error response. schema: @@ -81,12 +117,13 @@ paths: - AuthService /api/v1/auth/status: post: + summary: GetAuthStatus returns the current auth status of the user. operationId: AuthService_GetAuthStatus responses: "200": description: A successful response. schema: - $ref: '#/definitions/v1GetAuthStatusResponse' + $ref: '#/definitions/v1User' default: description: An unexpected error response. schema: @@ -961,11 +998,6 @@ definitions: type: object v1DeleteUserResponse: type: object - v1GetAuthStatusResponse: - type: object - properties: - user: - $ref: '#/definitions/v1User' v1GetCollectionByNameResponse: type: object properties: @@ -1077,18 +1109,6 @@ definitions: - ADMIN - USER default: ROLE_UNSPECIFIED - v1SignInResponse: - type: object - properties: - user: - $ref: '#/definitions/v1User' - v1SignOutResponse: - type: object - v1SignUpResponse: - type: object - properties: - user: - $ref: '#/definitions/v1User' v1Subscription: type: object properties: diff --git a/server/route/api/v1/auth_service.go b/server/route/api/v1/auth_service.go index faf7bbb..65f3f9a 100644 --- a/server/route/api/v1/auth_service.go +++ b/server/route/api/v1/auth_service.go @@ -10,6 +10,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/emptypb" v1pb "github.com/yourselfhosted/slash/proto/gen/api/v1" "github.com/yourselfhosted/slash/server/metric" @@ -17,7 +18,7 @@ import ( "github.com/yourselfhosted/slash/store" ) -func (s *APIV1Service) GetAuthStatus(ctx context.Context, _ *v1pb.GetAuthStatusRequest) (*v1pb.GetAuthStatusResponse, error) { +func (s *APIV1Service) GetAuthStatus(ctx context.Context, _ *v1pb.GetAuthStatusRequest) (*v1pb.User, error) { user, err := getCurrentUser(ctx, s.Store) if err != nil { return nil, status.Errorf(codes.Unauthenticated, "failed to get current user: %v", err) @@ -25,12 +26,10 @@ func (s *APIV1Service) GetAuthStatus(ctx context.Context, _ *v1pb.GetAuthStatusR if user == nil { return nil, status.Errorf(codes.Unauthenticated, "user not found") } - return &v1pb.GetAuthStatusResponse{ - User: convertUserFromStore(user), - }, nil + return convertUserFromStore(user), nil } -func (s *APIV1Service) SignIn(ctx context.Context, request *v1pb.SignInRequest) (*v1pb.SignInResponse, error) { +func (s *APIV1Service) SignIn(ctx context.Context, request *v1pb.SignInRequest) (*v1pb.User, error) { user, err := s.Store.GetUser(ctx, &store.FindUser{ Email: &request.Email, }) @@ -63,12 +62,10 @@ func (s *APIV1Service) SignIn(ctx context.Context, request *v1pb.SignInRequest) } metric.Enqueue("user sign in") - return &v1pb.SignInResponse{ - User: convertUserFromStore(user), - }, nil + return convertUserFromStore(user), nil } -func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest) (*v1pb.SignUpResponse, error) { +func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest) (*v1pb.User, error) { if !s.Profile.Public { return nil, status.Errorf(codes.PermissionDenied, "sign up is not allowed") } @@ -124,18 +121,15 @@ func (s *APIV1Service) SignUp(ctx context.Context, request *v1pb.SignUpRequest) } metric.Enqueue("user sign up") - return &v1pb.SignUpResponse{ - User: convertUserFromStore(user), - }, nil + return convertUserFromStore(user), nil } -func (*APIV1Service) SignOut(ctx context.Context, _ *v1pb.SignOutRequest) (*v1pb.SignOutResponse, error) { +func (*APIV1Service) SignOut(ctx context.Context, _ *v1pb.SignOutRequest) (*emptypb.Empty, error) { // Set the cookie header to expire access token. if err := grpc.SetHeader(ctx, metadata.New(map[string]string{ "Set-Cookie": fmt.Sprintf("%s=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; SameSite=Strict", AccessTokenCookieName), })); err != nil { return nil, status.Errorf(codes.Internal, "failed to set grpc header, error: %v", err) } - - return &v1pb.SignOutResponse{}, nil + return &emptypb.Empty{}, nil }