Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: get current user (#15829)
boojackc6428512baa2
diff --git a/backend/api/auth/header.go b/backend/api/auth/header.goindex 0219e4d1c9..5385dfecfb 100644--- a/backend/api/auth/header.go+++ b/backend/api/auth/header.go@@ -32,6 +32,7 @@ func (m *GatewayResponseModifier) Modify(ctx context.Context, response http.Resp}}m.processMetadata(ctx, md, GatewayMetadataAccessTokenKey, AccessTokenCookieName, true /* httpOnly */, isHTTPS, response)+ // TODO(steven): remove me please.m.processMetadata(ctx, md, GatewayMetadataUserIDKey, UserIDCookieName, false /* httpOnly */, isHTTPS, response)return nil}diff --git a/backend/api/v1/user_service.go b/backend/api/v1/user_service.goindex db54c5c6b6..ac6d5e4f5c 100644--- a/backend/api/v1/user_service.go+++ b/backend/api/v1/user_service.go@@ -88,6 +88,15 @@ func (s *UserService) GetUser(ctx context.Context, request *v1pb.GetUserRequest)return convertToUser(user), nil}+// GetCurrentUser gets the current authenticated user.+func (*UserService) GetCurrentUser(ctx context.Context, _ *emptypb.Empty) (*v1pb.User, error) {+ user, ok := ctx.Value(common.UserContextKey).(*store.UserMessage)+ if !ok || user == nil {+ return nil, status.Errorf(codes.Unauthenticated, "authenticated user not found")+ }+ return convertToUser(user), nil+}+// ListUsers lists all users.func (s *UserService) ListUsers(ctx context.Context, request *v1pb.ListUsersRequest) (*v1pb.ListUsersResponse, error) {offset, err := parseLimitAndOffset(&pageSize{diff --git a/frontend/src/types/proto/v1/user_service.ts b/frontend/src/types/proto/v1/user_service.tsindex 84e8958402..e3c55438be 100644--- a/frontend/src/types/proto/v1/user_service.ts+++ b/frontend/src/types/proto/v1/user_service.ts@@ -1169,6 +1169,21 @@ export const UserServiceDefinition = {},},},+ /** Get the current authenticated user. */+ getCurrentUser: {+ name: "GetCurrentUser",+ requestType: Empty,+ requestStream: false,+ responseType: User,+ responseStream: false,+ options: {+ _unknownFields: {+ 800000: [new Uint8Array([1])],+ 800016: [new Uint8Array([2])],+ 578365826: [new Uint8Array([14, 18, 12, 47, 118, 49, 47, 117, 115, 101, 114, 115, 47, 109, 101])],+ },+ },+ },/*** List all users.* Any authenticated user can list users.diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex 23ae2ddca1..885a684bf0 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -7050,6 +7050,25 @@ paths:application/json:schema:$ref: '#/components/schemas/Status'+ /v1/users/me:+ get:+ tags:+ - UserService+ description: Get the current authenticated user.+ operationId: UserService_GetCurrentUser+ responses:+ "200":+ description: OK+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/User'+ default:+ description: Default error response+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/Status'/v1/users/{user}:get:tags:diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex dda28b05ed..8c277dd3d6 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -5216,6 +5216,7 @@ The user's `name` field is used to identify the user to update. Format: user| Method Name | Request Type | Response Type | Description || ----------- | ------------ | ------------- | ------------|| GetUser | [GetUserRequest](#bytebase-v1-GetUserRequest) | [User](#bytebase-v1-User) | Get the user. Any authenticated user can get the user. |+| GetCurrentUser | [.google.protobuf.Empty](#google-protobuf-Empty) | [User](#bytebase-v1-User) | Get the current authenticated user. || ListUsers | [ListUsersRequest](#bytebase-v1-ListUsersRequest) | [ListUsersResponse](#bytebase-v1-ListUsersResponse) | List all users. Any authenticated user can list users. || CreateUser | [CreateUserRequest](#bytebase-v1-CreateUserRequest) | [User](#bytebase-v1-User) | Create a user. When Disallow Signup is enabled, only the caller with bb.users.create on the workspace can create a user. Otherwise, any unauthenticated user can create a user. || UpdateUser | [UpdateUserRequest](#bytebase-v1-UpdateUserRequest) | [User](#bytebase-v1-User) | Only the user itself and the user with bb.users.update permission on the workspace can update the user. |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex 6c36f6d2d9..ec6d4aabe1 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -14999,6 +14999,13 @@ Could be empty. </p></td>Any authenticated user can get the user.</p></td></tr>+ <tr>+ <td>GetCurrentUser</td>+ <td><a href="#google.protobuf.Empty">.google.protobuf.Empty</a></td>+ <td><a href="#bytebase.v1.User">User</a></td>+ <td><p>Get the current authenticated user.</p></td>+ </tr>+<tr><td>ListUsers</td><td><a href="#bytebase.v1.ListUsersRequest">ListUsersRequest</a></td>@@ -15068,6 +15075,16 @@ The last remaining workspace admin cannot be deleted.</p></td>+ <tr>+ <td>GetCurrentUser</td>+ <td>GET</td>+ <td>/v1/users/me</td>+ <td></td>+ </tr>++++<tr><td>ListUsers</td><td>GET</td>diff --git a/proto/generated-go/v1/user_service.pb.go b/proto/generated-go/v1/user_service.pb.goindex 29434c9a24..b80f407f48 100644--- a/proto/generated-go/v1/user_service.pb.go+++ b/proto/generated-go/v1/user_service.pb.go@@ -759,9 +759,10 @@ const file_v1_user_service_proto_rawDesc = "" +"\x04USER\x10\x01\x12\x0e\n" +"\n" +"SYSTEM_BOT\x10\x02\x12\x13\n" +- "\x0fSERVICE_ACCOUNT\x10\x032\xb2\x05\n" ++ "\x0fSERVICE_ACCOUNT\x10\x032\x8d\x06\n" +"\vUserService\x12`\n" +- "\aGetUser\x12\x1b.bytebase.v1.GetUserRequest\x1a\x11.bytebase.v1.User\"%\xdaA\x04name\x90\xea0\x02\x82\xd3\xe4\x93\x02\x14\x12\x12/v1/{name=users/*}\x12j\n" ++ "\aGetUser\x12\x1b.bytebase.v1.GetUserRequest\x1a\x11.bytebase.v1.User\"%\xdaA\x04name\x90\xea0\x02\x82\xd3\xe4\x93\x02\x14\x12\x12/v1/{name=users/*}\x12Y\n" ++ "\x0eGetCurrentUser\x12\x16.google.protobuf.Empty\x1a\x11.bytebase.v1.User\"\x1c\x80\xea0\x01\x90\xea0\x02\x82\xd3\xe4\x93\x02\x0e\x12\f/v1/users/me\x12j\n" +"\tListUsers\x12\x1d.bytebase.v1.ListUsersRequest\x1a\x1e.bytebase.v1.ListUsersResponse\"\x1e\xdaA\x06parent\x90\xea0\x02\x82\xd3\xe4\x93\x02\v\x12\t/v1/users\x12k\n" +"\n" +"CreateUser\x12\x1e.bytebase.v1.CreateUserRequest\x1a\x11.bytebase.v1.User\"*\xdaA\x04user\x80\xea0\x01\x90\xea0\x02\x98\xea0\x01\x82\xd3\xe4\x93\x02\x11:\x04user\"\t/v1/users\x12\x81\x01\n" +@@ -812,19 +813,21 @@ var file_v1_user_service_proto_depIdxs = []int32{12, // 7: bytebase.v1.User.Profile.last_login_time:type_name -> google.protobuf.Timestamp12, // 8: bytebase.v1.User.Profile.last_change_password_time:type_name -> google.protobuf.Timestamp1, // 9: bytebase.v1.UserService.GetUser:input_type -> bytebase.v1.GetUserRequest- 2, // 10: bytebase.v1.UserService.ListUsers:input_type -> bytebase.v1.ListUsersRequest- 4, // 11: bytebase.v1.UserService.CreateUser:input_type -> bytebase.v1.CreateUserRequest- 5, // 12: bytebase.v1.UserService.UpdateUser:input_type -> bytebase.v1.UpdateUserRequest- 6, // 13: bytebase.v1.UserService.DeleteUser:input_type -> bytebase.v1.DeleteUserRequest- 7, // 14: bytebase.v1.UserService.UndeleteUser:input_type -> bytebase.v1.UndeleteUserRequest- 8, // 15: bytebase.v1.UserService.GetUser:output_type -> bytebase.v1.User- 3, // 16: bytebase.v1.UserService.ListUsers:output_type -> bytebase.v1.ListUsersResponse- 8, // 17: bytebase.v1.UserService.CreateUser:output_type -> bytebase.v1.User- 8, // 18: bytebase.v1.UserService.UpdateUser:output_type -> bytebase.v1.User- 13, // 19: bytebase.v1.UserService.DeleteUser:output_type -> google.protobuf.Empty- 8, // 20: bytebase.v1.UserService.UndeleteUser:output_type -> bytebase.v1.User- 15, // [15:21] is the sub-list for method output_type- 9, // [9:15] is the sub-list for method input_type+ 13, // 10: bytebase.v1.UserService.GetCurrentUser:input_type -> google.protobuf.Empty+ 2, // 11: bytebase.v1.UserService.ListUsers:input_type -> bytebase.v1.ListUsersRequest+ 4, // 12: bytebase.v1.UserService.CreateUser:input_type -> bytebase.v1.CreateUserRequest+ 5, // 13: bytebase.v1.UserService.UpdateUser:input_type -> bytebase.v1.UpdateUserRequest+ 6, // 14: bytebase.v1.UserService.DeleteUser:input_type -> bytebase.v1.DeleteUserRequest+ 7, // 15: bytebase.v1.UserService.UndeleteUser:input_type -> bytebase.v1.UndeleteUserRequest+ 8, // 16: bytebase.v1.UserService.GetUser:output_type -> bytebase.v1.User+ 8, // 17: bytebase.v1.UserService.GetCurrentUser:output_type -> bytebase.v1.User+ 3, // 18: bytebase.v1.UserService.ListUsers:output_type -> bytebase.v1.ListUsersResponse+ 8, // 19: bytebase.v1.UserService.CreateUser:output_type -> bytebase.v1.User+ 8, // 20: bytebase.v1.UserService.UpdateUser:output_type -> bytebase.v1.User+ 13, // 21: bytebase.v1.UserService.DeleteUser:output_type -> google.protobuf.Empty+ 8, // 22: bytebase.v1.UserService.UndeleteUser:output_type -> bytebase.v1.User+ 16, // [16:23] is the sub-list for method output_type+ 9, // [9:16] is the sub-list for method input_type9, // [9:9] is the sub-list for extension type_name9, // [9:9] is the sub-list for extension extendee0, // [0:9] is the sub-list for field type_namediff --git a/proto/generated-go/v1/user_service.pb.gw.go b/proto/generated-go/v1/user_service.pb.gw.goindex 2c00ed8b98..461fae847d 100644--- a/proto/generated-go/v1/user_service.pb.gw.go+++ b/proto/generated-go/v1/user_service.pb.gw.go@@ -22,6 +22,7 @@ import ("google.golang.org/grpc/metadata""google.golang.org/grpc/status""google.golang.org/protobuf/proto"+ "google.golang.org/protobuf/types/known/emptypb")// Suppress "imported and not used" errors@@ -72,6 +73,25 @@ func local_request_UserService_GetUser_0(ctx context.Context, marshaler runtime.return msg, metadata, err}+func request_UserService_GetCurrentUser_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var (+ protoReq emptypb.Empty+ metadata runtime.ServerMetadata+ )+ io.Copy(io.Discard, req.Body)+ msg, err := client.GetCurrentUser(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err+}++func local_request_UserService_GetCurrentUser_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var (+ protoReq emptypb.Empty+ metadata runtime.ServerMetadata+ )+ msg, err := server.GetCurrentUser(ctx, &protoReq)+ return msg, metadata, err+}+var filter_UserService_ListUsers_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}func request_UserService_ListUsers_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {@@ -312,6 +332,26 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux}forward_UserService_GetUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)})+ mux.Handle(http.MethodGet, pattern_UserService_GetCurrentUser_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, "/bytebase.v1.UserService/GetCurrentUser", runtime.WithHTTPPathPattern("/v1/users/me"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_UserService_GetCurrentUser_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_UserService_GetCurrentUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)+ })mux.Handle(http.MethodGet, pattern_UserService_ListUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {ctx, cancel := context.WithCancel(req.Context())defer cancel()@@ -469,6 +509,23 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux}forward_UserService_GetUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)})+ mux.Handle(http.MethodGet, pattern_UserService_GetCurrentUser_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, "/bytebase.v1.UserService/GetCurrentUser", runtime.WithHTTPPathPattern("/v1/users/me"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_UserService_GetCurrentUser_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }+ forward_UserService_GetCurrentUser_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)+ })mux.Handle(http.MethodGet, pattern_UserService_ListUsers_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {ctx, cancel := context.WithCancel(req.Context())defer cancel()@@ -558,19 +615,21 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux}var (- pattern_UserService_GetUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "name"}, ""))- pattern_UserService_ListUsers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "users"}, ""))- pattern_UserService_CreateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "users"}, ""))- pattern_UserService_UpdateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "user.name"}, ""))- pattern_UserService_DeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "name"}, ""))- pattern_UserService_UndeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "name"}, "undelete"))+ pattern_UserService_GetUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "name"}, ""))+ pattern_UserService_GetCurrentUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"v1", "users", "me"}, ""))+ pattern_UserService_ListUsers_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "users"}, ""))+ pattern_UserService_CreateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "users"}, ""))+ pattern_UserService_UpdateUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "user.name"}, ""))+ pattern_UserService_DeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "name"}, ""))+ pattern_UserService_UndeleteUser_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "users", "name"}, "undelete")))var (- forward_UserService_GetUser_0 = runtime.ForwardResponseMessage- forward_UserService_ListUsers_0 = runtime.ForwardResponseMessage- forward_UserService_CreateUser_0 = runtime.ForwardResponseMessage- forward_UserService_UpdateUser_0 = runtime.ForwardResponseMessage- forward_UserService_DeleteUser_0 = runtime.ForwardResponseMessage- forward_UserService_UndeleteUser_0 = runtime.ForwardResponseMessage+ forward_UserService_GetUser_0 = runtime.ForwardResponseMessage+ forward_UserService_GetCurrentUser_0 = runtime.ForwardResponseMessage+ forward_UserService_ListUsers_0 = runtime.ForwardResponseMessage+ forward_UserService_CreateUser_0 = runtime.ForwardResponseMessage+ forward_UserService_UpdateUser_0 = runtime.ForwardResponseMessage+ forward_UserService_DeleteUser_0 = runtime.ForwardResponseMessage+ forward_UserService_UndeleteUser_0 = runtime.ForwardResponseMessage)diff --git a/proto/generated-go/v1/user_service_grpc.pb.go b/proto/generated-go/v1/user_service_grpc.pb.goindex 8bf7378714..3d3125b569 100644--- a/proto/generated-go/v1/user_service_grpc.pb.go+++ b/proto/generated-go/v1/user_service_grpc.pb.go@@ -20,12 +20,13 @@ import (const _ = grpc.SupportPackageIsVersion9const (- UserService_GetUser_FullMethodName = "/bytebase.v1.UserService/GetUser"- UserService_ListUsers_FullMethodName = "/bytebase.v1.UserService/ListUsers"- UserService_CreateUser_FullMethodName = "/bytebase.v1.UserService/CreateUser"- UserService_UpdateUser_FullMethodName = "/bytebase.v1.UserService/UpdateUser"- UserService_DeleteUser_FullMethodName = "/bytebase.v1.UserService/DeleteUser"- UserService_UndeleteUser_FullMethodName = "/bytebase.v1.UserService/UndeleteUser"+ UserService_GetUser_FullMethodName = "/bytebase.v1.UserService/GetUser"+ UserService_GetCurrentUser_FullMethodName = "/bytebase.v1.UserService/GetCurrentUser"+ UserService_ListUsers_FullMethodName = "/bytebase.v1.UserService/ListUsers"+ UserService_CreateUser_FullMethodName = "/bytebase.v1.UserService/CreateUser"+ UserService_UpdateUser_FullMethodName = "/bytebase.v1.UserService/UpdateUser"+ UserService_DeleteUser_FullMethodName = "/bytebase.v1.UserService/DeleteUser"+ UserService_UndeleteUser_FullMethodName = "/bytebase.v1.UserService/UndeleteUser")// UserServiceClient is the client API for UserService service.@@ -35,6 +36,8 @@ type UserServiceClient interface {// Get the user.// Any authenticated user can get the user.GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*User, error)+ // Get the current authenticated user.+ GetCurrentUser(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*User, error)// List all users.// Any authenticated user can list users.ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error)@@ -69,6 +72,16 @@ func (c *userServiceClient) GetUser(ctx context.Context, in *GetUserRequest, optreturn out, nil}+func (c *userServiceClient) GetCurrentUser(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*User, error) {+ cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)+ out := new(User)+ err := c.cc.Invoke(ctx, UserService_GetCurrentUser_FullMethodName, in, out, cOpts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}+func (c *userServiceClient) ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (*ListUsersResponse, error) {cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)out := new(ListUsersResponse)@@ -126,6 +139,8 @@ type UserServiceServer interface {// Get the user.// Any authenticated user can get the user.GetUser(context.Context, *GetUserRequest) (*User, error)+ // Get the current authenticated user.+ GetCurrentUser(context.Context, *emptypb.Empty) (*User, error)// List all users.// Any authenticated user can list users.ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error)@@ -153,6 +168,9 @@ type UnimplementedUserServiceServer struct{}func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*User, error) {return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented")}+func (UnimplementedUserServiceServer) GetCurrentUser(context.Context, *emptypb.Empty) (*User, error) {+ return nil, status.Errorf(codes.Unimplemented, "method GetCurrentUser not implemented")+}func (UnimplementedUserServiceServer) ListUsers(context.Context, *ListUsersRequest) (*ListUsersResponse, error) {return nil, status.Errorf(codes.Unimplemented, "method ListUsers not implemented")}@@ -207,6 +225,24 @@ func _UserService_GetUser_Handler(srv interface{}, ctx context.Context, dec funcreturn interceptor(ctx, in, info, handler)}+func _UserService_GetCurrentUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(emptypb.Empty)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(UserServiceServer).GetCurrentUser(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: UserService_GetCurrentUser_FullMethodName,+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(UserServiceServer).GetCurrentUser(ctx, req.(*emptypb.Empty))+ }+ return interceptor(ctx, in, info, handler)+}+func _UserService_ListUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {in := new(ListUsersRequest)if err := dec(in); err != nil {@@ -308,6 +344,10 @@ var UserService_ServiceDesc = grpc.ServiceDesc{MethodName: "GetUser",Handler: _UserService_GetUser_Handler,},+ {+ MethodName: "GetCurrentUser",+ Handler: _UserService_GetCurrentUser_Handler,+ },{MethodName: "ListUsers",Handler: _UserService_ListUsers_Handler,diff --git a/proto/v1/user_service.proto b/proto/v1/user_service.protoindex f825a28297..1942e9dc0e 100644--- a/proto/v1/user_service.proto+++ b/proto/v1/user_service.proto@@ -23,6 +23,13 @@ service UserService {option (bytebase.v1.auth_method) = CUSTOM;}+ // Get the current authenticated user.+ rpc GetCurrentUser(google.protobuf.Empty) returns (User) {+ option (google.api.http) = {get: "/v1/users/me"};+ option (bytebase.v1.allow_without_credential) = true;+ option (bytebase.v1.auth_method) = CUSTOM;+ }+// List all users.// Any authenticated user can list users.rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) {