diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..f4b4239b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.pb.go linguist-generated +go.sum linguist-generated \ No newline at end of file diff --git a/services/mpa/README.md b/services/mpa/README.md new file mode 100644 index 00000000..79923186 --- /dev/null +++ b/services/mpa/README.md @@ -0,0 +1,192 @@ +# Multi Party Authentication + +WARNING: This document describes the intended state. https://github.com/Snowflake-Labs/sansshell/issues/346 tracks implementation. + +This module enables [multi-party authorization](https://en.wikipedia.org/wiki/Multi-party_authorization) for any sansshell command. Approval data is stored in-memory in sansshell-server. + +## User flow + +MPA must be explicitly requested. When requested, the MPA flow will be used regardless of whether a policy would allow a command without MPA. + +1. A user issues commands. + + ```bash + $ sanssh -mpa -targets=1.2.3.4 -justification emergency exec run /bin/echo hi + Waiting for approval for 1-2345-6789. Command for approving: + sanssh -targets=1.2.3.4 mpa approve 1-2345-6789 + ``` + +2. The approver views the commands and approves it. + + ```bash + $ sanssh -targets=1.2.3.4 mpa list + 1-2345-6789 + $ sanssh -targets=1.2.3.4 mpa get 1-2345-6789 + user: firstuser + justification: emergency + method: /Exec.Exec/Run + message: { + "command": "/bin/echo", + "args": ["hi"] + } + $ sanssh -targets=1.2.3.4 mpa approve 1-2345-6789 + ``` + +3. If the user's command is still running, it will complete. If the user had stopped their command, they can rerun it and the approval will still be valid as long as the command's input remains the same and the sansshell-server still has the approval in memory. Approvals are lost if the server restarts, if the server evicts the approval due to age or staleness, or if a user calls `sanssh mpa clear` oon the request id. + +## Enabling MPA + +SansShell is built on a principle of "Don't pay for what you don't use". MPA is a more invasive than the typical sansshell module, so it requires updating more places than most modules. The reference sanssh, sansshell-server, and proxy-server binaries implement these changes. + +1. In sanssh, in addition to importing the module to get the `mpa` subcommand, you should conditionally add interceptors when a `-mpa` flag is provided to the cli. This will let other sanssh commands use MPA with the `-mpa` flag and get the user experience mentioned above. There are four interceptors. + + 1. Unary interceptor for direct calls + 2. Stream interceptor for direct calls + 3. Unary interceptor for proxied calls + 4. Stream interceptor for proxied calls. + + The interceptors for direct calls get added when dialing out. + + ```go + proxy.DialContext(ctx, proxy, targets, + grpc.WithStreamInterceptor(mpahooks.StreamClientIntercepter), + grpc.WithUnaryInterceptor(mpahooks.MPAUnaryClientInterceptor)) + ``` + + The interceptors for proxied calls are added as fields in the `*proxy.Conn` struct. + + ```go + conn.UnaryInterceptors = []proxy.UnaryInterceptor{mpahooks.ProxyClientUnaryInterceptor(state)} + conn.StreamInterceptors = []proxy.StreamInterceptor{mpahooks.ProxyClientStreamInterceptor(state)} + ``` + +2. In sansshell-server, import the MPA service and add an authz hook to consult the local datastore for MPA info. + + ```go + mpa "github.com/Snowflake-Labs/sansshell/services/mpa/server" + server.WithAuthzHook(mpa.ServerMPAAuthzHook) + ``` + +3. If using the proxy-server, add an authz hook to consult the server for MPA info. + + ```go + proxy.WithAuthzHook(mpa.ProxyMPAAuthzHook) + ``` + + You'll also need to set an additional interceptor on the server to make proxied identity information available. + + ```go + func(ctx context.Context) bool { + peer := rpcauth.PeerInputFromContext(ctx) + if peer == nil { + return false + } + // Custom business logic goes here. + } + proxiedidentity.ServerProxiedIdentityUnaryInterceptor() + proxiedidentity.ServerProxiedIdentityStreamInterceptor() + ``` + +4. Any approvers must be able to call `/Mpa.Mpa/Approve` and any requestor must be able to call `/Mpa.Mpa/Store`. It's highly recommended to additionally let potential approvers call `/Mpa.Mpa/Get` and potential requestors call `/Mpa.Mpa/WaitForApproval` for better user experiences. `/Mpa.Mpa/Clear` can be used for cancelling MPA requests. + +Approvers will show up in [RPCAuthInput](https://pkg.go.dev/github.com/Snowflake-Labs/sansshell/auth/opa/rpcauth#RPCAuthInput). Match on these in the OPA policies. + +```rego +allow if { + input.approvers[_].principal.id == 'superuser' +} +``` + +## Design details + +MPA requests and approvals are stored in memory in sansshell-server. The id for a request is generated as a hash of the request information, allowing us to reuse the same id for multiple identical requests across multiple commands or across multiple machines. + +To support proxying, there are multiple ways of populating the user identity used in `/Mpa.Mpa/Store` and `/Mpa.Mpa/Approve`. + +1. From the `sansshell-proxied-identity` key in the [gRPC metadata](https://grpc.io/docs/what-is-grpc/core-concepts/#metadata), used if the identity is set and the server has been configured to accept a proxied identity. The value of this is a JSON representation of `rpcauth.Principal`. +2. From the peer identity of the call, used in all other cases. + +Justification information can be provided via a `sansshell-justification` key in the gRPC metadata, available as a constant at `rpcauth.ReqJustKey`. + +The values in [RPCAuthInput](https://pkg.go.dev/github.com/Snowflake-Labs/sansshell/auth/opa/rpcauth#RPCAuthInput) are populated by authz hooks that look up a MPA request based on the `sansshell-mpa-request-id` key in the gRPC metadata. Requests will fail if this refers to an invalid or missing request. + +Client-side streaming RPCs that involve more than one streamed message are not supported because it's not possible to evaluate the client's messages prior to the request. + +### Server-only flow + +The server-only flow is the simplest scenario. + +```mermaid +sequenceDiagram + actor approver + actor client + client->>+server: /Mpa.Mpa/Store + server->>server: PolicyCheck / log + server->>-client: ID for request + client->>approver: Give request ID + approver->>+server: /Mpa.Mpa/Approve + server->>-server: PolicyCheck / log + client->>server: Make normal call with sansshell-mpa-request-id + server->>server: PolicyCheck / log +``` + +Typical usage will involve `/Mpa.Mpa/WaitForApproval` so that `sanssh` can make the call as soon as it has approval. + +```mermaid +sequenceDiagram + actor approver + actor client + client->>+server: /Mpa.Mpa/Store + server->>server: PolicyCheck / log + server->>-client: ID for request + client->>+server: /Mpa.Mpa/WaitForApproval + server->>server: PolicyCheck / log + client->>approver: Give request ID + approver->>+server: /Mpa.Mpa/Approve + server->>-server: PolicyCheck / log + server->>-client: /Mpa.Mpa/WaitForApproval completes + client->>server: Make normal call with sansshell-mpa-request-id + server->>server: PolicyCheck / log +``` + +### Server + Proxy flow + +The proxy flow is a bit more complicated than the server flow because the proxy relies on the server for maintaining state. + +```mermaid +sequenceDiagram + actor approver + actor client + client->>+proxy: /Mpa.Mpa/Store + proxy->>proxy: PolicyCheck / log + proxy->>+server: /Mpa.Mpa/Store + server->>server: PolicyCheck / log + server->>-proxy: ID for request + proxy->>-client: ID for request + client->>+proxy: /Mpa.Mpa/WaitForApproval + proxy->>proxy: PolicyCheck / log + proxy->>+server: /Mpa.Mpa/WaitForApproval + server->>server: PolicyCheck / log + client->>approver: Give request ID + approver->>+proxy: /Mpa.Mpa/Approve + proxy->>proxy: PolicyCheck / log + proxy->>-server: /Mpa.Mpa/Approve + server->>server: PolicyCheck / log + server->>-proxy: /Mpa.Mpa/WaitForApproval completes + proxy->>-client: /Mpa.Mpa/WaitForApproval completes + client->>+proxy: Make normal call with sansshell-mpa-request-id + proxy->>+server: /Mpa.Mpa/Get + server->>server: PolicyCheck / log + server->>-proxy: Approver info + proxy->>proxy: PolicyCheck / log + proxy->>-server: Make normal call +``` + +## Caveats + +- Due to the complexity of OPA policies, we don't support automatically recognizing that a request requires MPA. + - If you want to give feedback that an action would succeed with MPA, check out [DenialHints](https://pkg.go.dev/github.com/Snowflake-Labs/sansshell/auth/opa#WithDenialHintsQuery) +- We also don't support recognizing in advance whether MPA would let an action succeed. +- You can easily write policies that allow people to approve actions even if their approval isn't useful +- All state is stored in-memory in sansshell-server. Any restarts of the server will clear approvals. +- Be wary of guarding too many actions behind MPA. If it gets used too regularly, humans will quickly get used to blindly approving commands without thinking through whether each command is necessary. diff --git a/services/mpa/mpa.go b/services/mpa/mpa.go new file mode 100644 index 00000000..f9eab4c9 --- /dev/null +++ b/services/mpa/mpa.go @@ -0,0 +1,22 @@ +/* Copyright (c) 2019 Snowflake Inc. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +// Package mpa defines the RPC interface for the sansshell MPA actions. +package mpa + +// To regenerate the proto headers if the .proto changes, just run go generate +// and this encodes the necessary magic: +//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=require_unimplemented_servers=false:. --go-grpc_opt=paths=source_relative --go-grpcproxy_out=. --go-grpcproxy_opt=paths=source_relative mpa.proto diff --git a/services/mpa/mpa.pb.go b/services/mpa/mpa.pb.go new file mode 100644 index 00000000..ffa971c7 --- /dev/null +++ b/services/mpa/mpa.pb.go @@ -0,0 +1,1159 @@ +// Copyright (c) 2022 Snowflake Inc. All rights reserved. +// +//Licensed under the Apache License, Version 2.0 (the +//"License"); you may not use this file except in compliance +//with the License. You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +//Unless required by applicable law or agreed to in writing, +//software distributed under the License is distributed on an +//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +//KIND, either express or implied. See the License for the +//specific language governing permissions and limitations +//under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc v3.19.6 +// source: mpa.proto + +package mpa + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Action struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The user that created the request. + User string `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` + // User-supplied information on why the request is being made. + Justification string `protobuf:"bytes,2,opt,name=justification,proto3" json:"justification,omitempty"` + // The GRPC method name, as '/Package.Service/Method' + Method string `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"` + // The request protocol buffer. + Message *anypb.Any `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *Action) Reset() { + *x = Action{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Action) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Action) ProtoMessage() {} + +func (x *Action) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[0] + 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 Action.ProtoReflect.Descriptor instead. +func (*Action) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{0} +} + +func (x *Action) GetUser() string { + if x != nil { + return x.User + } + return "" +} + +func (x *Action) GetJustification() string { + if x != nil { + return x.Justification + } + return "" +} + +func (x *Action) GetMethod() string { + if x != nil { + return x.Method + } + return "" +} + +func (x *Action) GetMessage() *anypb.Any { + if x != nil { + return x.Message + } + return nil +} + +type Principal struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The principal identifier (e.g. a username or service role) + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // Auxiliary groups associated with this principal. + Groups []string `protobuf:"bytes,2,rep,name=groups,proto3" json:"groups,omitempty"` +} + +func (x *Principal) Reset() { + *x = Principal{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Principal) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Principal) ProtoMessage() {} + +func (x *Principal) ProtoReflect() protoreflect.Message { + mi := &file_mpa_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 Principal.ProtoReflect.Descriptor instead. +func (*Principal) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{1} +} + +func (x *Principal) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Principal) GetGroups() []string { + if x != nil { + return x.Groups + } + return nil +} + +type StoreRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The GRPC method name, as '/Package.Service/Method' + Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` + // The request protocol buffer. + Message *anypb.Any `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *StoreRequest) Reset() { + *x = StoreRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StoreRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StoreRequest) ProtoMessage() {} + +func (x *StoreRequest) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[2] + 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 StoreRequest.ProtoReflect.Descriptor instead. +func (*StoreRequest) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{2} +} + +func (x *StoreRequest) GetMethod() string { + if x != nil { + return x.Method + } + return "" +} + +func (x *StoreRequest) GetMessage() *anypb.Any { + if x != nil { + return x.Message + } + return nil +} + +type StoreResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Action *Action `protobuf:"bytes,2,opt,name=action,proto3" json:"action,omitempty"` + // All approvers of the request. Storing is idempotent, so + // approvers may be non-empty if we're storing a previously + // approved command. + Approver []*Principal `protobuf:"bytes,3,rep,name=approver,proto3" json:"approver,omitempty"` +} + +func (x *StoreResponse) Reset() { + *x = StoreResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StoreResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StoreResponse) ProtoMessage() {} + +func (x *StoreResponse) ProtoReflect() protoreflect.Message { + mi := &file_mpa_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 StoreResponse.ProtoReflect.Descriptor instead. +func (*StoreResponse) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{3} +} + +func (x *StoreResponse) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *StoreResponse) GetAction() *Action { + if x != nil { + return x.Action + } + return nil +} + +func (x *StoreResponse) GetApprover() []*Principal { + if x != nil { + return x.Approver + } + return nil +} + +type ApproveRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // Approve takes an action instead of an ID to improve auditability + // and allow richer authorization logic. + Action *Action `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"` +} + +func (x *ApproveRequest) Reset() { + *x = ApproveRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ApproveRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApproveRequest) ProtoMessage() {} + +func (x *ApproveRequest) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[4] + 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 ApproveRequest.ProtoReflect.Descriptor instead. +func (*ApproveRequest) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{4} +} + +func (x *ApproveRequest) GetAction() *Action { + if x != nil { + return x.Action + } + return nil +} + +type ApproveResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ApproveResponse) Reset() { + *x = ApproveResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ApproveResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApproveResponse) ProtoMessage() {} + +func (x *ApproveResponse) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[5] + 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 ApproveResponse.ProtoReflect.Descriptor instead. +func (*ApproveResponse) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{5} +} + +type WaitForApprovalRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *WaitForApprovalRequest) Reset() { + *x = WaitForApprovalRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WaitForApprovalRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WaitForApprovalRequest) ProtoMessage() {} + +func (x *WaitForApprovalRequest) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[6] + 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 WaitForApprovalRequest.ProtoReflect.Descriptor instead. +func (*WaitForApprovalRequest) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{6} +} + +func (x *WaitForApprovalRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type WaitForApprovalResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *WaitForApprovalResponse) Reset() { + *x = WaitForApprovalResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *WaitForApprovalResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WaitForApprovalResponse) ProtoMessage() {} + +func (x *WaitForApprovalResponse) ProtoReflect() protoreflect.Message { + mi := &file_mpa_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 WaitForApprovalResponse.ProtoReflect.Descriptor instead. +func (*WaitForApprovalResponse) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{7} +} + +type ListRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListRequest) Reset() { + *x = ListRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListRequest) ProtoMessage() {} + +func (x *ListRequest) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[8] + 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 ListRequest.ProtoReflect.Descriptor instead. +func (*ListRequest) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{8} +} + +type ListResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Item []*ListResponse_Item `protobuf:"bytes,1,rep,name=item,proto3" json:"item,omitempty"` +} + +func (x *ListResponse) Reset() { + *x = ListResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListResponse) ProtoMessage() {} + +func (x *ListResponse) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[9] + 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 ListResponse.ProtoReflect.Descriptor instead. +func (*ListResponse) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{9} +} + +func (x *ListResponse) GetItem() []*ListResponse_Item { + if x != nil { + return x.Item + } + return nil +} + +type GetRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *GetRequest) Reset() { + *x = GetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRequest) ProtoMessage() {} + +func (x *GetRequest) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[10] + 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 GetRequest.ProtoReflect.Descriptor instead. +func (*GetRequest) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{10} +} + +func (x *GetRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +type GetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Action *Action `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"` + // All approvers of the request. + Approver []*Principal `protobuf:"bytes,2,rep,name=approver,proto3" json:"approver,omitempty"` +} + +func (x *GetResponse) Reset() { + *x = GetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetResponse) ProtoMessage() {} + +func (x *GetResponse) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[11] + 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 GetResponse.ProtoReflect.Descriptor instead. +func (*GetResponse) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{11} +} + +func (x *GetResponse) GetAction() *Action { + if x != nil { + return x.Action + } + return nil +} + +func (x *GetResponse) GetApprover() []*Principal { + if x != nil { + return x.Approver + } + return nil +} + +type ClearRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Action *Action `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"` +} + +func (x *ClearRequest) Reset() { + *x = ClearRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClearRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClearRequest) ProtoMessage() {} + +func (x *ClearRequest) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[12] + 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 ClearRequest.ProtoReflect.Descriptor instead. +func (*ClearRequest) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{12} +} + +func (x *ClearRequest) GetAction() *Action { + if x != nil { + return x.Action + } + return nil +} + +type ClearResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ClearResponse) Reset() { + *x = ClearResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClearResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClearResponse) ProtoMessage() {} + +func (x *ClearResponse) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[13] + 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 ClearResponse.ProtoReflect.Descriptor instead. +func (*ClearResponse) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{13} +} + +type ListResponse_Item struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Action *Action `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"` + Approver []*Principal `protobuf:"bytes,2,rep,name=approver,proto3" json:"approver,omitempty"` + Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` +} + +func (x *ListResponse_Item) Reset() { + *x = ListResponse_Item{} + if protoimpl.UnsafeEnabled { + mi := &file_mpa_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ListResponse_Item) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListResponse_Item) ProtoMessage() {} + +func (x *ListResponse_Item) ProtoReflect() protoreflect.Message { + mi := &file_mpa_proto_msgTypes[14] + 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 ListResponse_Item.ProtoReflect.Descriptor instead. +func (*ListResponse_Item) Descriptor() ([]byte, []int) { + return file_mpa_proto_rawDescGZIP(), []int{9, 0} +} + +func (x *ListResponse_Item) GetAction() *Action { + if x != nil { + return x.Action + } + return nil +} + +func (x *ListResponse_Item) GetApprover() []*Principal { + if x != nil { + return x.Approver + } + return nil +} + +func (x *ListResponse_Item) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +var File_mpa_proto protoreflect.FileDescriptor + +var file_mpa_proto_rawDesc = []byte{ + 0x0a, 0x09, 0x6d, 0x70, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x4d, 0x70, 0x61, + 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8a, 0x01, 0x0a, 0x06, + 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x24, 0x0a, 0x0d, 0x6a, 0x75, + 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0d, 0x6a, 0x75, 0x73, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x33, 0x0a, 0x09, 0x50, 0x72, 0x69, 0x6e, + 0x63, 0x69, 0x70, 0x61, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x73, 0x22, 0x56, 0x0a, + 0x0c, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, + 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, + 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x2e, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x70, 0x0a, 0x0d, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x23, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x41, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x08, 0x61, + 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, + 0x4d, 0x70, 0x61, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x52, 0x08, 0x61, + 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x22, 0x35, 0x0a, 0x0e, 0x41, 0x70, 0x70, 0x72, 0x6f, + 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x06, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4d, 0x70, 0x61, 0x2e, + 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x11, + 0x0a, 0x0f, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x28, 0x0a, 0x16, 0x57, 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, 0x41, 0x70, 0x70, 0x72, + 0x6f, 0x76, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x19, 0x0a, 0x17, 0x57, + 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x0d, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa3, 0x01, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x04, 0x69, 0x74, + 0x65, 0x6d, 0x1a, 0x67, 0x0a, 0x04, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x23, 0x0a, 0x06, 0x61, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4d, 0x70, 0x61, + 0x2e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x2a, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x0e, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, + 0x6c, 0x52, 0x08, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x1c, 0x0a, 0x0a, 0x47, + 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x5e, 0x0a, 0x0b, 0x47, 0x65, 0x74, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x06, 0x61, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x41, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, + 0x08, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x0e, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x61, 0x6c, 0x52, + 0x08, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x72, 0x22, 0x33, 0x0a, 0x0c, 0x43, 0x6c, 0x65, + 0x61, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x06, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x4d, 0x70, 0x61, 0x2e, + 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x0f, + 0x0a, 0x0d, 0x43, 0x6c, 0x65, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, + 0xcc, 0x02, 0x0a, 0x03, 0x4d, 0x70, 0x61, 0x12, 0x30, 0x0a, 0x05, 0x53, 0x74, 0x6f, 0x72, 0x65, + 0x12, 0x11, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x07, 0x41, 0x70, 0x70, + 0x72, 0x6f, 0x76, 0x65, 0x12, 0x13, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x41, 0x70, 0x70, 0x72, 0x6f, + 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x4d, 0x70, 0x61, 0x2e, + 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x4e, 0x0a, 0x0f, 0x57, 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, 0x41, 0x70, 0x70, 0x72, + 0x6f, 0x76, 0x61, 0x6c, 0x12, 0x1b, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x57, 0x61, 0x69, 0x74, 0x46, + 0x6f, 0x72, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1c, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x57, 0x61, 0x69, 0x74, 0x46, 0x6f, 0x72, 0x41, + 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x2d, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x10, 0x2e, 0x4d, 0x70, 0x61, 0x2e, + 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x4d, 0x70, + 0x61, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x2a, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x0f, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x47, 0x65, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x47, + 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x30, 0x0a, 0x05, + 0x43, 0x6c, 0x65, 0x61, 0x72, 0x12, 0x11, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x43, 0x6c, 0x65, 0x61, + 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x4d, 0x70, 0x61, 0x2e, 0x43, + 0x6c, 0x65, 0x61, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x29, + 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x53, 0x6e, 0x6f, + 0x77, 0x66, 0x6c, 0x61, 0x6b, 0x65, 0x2d, 0x4c, 0x61, 0x62, 0x73, 0x2f, 0x73, 0x61, 0x6e, 0x73, + 0x73, 0x68, 0x65, 0x6c, 0x6c, 0x2f, 0x6d, 0x70, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_mpa_proto_rawDescOnce sync.Once + file_mpa_proto_rawDescData = file_mpa_proto_rawDesc +) + +func file_mpa_proto_rawDescGZIP() []byte { + file_mpa_proto_rawDescOnce.Do(func() { + file_mpa_proto_rawDescData = protoimpl.X.CompressGZIP(file_mpa_proto_rawDescData) + }) + return file_mpa_proto_rawDescData +} + +var file_mpa_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_mpa_proto_goTypes = []interface{}{ + (*Action)(nil), // 0: Mpa.Action + (*Principal)(nil), // 1: Mpa.Principal + (*StoreRequest)(nil), // 2: Mpa.StoreRequest + (*StoreResponse)(nil), // 3: Mpa.StoreResponse + (*ApproveRequest)(nil), // 4: Mpa.ApproveRequest + (*ApproveResponse)(nil), // 5: Mpa.ApproveResponse + (*WaitForApprovalRequest)(nil), // 6: Mpa.WaitForApprovalRequest + (*WaitForApprovalResponse)(nil), // 7: Mpa.WaitForApprovalResponse + (*ListRequest)(nil), // 8: Mpa.ListRequest + (*ListResponse)(nil), // 9: Mpa.ListResponse + (*GetRequest)(nil), // 10: Mpa.GetRequest + (*GetResponse)(nil), // 11: Mpa.GetResponse + (*ClearRequest)(nil), // 12: Mpa.ClearRequest + (*ClearResponse)(nil), // 13: Mpa.ClearResponse + (*ListResponse_Item)(nil), // 14: Mpa.ListResponse.Item + (*anypb.Any)(nil), // 15: google.protobuf.Any +} +var file_mpa_proto_depIdxs = []int32{ + 15, // 0: Mpa.Action.message:type_name -> google.protobuf.Any + 15, // 1: Mpa.StoreRequest.message:type_name -> google.protobuf.Any + 0, // 2: Mpa.StoreResponse.action:type_name -> Mpa.Action + 1, // 3: Mpa.StoreResponse.approver:type_name -> Mpa.Principal + 0, // 4: Mpa.ApproveRequest.action:type_name -> Mpa.Action + 14, // 5: Mpa.ListResponse.item:type_name -> Mpa.ListResponse.Item + 0, // 6: Mpa.GetResponse.action:type_name -> Mpa.Action + 1, // 7: Mpa.GetResponse.approver:type_name -> Mpa.Principal + 0, // 8: Mpa.ClearRequest.action:type_name -> Mpa.Action + 0, // 9: Mpa.ListResponse.Item.action:type_name -> Mpa.Action + 1, // 10: Mpa.ListResponse.Item.approver:type_name -> Mpa.Principal + 2, // 11: Mpa.Mpa.Store:input_type -> Mpa.StoreRequest + 4, // 12: Mpa.Mpa.Approve:input_type -> Mpa.ApproveRequest + 6, // 13: Mpa.Mpa.WaitForApproval:input_type -> Mpa.WaitForApprovalRequest + 8, // 14: Mpa.Mpa.List:input_type -> Mpa.ListRequest + 10, // 15: Mpa.Mpa.Get:input_type -> Mpa.GetRequest + 12, // 16: Mpa.Mpa.Clear:input_type -> Mpa.ClearRequest + 3, // 17: Mpa.Mpa.Store:output_type -> Mpa.StoreResponse + 5, // 18: Mpa.Mpa.Approve:output_type -> Mpa.ApproveResponse + 7, // 19: Mpa.Mpa.WaitForApproval:output_type -> Mpa.WaitForApprovalResponse + 9, // 20: Mpa.Mpa.List:output_type -> Mpa.ListResponse + 11, // 21: Mpa.Mpa.Get:output_type -> Mpa.GetResponse + 13, // 22: Mpa.Mpa.Clear:output_type -> Mpa.ClearResponse + 17, // [17:23] is the sub-list for method output_type + 11, // [11:17] 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_mpa_proto_init() } +func file_mpa_proto_init() { + if File_mpa_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_mpa_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Action); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Principal); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StoreRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StoreResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ApproveRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ApproveResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WaitForApprovalRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*WaitForApprovalResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClearRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClearResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mpa_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ListResponse_Item); 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{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_mpa_proto_rawDesc, + NumEnums: 0, + NumMessages: 15, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_mpa_proto_goTypes, + DependencyIndexes: file_mpa_proto_depIdxs, + MessageInfos: file_mpa_proto_msgTypes, + }.Build() + File_mpa_proto = out.File + file_mpa_proto_rawDesc = nil + file_mpa_proto_goTypes = nil + file_mpa_proto_depIdxs = nil +} diff --git a/services/mpa/mpa.proto b/services/mpa/mpa.proto new file mode 100644 index 00000000..2e140be9 --- /dev/null +++ b/services/mpa/mpa.proto @@ -0,0 +1,120 @@ +/* Copyright (c) 2022 Snowflake Inc. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +syntax = "proto3"; + +option go_package = "github.com/Snowflake-Labs/sansshell/mpa"; + +import "google/protobuf/any.proto"; + +package Mpa; + +// The Mpa service definition +service Mpa { + // Store a request that we'd like to try running in the future. Requests + // are stored in-memory and older requests may be cleared automatically. + // This call is idempotent - requests from the same user with the same + // contents will return the same id. + // + // The user for the request and any justification is implicitly passed in + // via inspecting the peer of the RPC or via gRPC metadata. + rpc Store(StoreRequest) returns (StoreResponse) {} + // Approve a previously stored request. A request can have multiple approvals + // and can be approved by anybody but the original user that stored the request. + // + // The user for the request is implicitly passed in via inspecting the + // peer of the RPC or via gRPC metadata. + rpc Approve(ApproveRequest) returns (ApproveResponse) {} + // Block until at least one approval has been granted. This is used + // as an optimization to avoid needing to poll for MPA approval. + rpc WaitForApproval(WaitForApprovalRequest) returns (WaitForApprovalResponse) {} + // List available requests. + rpc List(ListRequest) returns (ListResponse) {} + // Get a request and all approvals associated with it. + rpc Get(GetRequest) returns (GetResponse) {} + // Clear a stored request. + // + // This is typically unnecessary due to how requests are stored in memory + // and forgotten after a process restart. + rpc Clear(ClearRequest) returns (ClearResponse) {} +} + +message Action { + // The user that created the request. + string user = 1; + // User-supplied information on why the request is being made. + string justification = 2; + // The GRPC method name, as '/Package.Service/Method' + string method = 3; + // The request protocol buffer. + google.protobuf.Any message = 4; +} + +message Principal { + // The principal identifier (e.g. a username or service role) + string id = 1; + // Auxiliary groups associated with this principal. + repeated string groups = 2; +} + + +message StoreRequest { + // The GRPC method name, as '/Package.Service/Method' + string method = 1; + // The request protocol buffer. + google.protobuf.Any message = 2; +} + +message StoreResponse { + string id = 1; + Action action = 2; + // All approvers of the request. Storing is idempotent, so + // approvers may be non-empty if we're storing a previously + // approved command. + repeated Principal approver = 3; +} + +message ApproveRequest { + // Approve takes an action instead of an ID to improve auditability + // and allow richer authorization logic. + Action action = 1; +} +message ApproveResponse {} + +message WaitForApprovalRequest { string id = 1; } +message WaitForApprovalResponse {} + +message ListRequest {} +message ListResponse { + message Item { + Action action = 1; + repeated Principal approver = 2; + string id = 3; + } + repeated Item item = 1; +} + +message GetRequest { string id = 1; } + +message GetResponse { + Action action = 1; + + // All approvers of the request. + repeated Principal approver = 2; +} + +message ClearRequest { Action action = 1; } +message ClearResponse {} \ No newline at end of file diff --git a/services/mpa/mpa_grpc.pb.go b/services/mpa/mpa_grpc.pb.go new file mode 100644 index 00000000..701253d0 --- /dev/null +++ b/services/mpa/mpa_grpc.pb.go @@ -0,0 +1,347 @@ +// Copyright (c) 2022 Snowflake Inc. All rights reserved. +// +//Licensed under the Apache License, Version 2.0 (the +//"License"); you may not use this file except in compliance +//with the License. You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +//Unless required by applicable law or agreed to in writing, +//software distributed under the License is distributed on an +//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +//KIND, either express or implied. See the License for the +//specific language governing permissions and limitations +//under the License. + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v3.19.6 +// source: mpa.proto + +package mpa + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +const ( + Mpa_Store_FullMethodName = "/Mpa.Mpa/Store" + Mpa_Approve_FullMethodName = "/Mpa.Mpa/Approve" + Mpa_WaitForApproval_FullMethodName = "/Mpa.Mpa/WaitForApproval" + Mpa_List_FullMethodName = "/Mpa.Mpa/List" + Mpa_Get_FullMethodName = "/Mpa.Mpa/Get" + Mpa_Clear_FullMethodName = "/Mpa.Mpa/Clear" +) + +// MpaClient is the client API for Mpa 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 MpaClient interface { + // Store a request that we'd like to try running in the future. Requests + // are stored in-memory and older requests may be cleared automatically. + // This call is idempotent - requests from the same user with the same + // contents will return the same id. + // + // The user for the request and any justification is implicitly passed in + // via inspecting the peer of the RPC or via gRPC metadata. + Store(ctx context.Context, in *StoreRequest, opts ...grpc.CallOption) (*StoreResponse, error) + // Approve a previously stored request. A request can have multiple approvals + // and can be approved by anybody but the original user that stored the request. + // + // The user for the request is implicitly passed in via inspecting the + // peer of the RPC or via gRPC metadata. + Approve(ctx context.Context, in *ApproveRequest, opts ...grpc.CallOption) (*ApproveResponse, error) + // Block until at least one approval has been granted. This is used + // as an optimization to avoid needing to poll for MPA approval. + WaitForApproval(ctx context.Context, in *WaitForApprovalRequest, opts ...grpc.CallOption) (*WaitForApprovalResponse, error) + // List available requests. + List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) + // Get a request and all approvals associated with it. + Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) + // Clear a stored request. + // + // This is typically unnecessary due to how requests are stored in memory + // and forgotten after a process restart. + Clear(ctx context.Context, in *ClearRequest, opts ...grpc.CallOption) (*ClearResponse, error) +} + +type mpaClient struct { + cc grpc.ClientConnInterface +} + +func NewMpaClient(cc grpc.ClientConnInterface) MpaClient { + return &mpaClient{cc} +} + +func (c *mpaClient) Store(ctx context.Context, in *StoreRequest, opts ...grpc.CallOption) (*StoreResponse, error) { + out := new(StoreResponse) + err := c.cc.Invoke(ctx, Mpa_Store_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *mpaClient) Approve(ctx context.Context, in *ApproveRequest, opts ...grpc.CallOption) (*ApproveResponse, error) { + out := new(ApproveResponse) + err := c.cc.Invoke(ctx, Mpa_Approve_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *mpaClient) WaitForApproval(ctx context.Context, in *WaitForApprovalRequest, opts ...grpc.CallOption) (*WaitForApprovalResponse, error) { + out := new(WaitForApprovalResponse) + err := c.cc.Invoke(ctx, Mpa_WaitForApproval_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *mpaClient) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) { + out := new(ListResponse) + err := c.cc.Invoke(ctx, Mpa_List_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *mpaClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) { + out := new(GetResponse) + err := c.cc.Invoke(ctx, Mpa_Get_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *mpaClient) Clear(ctx context.Context, in *ClearRequest, opts ...grpc.CallOption) (*ClearResponse, error) { + out := new(ClearResponse) + err := c.cc.Invoke(ctx, Mpa_Clear_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MpaServer is the server API for Mpa service. +// All implementations should embed UnimplementedMpaServer +// for forward compatibility +type MpaServer interface { + // Store a request that we'd like to try running in the future. Requests + // are stored in-memory and older requests may be cleared automatically. + // This call is idempotent - requests from the same user with the same + // contents will return the same id. + // + // The user for the request and any justification is implicitly passed in + // via inspecting the peer of the RPC or via gRPC metadata. + Store(context.Context, *StoreRequest) (*StoreResponse, error) + // Approve a previously stored request. A request can have multiple approvals + // and can be approved by anybody but the original user that stored the request. + // + // The user for the request is implicitly passed in via inspecting the + // peer of the RPC or via gRPC metadata. + Approve(context.Context, *ApproveRequest) (*ApproveResponse, error) + // Block until at least one approval has been granted. This is used + // as an optimization to avoid needing to poll for MPA approval. + WaitForApproval(context.Context, *WaitForApprovalRequest) (*WaitForApprovalResponse, error) + // List available requests. + List(context.Context, *ListRequest) (*ListResponse, error) + // Get a request and all approvals associated with it. + Get(context.Context, *GetRequest) (*GetResponse, error) + // Clear a stored request. + // + // This is typically unnecessary due to how requests are stored in memory + // and forgotten after a process restart. + Clear(context.Context, *ClearRequest) (*ClearResponse, error) +} + +// UnimplementedMpaServer should be embedded to have forward compatible implementations. +type UnimplementedMpaServer struct { +} + +func (UnimplementedMpaServer) Store(context.Context, *StoreRequest) (*StoreResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Store not implemented") +} +func (UnimplementedMpaServer) Approve(context.Context, *ApproveRequest) (*ApproveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Approve not implemented") +} +func (UnimplementedMpaServer) WaitForApproval(context.Context, *WaitForApprovalRequest) (*WaitForApprovalResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WaitForApproval not implemented") +} +func (UnimplementedMpaServer) List(context.Context, *ListRequest) (*ListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method List not implemented") +} +func (UnimplementedMpaServer) Get(context.Context, *GetRequest) (*GetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") +} +func (UnimplementedMpaServer) Clear(context.Context, *ClearRequest) (*ClearResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Clear not implemented") +} + +// UnsafeMpaServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to MpaServer will +// result in compilation errors. +type UnsafeMpaServer interface { + mustEmbedUnimplementedMpaServer() +} + +func RegisterMpaServer(s grpc.ServiceRegistrar, srv MpaServer) { + s.RegisterService(&Mpa_ServiceDesc, srv) +} + +func _Mpa_Store_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(StoreRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MpaServer).Store(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Mpa_Store_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MpaServer).Store(ctx, req.(*StoreRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Mpa_Approve_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ApproveRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MpaServer).Approve(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Mpa_Approve_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MpaServer).Approve(ctx, req.(*ApproveRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Mpa_WaitForApproval_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(WaitForApprovalRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MpaServer).WaitForApproval(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Mpa_WaitForApproval_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MpaServer).WaitForApproval(ctx, req.(*WaitForApprovalRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Mpa_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MpaServer).List(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Mpa_List_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MpaServer).List(ctx, req.(*ListRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Mpa_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MpaServer).Get(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Mpa_Get_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MpaServer).Get(ctx, req.(*GetRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Mpa_Clear_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ClearRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MpaServer).Clear(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Mpa_Clear_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MpaServer).Clear(ctx, req.(*ClearRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Mpa_ServiceDesc is the grpc.ServiceDesc for Mpa service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Mpa_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "Mpa.Mpa", + HandlerType: (*MpaServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Store", + Handler: _Mpa_Store_Handler, + }, + { + MethodName: "Approve", + Handler: _Mpa_Approve_Handler, + }, + { + MethodName: "WaitForApproval", + Handler: _Mpa_WaitForApproval_Handler, + }, + { + MethodName: "List", + Handler: _Mpa_List_Handler, + }, + { + MethodName: "Get", + Handler: _Mpa_Get_Handler, + }, + { + MethodName: "Clear", + Handler: _Mpa_Clear_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "mpa.proto", +} diff --git a/services/mpa/mpa_grpcproxy.pb.go b/services/mpa/mpa_grpcproxy.pb.go new file mode 100644 index 00000000..b5ddd5b7 --- /dev/null +++ b/services/mpa/mpa_grpcproxy.pb.go @@ -0,0 +1,440 @@ +// Auto generated code by protoc-gen-go-grpcproxy +// DO NOT EDIT + +// Adds OneMany versions of RPC methods for use by proxy clients + +package mpa + +import ( + context "context" + proxy "github.com/Snowflake-Labs/sansshell/proxy/proxy" + grpc "google.golang.org/grpc" +) + +import ( + "fmt" +) + +// MpaClientProxy is the superset of MpaClient which additionally includes the OneMany proxy methods +type MpaClientProxy interface { + MpaClient + StoreOneMany(ctx context.Context, in *StoreRequest, opts ...grpc.CallOption) (<-chan *StoreManyResponse, error) + ApproveOneMany(ctx context.Context, in *ApproveRequest, opts ...grpc.CallOption) (<-chan *ApproveManyResponse, error) + WaitForApprovalOneMany(ctx context.Context, in *WaitForApprovalRequest, opts ...grpc.CallOption) (<-chan *WaitForApprovalManyResponse, error) + ListOneMany(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (<-chan *ListManyResponse, error) + GetOneMany(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (<-chan *GetManyResponse, error) + ClearOneMany(ctx context.Context, in *ClearRequest, opts ...grpc.CallOption) (<-chan *ClearManyResponse, error) +} + +// Embed the original client inside of this so we get the other generated methods automatically. +type mpaClientProxy struct { + *mpaClient +} + +// NewMpaClientProxy creates a MpaClientProxy for use in proxied connections. +// NOTE: This takes a proxy.Conn instead of a generic ClientConnInterface as the methods here are only valid in proxy.Conn contexts. +func NewMpaClientProxy(cc *proxy.Conn) MpaClientProxy { + return &mpaClientProxy{NewMpaClient(cc).(*mpaClient)} +} + +// StoreManyResponse encapsulates a proxy data packet. +// It includes the target, index, response and possible error returned. +type StoreManyResponse struct { + Target string + // As targets can be duplicated this is the index into the slice passed to proxy.Conn. + Index int + Resp *StoreResponse + Error error +} + +// StoreOneMany provides the same API as Store but sends the same request to N destinations at once. +// N can be a single destination. +// +// NOTE: The returned channel must be read until it closes in order to avoid leaking goroutines. +func (c *mpaClientProxy) StoreOneMany(ctx context.Context, in *StoreRequest, opts ...grpc.CallOption) (<-chan *StoreManyResponse, error) { + conn := c.cc.(*proxy.Conn) + ret := make(chan *StoreManyResponse) + // If this is a single case we can just use Invoke and marshal it onto the channel once and be done. + if len(conn.Targets) == 1 { + go func() { + out := &StoreManyResponse{ + Target: conn.Targets[0], + Index: 0, + Resp: &StoreResponse{}, + } + err := conn.Invoke(ctx, "/Mpa.Mpa/Store", in, out.Resp, opts...) + if err != nil { + out.Error = err + } + // Send and close. + ret <- out + close(ret) + }() + return ret, nil + } + manyRet, err := conn.InvokeOneMany(ctx, "/Mpa.Mpa/Store", in, opts...) + if err != nil { + return nil, err + } + // A goroutine to retrive untyped responses and convert them to typed ones. + go func() { + for { + typedResp := &StoreManyResponse{ + Resp: &StoreResponse{}, + } + + resp, ok := <-manyRet + if !ok { + // All done so we can shut down. + close(ret) + return + } + typedResp.Target = resp.Target + typedResp.Index = resp.Index + typedResp.Error = resp.Error + if resp.Error == nil { + if err := resp.Resp.UnmarshalTo(typedResp.Resp); err != nil { + typedResp.Error = fmt.Errorf("can't decode any response - %v. Original Error - %v", err, resp.Error) + } + } + ret <- typedResp + } + }() + + return ret, nil +} + +// ApproveManyResponse encapsulates a proxy data packet. +// It includes the target, index, response and possible error returned. +type ApproveManyResponse struct { + Target string + // As targets can be duplicated this is the index into the slice passed to proxy.Conn. + Index int + Resp *ApproveResponse + Error error +} + +// ApproveOneMany provides the same API as Approve but sends the same request to N destinations at once. +// N can be a single destination. +// +// NOTE: The returned channel must be read until it closes in order to avoid leaking goroutines. +func (c *mpaClientProxy) ApproveOneMany(ctx context.Context, in *ApproveRequest, opts ...grpc.CallOption) (<-chan *ApproveManyResponse, error) { + conn := c.cc.(*proxy.Conn) + ret := make(chan *ApproveManyResponse) + // If this is a single case we can just use Invoke and marshal it onto the channel once and be done. + if len(conn.Targets) == 1 { + go func() { + out := &ApproveManyResponse{ + Target: conn.Targets[0], + Index: 0, + Resp: &ApproveResponse{}, + } + err := conn.Invoke(ctx, "/Mpa.Mpa/Approve", in, out.Resp, opts...) + if err != nil { + out.Error = err + } + // Send and close. + ret <- out + close(ret) + }() + return ret, nil + } + manyRet, err := conn.InvokeOneMany(ctx, "/Mpa.Mpa/Approve", in, opts...) + if err != nil { + return nil, err + } + // A goroutine to retrive untyped responses and convert them to typed ones. + go func() { + for { + typedResp := &ApproveManyResponse{ + Resp: &ApproveResponse{}, + } + + resp, ok := <-manyRet + if !ok { + // All done so we can shut down. + close(ret) + return + } + typedResp.Target = resp.Target + typedResp.Index = resp.Index + typedResp.Error = resp.Error + if resp.Error == nil { + if err := resp.Resp.UnmarshalTo(typedResp.Resp); err != nil { + typedResp.Error = fmt.Errorf("can't decode any response - %v. Original Error - %v", err, resp.Error) + } + } + ret <- typedResp + } + }() + + return ret, nil +} + +// WaitForApprovalManyResponse encapsulates a proxy data packet. +// It includes the target, index, response and possible error returned. +type WaitForApprovalManyResponse struct { + Target string + // As targets can be duplicated this is the index into the slice passed to proxy.Conn. + Index int + Resp *WaitForApprovalResponse + Error error +} + +// WaitForApprovalOneMany provides the same API as WaitForApproval but sends the same request to N destinations at once. +// N can be a single destination. +// +// NOTE: The returned channel must be read until it closes in order to avoid leaking goroutines. +func (c *mpaClientProxy) WaitForApprovalOneMany(ctx context.Context, in *WaitForApprovalRequest, opts ...grpc.CallOption) (<-chan *WaitForApprovalManyResponse, error) { + conn := c.cc.(*proxy.Conn) + ret := make(chan *WaitForApprovalManyResponse) + // If this is a single case we can just use Invoke and marshal it onto the channel once and be done. + if len(conn.Targets) == 1 { + go func() { + out := &WaitForApprovalManyResponse{ + Target: conn.Targets[0], + Index: 0, + Resp: &WaitForApprovalResponse{}, + } + err := conn.Invoke(ctx, "/Mpa.Mpa/WaitForApproval", in, out.Resp, opts...) + if err != nil { + out.Error = err + } + // Send and close. + ret <- out + close(ret) + }() + return ret, nil + } + manyRet, err := conn.InvokeOneMany(ctx, "/Mpa.Mpa/WaitForApproval", in, opts...) + if err != nil { + return nil, err + } + // A goroutine to retrive untyped responses and convert them to typed ones. + go func() { + for { + typedResp := &WaitForApprovalManyResponse{ + Resp: &WaitForApprovalResponse{}, + } + + resp, ok := <-manyRet + if !ok { + // All done so we can shut down. + close(ret) + return + } + typedResp.Target = resp.Target + typedResp.Index = resp.Index + typedResp.Error = resp.Error + if resp.Error == nil { + if err := resp.Resp.UnmarshalTo(typedResp.Resp); err != nil { + typedResp.Error = fmt.Errorf("can't decode any response - %v. Original Error - %v", err, resp.Error) + } + } + ret <- typedResp + } + }() + + return ret, nil +} + +// ListManyResponse encapsulates a proxy data packet. +// It includes the target, index, response and possible error returned. +type ListManyResponse struct { + Target string + // As targets can be duplicated this is the index into the slice passed to proxy.Conn. + Index int + Resp *ListResponse + Error error +} + +// ListOneMany provides the same API as List but sends the same request to N destinations at once. +// N can be a single destination. +// +// NOTE: The returned channel must be read until it closes in order to avoid leaking goroutines. +func (c *mpaClientProxy) ListOneMany(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (<-chan *ListManyResponse, error) { + conn := c.cc.(*proxy.Conn) + ret := make(chan *ListManyResponse) + // If this is a single case we can just use Invoke and marshal it onto the channel once and be done. + if len(conn.Targets) == 1 { + go func() { + out := &ListManyResponse{ + Target: conn.Targets[0], + Index: 0, + Resp: &ListResponse{}, + } + err := conn.Invoke(ctx, "/Mpa.Mpa/List", in, out.Resp, opts...) + if err != nil { + out.Error = err + } + // Send and close. + ret <- out + close(ret) + }() + return ret, nil + } + manyRet, err := conn.InvokeOneMany(ctx, "/Mpa.Mpa/List", in, opts...) + if err != nil { + return nil, err + } + // A goroutine to retrive untyped responses and convert them to typed ones. + go func() { + for { + typedResp := &ListManyResponse{ + Resp: &ListResponse{}, + } + + resp, ok := <-manyRet + if !ok { + // All done so we can shut down. + close(ret) + return + } + typedResp.Target = resp.Target + typedResp.Index = resp.Index + typedResp.Error = resp.Error + if resp.Error == nil { + if err := resp.Resp.UnmarshalTo(typedResp.Resp); err != nil { + typedResp.Error = fmt.Errorf("can't decode any response - %v. Original Error - %v", err, resp.Error) + } + } + ret <- typedResp + } + }() + + return ret, nil +} + +// GetManyResponse encapsulates a proxy data packet. +// It includes the target, index, response and possible error returned. +type GetManyResponse struct { + Target string + // As targets can be duplicated this is the index into the slice passed to proxy.Conn. + Index int + Resp *GetResponse + Error error +} + +// GetOneMany provides the same API as Get but sends the same request to N destinations at once. +// N can be a single destination. +// +// NOTE: The returned channel must be read until it closes in order to avoid leaking goroutines. +func (c *mpaClientProxy) GetOneMany(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (<-chan *GetManyResponse, error) { + conn := c.cc.(*proxy.Conn) + ret := make(chan *GetManyResponse) + // If this is a single case we can just use Invoke and marshal it onto the channel once and be done. + if len(conn.Targets) == 1 { + go func() { + out := &GetManyResponse{ + Target: conn.Targets[0], + Index: 0, + Resp: &GetResponse{}, + } + err := conn.Invoke(ctx, "/Mpa.Mpa/Get", in, out.Resp, opts...) + if err != nil { + out.Error = err + } + // Send and close. + ret <- out + close(ret) + }() + return ret, nil + } + manyRet, err := conn.InvokeOneMany(ctx, "/Mpa.Mpa/Get", in, opts...) + if err != nil { + return nil, err + } + // A goroutine to retrive untyped responses and convert them to typed ones. + go func() { + for { + typedResp := &GetManyResponse{ + Resp: &GetResponse{}, + } + + resp, ok := <-manyRet + if !ok { + // All done so we can shut down. + close(ret) + return + } + typedResp.Target = resp.Target + typedResp.Index = resp.Index + typedResp.Error = resp.Error + if resp.Error == nil { + if err := resp.Resp.UnmarshalTo(typedResp.Resp); err != nil { + typedResp.Error = fmt.Errorf("can't decode any response - %v. Original Error - %v", err, resp.Error) + } + } + ret <- typedResp + } + }() + + return ret, nil +} + +// ClearManyResponse encapsulates a proxy data packet. +// It includes the target, index, response and possible error returned. +type ClearManyResponse struct { + Target string + // As targets can be duplicated this is the index into the slice passed to proxy.Conn. + Index int + Resp *ClearResponse + Error error +} + +// ClearOneMany provides the same API as Clear but sends the same request to N destinations at once. +// N can be a single destination. +// +// NOTE: The returned channel must be read until it closes in order to avoid leaking goroutines. +func (c *mpaClientProxy) ClearOneMany(ctx context.Context, in *ClearRequest, opts ...grpc.CallOption) (<-chan *ClearManyResponse, error) { + conn := c.cc.(*proxy.Conn) + ret := make(chan *ClearManyResponse) + // If this is a single case we can just use Invoke and marshal it onto the channel once and be done. + if len(conn.Targets) == 1 { + go func() { + out := &ClearManyResponse{ + Target: conn.Targets[0], + Index: 0, + Resp: &ClearResponse{}, + } + err := conn.Invoke(ctx, "/Mpa.Mpa/Clear", in, out.Resp, opts...) + if err != nil { + out.Error = err + } + // Send and close. + ret <- out + close(ret) + }() + return ret, nil + } + manyRet, err := conn.InvokeOneMany(ctx, "/Mpa.Mpa/Clear", in, opts...) + if err != nil { + return nil, err + } + // A goroutine to retrive untyped responses and convert them to typed ones. + go func() { + for { + typedResp := &ClearManyResponse{ + Resp: &ClearResponse{}, + } + + resp, ok := <-manyRet + if !ok { + // All done so we can shut down. + close(ret) + return + } + typedResp.Target = resp.Target + typedResp.Index = resp.Index + typedResp.Error = resp.Error + if resp.Error == nil { + if err := resp.Resp.UnmarshalTo(typedResp.Resp); err != nil { + typedResp.Error = fmt.Errorf("can't decode any response - %v. Original Error - %v", err, resp.Error) + } + } + ret <- typedResp + } + }() + + return ret, nil +}