Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: support grant request issue (#5943)

Danny Xu79ef7dcbb906
diff --git a/backend/api/v1/review_service.go b/backend/api/v1/review_service.go
index c5605bc93e..db74415b2e 100644
--- a/backend/api/v1/review_service.go
+++ b/backend/api/v1/review_service.go
@@ -137,6 +137,10 @@ func (s *ReviewService) ApproveReview(ctx context.Context, request *v1pb.Approve
return nil, status.Errorf(codes.Internal, "failed to update issue, error: %v", err)
}
+ // TODO(d): grant the privilege if the issue is approved.
+ // if len(payload.Approval.Approvers) > 0 {
+ // }
+
// It's ok to fail to create activity.
if err := func() error {
activityPayload, err := protojson.Marshal(&storepb.ActivityIssueCommentCreatePayload{
diff --git a/backend/legacyapi/issue.go b/backend/legacyapi/issue.go
index 7fc6b61512..d3f45d656e 100644
--- a/backend/legacyapi/issue.go
+++ b/backend/legacyapi/issue.go
@@ -33,8 +33,8 @@ const (
IssueDatabaseDataUpdate IssueType = "bb.issue.database.data.update"
// IssueDatabaseRestorePITR is the issue type for performing a Point-in-time Recovery.
IssueDatabaseRestorePITR IssueType = "bb.issue.database.restore.pitr"
- // IssueRequestPrivilege is the issue type for requesting privileges.
- IssueRequestPrivilege IssueType = "bb.issue.request.privilege"
+ // IssueGrantRequest is the issue type for requesting grant.
+ IssueGrantRequest IssueType = "bb.issue.grant.request"
)
// IssueFieldID is the field ID for an issue.
@@ -75,8 +75,8 @@ type Issue struct {
Project *Project `jsonapi:"relation,project"`
PipelineID int
Pipeline *Pipeline `jsonapi:"relation,pipeline"`
- // The requested privilege in PrivilegeRequest format.
- PrivilegeRequest string `jsonapi:"attr,privilegeRequest"`
+ // The requested grant in GrantRequest format.
+ GrantRequest string `jsonapi:"attr,grantRequest"`
// Domain specific fields
Name string `jsonapi:"attr,name"`
@@ -112,8 +112,6 @@ type IssueCreate struct {
CreateContext string `jsonapi:"attr,createContext"`
// ValidateOnly validates the request and previews the review, but does not actually post it.
ValidateOnly bool `jsonapi:"attr,validateOnly"`
- // The requested privilege in PrivilegeRequest format.
- PrivilegeRequest string `jsonapi:"attr,privilegeRequest"`
}
// CreateDatabaseContext is the issue create context for creating a database.
@@ -208,17 +206,6 @@ type PITRContext struct {
PointInTimeTs *int64 `json:"pointInTimeTs"`
}
-// PrivilegeRequest is the create context to request privileges.
-type PrivilegeRequest struct {
- // Requested Role.
- // Example "roles/Developer"
- Role string `json:"role"`
- // Requested user, e.g. "users/[email protected]".
- User string `json:"user"`
- // IAM binding condition in expr. Exp proto format
- Condition string `json:"condition"`
-}
-
// IssuePatch is the API message for patching an issue.
type IssuePatch struct {
Name *string `jsonapi:"attr,name"`
diff --git a/backend/legacyapi/sql.go b/backend/legacyapi/sql.go
index 72798f574c..5677a1d5b0 100644
--- a/backend/legacyapi/sql.go
+++ b/backend/legacyapi/sql.go
@@ -53,6 +53,8 @@ type SQLExecute struct {
// The maximum row count returned, only applicable to SELECT query.
// Not enforced if limit <= 0.
Limit int `jsonapi:"attr,limit"`
+ // The export flag indicates whether the query is used for exporting data.
+ Export bool `jsonapi:"attr,export"`
}
// SingleSQLResult is the API message for single SQL result.
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 56b34b4857..50bff86822 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -61,6 +61,8 @@ var issueTypeToRiskSource = map[api.IssueType]store.RiskSource{
api.IssueDatabaseDataUpdate: store.RiskSourceDatabaseDataUpdate,
// RiskSourceDatabaseCreate
api.IssueDatabaseCreate: store.RiskSourceDatabaseCreate,
+ // RiskGrantRequest.
+ api.IssueGrantRequest: store.RiskGrantRequest,
// RiskSourceUnknown
api.IssueGeneral: store.RiskSourceUnknown,
api.IssueDatabaseRestorePITR: store.RiskSourceUnknown,
@@ -177,36 +179,57 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.
}
return true, nil
}
-
- riskLevel, done, err := getIssueRiskLevel(ctx, r.store, issue, risks)
- if err != nil {
- err = errors.Wrap(err, "failed to get issue risk level")
- if updateErr := updateIssuePayload(ctx, r.store, issue.UID, &storepb.IssuePayload{
- Approval: &storepb.IssuePayloadApproval{
- ApprovalFindingDone: true,
- ApprovalFindingError: err.Error(),
+ var approvalTemplate *storepb.ApprovalTemplate
+ if issue.Type == api.IssueGrantRequest {
+ // TODO(d): sorry p0ny!
+ approvalTemplate = &storepb.ApprovalTemplate{
+ Flow: &storepb.ApprovalFlow{
+ Steps: []*storepb.ApprovalStep{
+ {
+ Type: storepb.ApprovalStep_ANY,
+ Nodes: []*storepb.ApprovalNode{
+ {
+ Type: storepb.ApprovalNode_ANY_IN_GROUP,
+ Payload: &storepb.ApprovalNode_GroupValue_{
+ GroupValue: storepb.ApprovalNode_PROJECT_OWNER,
+ },
+ },
+ },
+ },
+ },
},
- }); updateErr != nil {
- return false, multierr.Append(errors.Wrap(updateErr, "failed to update issue payload"), err)
}
- return false, err
- }
- if !done {
- return false, nil
- }
+ } else {
+ riskLevel, done, err := getIssueRiskLevel(ctx, r.store, issue, risks)
+ if err != nil {
+ err = errors.Wrap(err, "failed to get issue risk level")
+ if updateErr := updateIssuePayload(ctx, r.store, issue.UID, &storepb.IssuePayload{
+ Approval: &storepb.IssuePayloadApproval{
+ ApprovalFindingDone: true,
+ ApprovalFindingError: err.Error(),
+ },
+ }); updateErr != nil {
+ return false, multierr.Append(errors.Wrap(updateErr, "failed to update issue payload"), err)
+ }
+ return false, err
+ }
+ if !done {
+ return false, nil
+ }
- approvalTemplate, err := getApprovalTemplate(approvalSetting, riskLevel, issueTypeToRiskSource[issue.Type])
- if err != nil {
- err = errors.Wrapf(err, "failed to get approval template, riskLevel: %v", riskLevel)
- if updateErr := updateIssuePayload(ctx, r.store, issue.UID, &storepb.IssuePayload{
- Approval: &storepb.IssuePayloadApproval{
- ApprovalFindingDone: true,
- ApprovalFindingError: err.Error(),
- },
- }); updateErr != nil {
- return false, multierr.Append(errors.Wrap(updateErr, "failed to update issue payload"), err)
+ approvalTemplate, err = getApprovalTemplate(approvalSetting, riskLevel, issueTypeToRiskSource[issue.Type])
+ if err != nil {
+ err = errors.Wrapf(err, "failed to get approval template, riskLevel: %v", riskLevel)
+ if updateErr := updateIssuePayload(ctx, r.store, issue.UID, &storepb.IssuePayload{
+ Approval: &storepb.IssuePayloadApproval{
+ ApprovalFindingDone: true,
+ ApprovalFindingError: err.Error(),
+ },
+ }); updateErr != nil {
+ return false, multierr.Append(errors.Wrap(updateErr, "failed to update issue payload"), err)
+ }
+ return false, err
}
- return false, err
}
payload = &storepb.IssuePayload{
diff --git a/backend/server/issue.go b/backend/server/issue.go
index 76ba3c034f..14a6049258 100644
--- a/backend/server/issue.go
+++ b/backend/server/issue.go
@@ -372,6 +372,9 @@ func (s *Server) createIssue(ctx context.Context, issueCreate *api.IssueCreate,
if issueCreate.ProjectID == api.DefaultProjectUID {
return nil, echo.NewHTTPError(http.StatusBadRequest, "Cannot create a new issue in the default project")
}
+ if issueCreate.Type == api.IssueGrantRequest {
+ return s.createGrantRequestIssue(ctx, issueCreate, creatorID)
+ }
// Run pre-condition check first to make sure all tasks are valid, otherwise we will create partial pipelines
// since we are not creating pipeline/stage list/task list in a single transaction.
@@ -522,6 +525,99 @@ func (s *Server) createIssue(ctx context.Context, issueCreate *api.IssueCreate,
return composedIssue, nil
}
+func (s *Server) createGrantRequestIssue(ctx context.Context, issueCreate *api.IssueCreate, creatorID int) (*api.Issue, error) {
+ project, err := s.store.GetProjectV2(ctx, &store.FindProjectMessage{UID: &issueCreate.ProjectID})
+ if err != nil {
+ return nil, err
+ }
+ if project == nil {
+ return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("project %d not found", issueCreate.ProjectID))
+ }
+ policy, err := s.store.GetProjectPolicy(ctx, &store.GetProjectPolicyMessage{ProjectID: &project.ResourceID})
+ if err != nil {
+ return nil, err
+ }
+ var assignee *store.UserMessage
+ for _, binding := range policy.Bindings {
+ if binding.Role != api.Owner {
+ continue
+ }
+ if binding.Condition == nil || binding.Condition.Expression != "" {
+ continue
+ }
+ if len(binding.Members) == 0 {
+ continue
+ }
+ assignee = binding.Members[0]
+ break
+ }
+ if assignee == nil {
+ return nil, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("project owner %d not found", issueCreate.ProjectID))
+ }
+
+ var issuePayload storepb.IssuePayload
+ if err := protojson.Unmarshal([]byte(issueCreate.Payload), &issuePayload); err != nil {
+ return nil, err
+ }
+ issueCreatePayload := &storepb.IssuePayload{
+ GrantRequest: issuePayload.GrantRequest,
+ Approval: &storepb.IssuePayloadApproval{
+ ApprovalFindingDone: false,
+ },
+ }
+ issueCreatePayloadBytes, err := protojson.Marshal(issueCreatePayload)
+ if err != nil {
+ return nil, echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal issue payload").SetInternal(err)
+ }
+ issueCreateMessage := &store.IssueMessage{
+ Project: project,
+ Title: issueCreate.Name,
+ Type: issueCreate.Type,
+ Description: issueCreate.Description,
+ Assignee: assignee,
+ NeedAttention: issueCreate.AssigneeNeedAttention,
+ Payload: string(issueCreatePayloadBytes),
+ }
+ issue, err := s.store.CreateIssueV2(ctx, issueCreateMessage, creatorID)
+ if err != nil {
+ return nil, err
+ }
+
+ // Composed the issue.
+ composedIssue := &api.Issue{
+ ID: issue.UID,
+ CreatorID: issue.Creator.ID,
+ CreatedTs: issue.CreatedTime.Unix(),
+ UpdaterID: issue.Updater.ID,
+ UpdatedTs: issue.UpdatedTime.Unix(),
+ ProjectID: issue.Project.UID,
+ PipelineID: issue.PipelineUID,
+ Name: issue.Title,
+ Status: issue.Status,
+ Type: issue.Type,
+ Description: issue.Description,
+ AssigneeID: issue.Assignee.ID,
+ AssigneeNeedAttention: issue.NeedAttention,
+ Payload: issue.Payload,
+ }
+ composedCreator, err := s.store.GetPrincipalByID(ctx, issue.Creator.ID)
+ if err != nil {
+ return nil, err
+ }
+ composedIssue.Creator = composedCreator
+ composedUpdater, err := s.store.GetPrincipalByID(ctx, issue.Updater.ID)
+ if err != nil {
+ return nil, err
+ }
+ composedIssue.Updater = composedUpdater
+ composedAssignee, err := s.store.GetPrincipalByID(ctx, issue.Assignee.ID)
+ if err != nil {
+ return nil, err
+ }
+ composedIssue.Assignee = composedAssignee
+ return composedIssue, nil
+}
+
func (s *Server) createPipeline(ctx context.Context, creatorID int, pipelineCreate *api.PipelineCreate) (*store.PipelineMessage, error) {
pipelineCreated, err := s.store.CreatePipelineV2(ctx, &store.PipelineMessage{Name: pipelineCreate.Name}, creatorID)
if err != nil {
diff --git a/backend/store/risk.go b/backend/store/risk.go
index 7c608392b0..9e98aab95d 100644
--- a/backend/store/risk.go
+++ b/backend/store/risk.go
@@ -25,6 +25,8 @@ const (
RiskSourceDatabaseDataUpdate RiskSource = "bb.risk.database.data.update"
// RiskSourceDatabaseCreate is for creating databases.
RiskSourceDatabaseCreate RiskSource = "bb.risk.database.create"
+ // RiskGrantRequest is for requesting grant.
+ RiskGrantRequest RiskSource = "bb.risk.request.grant"
)
// RiskMessage is the message for risks.
diff --git a/frontend/src/types/proto/store/issue.ts b/frontend/src/types/proto/store/issue.ts
index 3aeb3e9f21..1d38d0a216 100644
--- a/frontend/src/types/proto/store/issue.ts
+++ b/frontend/src/types/proto/store/issue.ts
@@ -1,15 +1,25 @@
/* eslint-disable */
import * as _m0 from "protobufjs/minimal";
+import { Expr } from "../google/type/expr";
import { IssuePayloadApproval } from "./approval";
export const protobufPackage = "bytebase.store";
export interface IssuePayload {
approval?: IssuePayloadApproval;
+ grantRequest?: GrantRequest;
+}
+
+export interface GrantRequest {
+ /** The requested role, e.g. roles/EXPORTER. */
+ role: string;
+ /** The requested user, e.g. users/[email protected]. */
+ user: string;
+ condition?: Expr;
}
function createBaseIssuePayload(): IssuePayload {
- return { approval: undefined };
+ return { approval: undefined, grantRequest: undefined };
}
export const IssuePayload = {
@@ -17,6 +27,9 @@ export const IssuePayload = {
if (message.approval !== undefined) {
IssuePayloadApproval.encode(message.approval, writer.uint32(10).fork()).ldelim();
}
+ if (message.grantRequest !== undefined) {
+ GrantRequest.encode(message.grantRequest, writer.uint32(18).fork()).ldelim();
+ }
return writer;
},
@@ -34,6 +47,13 @@ export const IssuePayload = {
message.approval = IssuePayloadApproval.decode(reader, reader.uint32());
continue;
+ case 2:
+ if (tag !== 18) {
+ break;
+ }
+
+ message.grantRequest = GrantRequest.decode(reader, reader.uint32());
+ continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
@@ -44,13 +64,18 @@ export const IssuePayload = {
},
fromJSON(object: any): IssuePayload {
- return { approval: isSet(object.approval) ? IssuePayloadApproval.fromJSON(object.approval) : undefined };
+ return {
+ approval: isSet(object.approval) ? IssuePayloadApproval.fromJSON(object.approval) : undefined,
+ grantRequest: isSet(object.grantRequest) ? GrantRequest.fromJSON(object.grantRequest) : undefined,
+ };
},
toJSON(message: IssuePayload): unknown {
const obj: any = {};
message.approval !== undefined &&
(obj.approval = message.approval ? IssuePayloadApproval.toJSON(message.approval) : undefined);
+ message.grantRequest !== undefined &&
+ (obj.grantRequest = message.grantRequest ? GrantRequest.toJSON(message.grantRequest) : undefined);
return obj;
},
@@ -63,6 +88,95 @@ export const IssuePayload = {
message.approval = (object.approval !== undefined && object.approval !== null)
? IssuePayloadApproval.fromPartial(object.approval)
: undefined;
+ message.grantRequest = (object.grantRequest !== undefined && object.grantRequest !== null)
+ ? GrantRequest.fromPartial(object.grantRequest)
+ : undefined;
+ return message;
+ },
+};
+
+function createBaseGrantRequest(): GrantRequest {
+ return { role: "", user: "", condition: undefined };
+}
+
+export const GrantRequest = {
+ encode(message: GrantRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.role !== "") {
+ writer.uint32(10).string(message.role);
+ }
+ if (message.user !== "") {
+ writer.uint32(18).string(message.user);
+ }
+ if (message.condition !== undefined) {
+ Expr.encode(message.condition, writer.uint32(26).fork()).ldelim();
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): GrantRequest {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseGrantRequest();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag !== 10) {
+ break;
+ }
+
+ message.role = reader.string();
+ continue;
+ case 2:
+ if (tag !== 18) {
+ break;
+ }
+
+ message.user = reader.string();
+ continue;
+ case 3:
+ if (tag !== 26) {
+ break;
+ }
+
+ message.condition = Expr.decode(reader, reader.uint32());
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): GrantRequest {
+ return {
+ role: isSet(object.role) ? String(object.role) : "",
+ user: isSet(object.user) ? String(object.user) : "",
+ condition: isSet(object.condition) ? Expr.fromJSON(object.condition) : undefined,
+ };
+ },
+
+ toJSON(message: GrantRequest): unknown {
+ const obj: any = {};
+ message.role !== undefined && (obj.role = message.role);
+ message.user !== undefined && (obj.user = message.user);
+ message.condition !== undefined && (obj.condition = message.condition ? Expr.toJSON(message.condition) : undefined);
+ return obj;
+ },
+
+ create(base?: DeepPartial<GrantRequest>): GrantRequest {
+ return GrantRequest.fromPartial(base ?? {});
+ },
+
+ fromPartial(object: DeepPartial<GrantRequest>): GrantRequest {
+ const message = createBaseGrantRequest();
+ message.role = object.role ?? "";
+ message.user = object.user ?? "";
+ message.condition = (object.condition !== undefined && object.condition !== null)
+ ? Expr.fromPartial(object.condition)
+ : undefined;
return message;
},
};
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index 8d4c7c8bd8..30a4f81324 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -55,6 +55,7 @@
- [IdentityProviderType](#bytebase-store-IdentityProviderType)
- [store/issue.proto](#store_issue-proto)
+ - [GrantRequest](#bytebase-store-GrantRequest)
- [IssuePayload](#bytebase-store-IssuePayload)
- [store/setting.proto](#store_setting-proto)
@@ -840,6 +841,23 @@ OIDCIdentityProviderConfig is the structure for OIDC identity provider config.
+<a name="bytebase-store-GrantRequest"></a>
+
+### GrantRequest
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| role | [string](#string) | | The requested role, e.g. roles/EXPORTER. |
+| user | [string](#string) | | The requested user, e.g. users/[email protected]. |
+| condition | [google.type.Expr](#google-type-Expr) | | |
+
+
+
+
+
+
<a name="bytebase-store-IssuePayload"></a>
### IssuePayload
@@ -849,6 +867,7 @@ OIDCIdentityProviderConfig is the structure for OIDC identity provider config.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| approval | [IssuePayloadApproval](#bytebase-store-IssuePayloadApproval) | | |
+| grant_request | [GrantRequest](#bytebase-store-GrantRequest) | | |
diff --git a/proto/generated-go/store/issue.pb.go b/proto/generated-go/store/issue.pb.go
index b5a01ec96a..d865f6f4a8 100644
--- a/proto/generated-go/store/issue.pb.go
+++ b/proto/generated-go/store/issue.pb.go
@@ -7,6 +7,7 @@
package store
import (
+ expr "google.golang.org/genproto/googleapis/type/expr"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@@ -25,7 +26,8 @@ type IssuePayload struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
- Approval *IssuePayloadApproval `protobuf:"bytes,1,opt,name=approval,proto3" json:"approval,omitempty"`
+ Approval *IssuePayloadApproval `protobuf:"bytes,1,opt,name=approval,proto3" json:"approval,omitempty"`
+ GrantRequest *GrantRequest `protobuf:"bytes,2,opt,name=grant_request,json=grantRequest,proto3" json:"grant_request,omitempty"`
}
func (x *IssuePayload) Reset() {
@@ -67,20 +69,104 @@ func (x *IssuePayload) GetApproval() *IssuePayloadApproval {
return nil
}
+func (x *IssuePayload) GetGrantRequest() *GrantRequest {
+ if x != nil {
+ return x.GrantRequest
+ }
+ return nil
+}
+
+type GrantRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // The requested role, e.g. roles/EXPORTER.
+ Role string `protobuf:"bytes,1,opt,name=role,proto3" json:"role,omitempty"`
+ // The requested user, e.g. users/[email protected].
+ User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"`
+ Condition *expr.Expr `protobuf:"bytes,3,opt,name=condition,proto3" json:"condition,omitempty"`
+}
+
+func (x *GrantRequest) Reset() {
+ *x = GrantRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_store_issue_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *GrantRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*GrantRequest) ProtoMessage() {}
+
+func (x *GrantRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_store_issue_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 GrantRequest.ProtoReflect.Descriptor instead.
+func (*GrantRequest) Descriptor() ([]byte, []int) {
+ return file_store_issue_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *GrantRequest) GetRole() string {
+ if x != nil {
+ return x.Role
+ }
+ return ""
+}
+
+func (x *GrantRequest) GetUser() string {
+ if x != nil {
+ return x.User
+ }
+ return ""
+}
+
+func (x *GrantRequest) GetCondition() *expr.Expr {
+ if x != nil {
+ return x.Condition
+ }
+ return nil
+}
+
var File_store_issue_proto protoreflect.FileDescriptor
var file_store_issue_proto_rawDesc = []byte{
0x0a, 0x11, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x69, 0x73, 0x73, 0x75, 0x65, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74,
- 0x6f, 0x72, 0x65, 0x1a, 0x14, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x72, 0x6f,
- 0x76, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x50, 0x0a, 0x0c, 0x49, 0x73, 0x73,
- 0x75, 0x65, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x40, 0x0a, 0x08, 0x61, 0x70, 0x70,
- 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x62, 0x79,
- 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x73, 0x73,
- 0x75, 0x65, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61,
- 0x6c, 0x52, 0x08, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x42, 0x14, 0x5a, 0x12, 0x67,
- 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72,
- 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x6f, 0x72, 0x65, 0x1a, 0x16, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x74, 0x79, 0x70, 0x65,
+ 0x2f, 0x65, 0x78, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x73, 0x74, 0x6f,
+ 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74,
+ 0x6f, 0x22, 0x93, 0x01, 0x0a, 0x0c, 0x49, 0x73, 0x73, 0x75, 0x65, 0x50, 0x61, 0x79, 0x6c, 0x6f,
+ 0x61, 0x64, 0x12, 0x40, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x18, 0x01,
+ 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
+ 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x73, 0x73, 0x75, 0x65, 0x50, 0x61, 0x79, 0x6c, 0x6f,
+ 0x61, 0x64, 0x41, 0x70, 0x70, 0x72, 0x6f, 0x76, 0x61, 0x6c, 0x52, 0x08, 0x61, 0x70, 0x70, 0x72,
+ 0x6f, 0x76, 0x61, 0x6c, 0x12, 0x41, 0x0a, 0x0d, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x5f, 0x72, 0x65,
+ 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x62, 0x79,
+ 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x47, 0x72, 0x61,
+ 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0c, 0x67, 0x72, 0x61, 0x6e, 0x74,
+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x67, 0x0a, 0x0c, 0x47, 0x72, 0x61, 0x6e, 0x74,
+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x18,
+ 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x6f, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75,
+ 0x73, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12,
+ 0x2f, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01,
+ 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x74, 0x79, 0x70, 0x65,
+ 0x2e, 0x45, 0x78, 0x70, 0x72, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e,
+ 0x42, 0x14, 0x5a, 0x12, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f,
+ 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -95,18 +181,22 @@ func file_store_issue_proto_rawDescGZIP() []byte {
return file_store_issue_proto_rawDescData
}
-var file_store_issue_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
+var file_store_issue_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_store_issue_proto_goTypes = []interface{}{
(*IssuePayload)(nil), // 0: bytebase.store.IssuePayload
- (*IssuePayloadApproval)(nil), // 1: bytebase.store.IssuePayloadApproval
+ (*GrantRequest)(nil), // 1: bytebase.store.GrantRequest
+ (*IssuePayloadApproval)(nil), // 2: bytebase.store.IssuePayloadApproval
+ (*expr.Expr)(nil), // 3: google.type.Expr
}
var file_store_issue_proto_depIdxs = []int32{
- 1, // 0: bytebase.store.IssuePayload.approval:type_name -> bytebase.store.IssuePayloadApproval
- 1, // [1:1] is the sub-list for method output_type
- 1, // [1:1] is the sub-list for method input_type
- 1, // [1:1] is the sub-list for extension type_name
- 1, // [1:1] is the sub-list for extension extendee
- 0, // [0:1] is the sub-list for field type_name
+ 2, // 0: bytebase.store.IssuePayload.approval:type_name -> bytebase.store.IssuePayloadApproval
+ 1, // 1: bytebase.store.IssuePayload.grant_request:type_name -> bytebase.store.GrantRequest
+ 3, // 2: bytebase.store.GrantRequest.condition:type_name -> google.type.Expr
+ 3, // [3:3] is the sub-list for method output_type
+ 3, // [3:3] is the sub-list for method input_type
+ 3, // [3:3] is the sub-list for extension type_name
+ 3, // [3:3] is the sub-list for extension extendee
+ 0, // [0:3] is the sub-list for field type_name
}
func init() { file_store_issue_proto_init() }
@@ -128,6 +218,18 @@ func file_store_issue_proto_init() {
return nil
}
}
+ file_store_issue_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*GrantRequest); 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{
@@ -135,7 +237,7 @@ func file_store_issue_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_store_issue_proto_rawDesc,
NumEnums: 0,
- NumMessages: 1,
+ NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
diff --git a/proto/store/issue.proto b/proto/store/issue.proto
index 7724e064a1..c0cab16b33 100644
--- a/proto/store/issue.proto
+++ b/proto/store/issue.proto
@@ -2,10 +2,20 @@ syntax = "proto3";
package bytebase.store;
+import "google/type/expr.proto";
import "store/approval.proto";
option go_package = "generated-go/store";
message IssuePayload {
IssuePayloadApproval approval = 1;
+ GrantRequest grant_request = 2;
+}
+
+message GrantRequest {
+ // The requested role, e.g. roles/EXPORTER.
+ string role = 1;
+ // The requested user, e.g. users/[email protected].
+ string user = 2;
+ google.type.Expr condition = 3;
}