Skip to content

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

chore: method signature (#12915)

Danny Xu7a35e14f3a9b
diff --git a/backend/api/auth/auth.go b/backend/api/auth/auth.go
index 6ccae96308..55cf9cbea4 100644
--- a/backend/api/auth/auth.go
+++ b/backend/api/auth/auth.go
@@ -22,6 +22,8 @@ import (
"github.com/golang-jwt/jwt/v5"
errs "github.com/pkg/errors"
+ annotationsproto "google.golang.org/genproto/googleapis/api/annotations"
+
"github.com/bytebase/bytebase/backend/common"
"github.com/bytebase/bytebase/backend/component/config"
"github.com/bytebase/bytebase/backend/component/state"
@@ -331,30 +333,30 @@ func getAuthContext(fullMethod string) (*common.AuthContext, error) {
}
rd, err := protoregistry.GlobalFiles.FindDescriptorByName(protoreflect.FullName(methodTokens[1]))
if err != nil {
- return nil, errs.Wrapf(err, "invalid full method name %q", fullMethod)
+ return nil, errs.Wrapf(err, "invalid registry service descriptor, full method name %q", fullMethod)
}
sd, ok := rd.(protoreflect.ServiceDescriptor)
if !ok {
- return nil, errs.Errorf("invalid full method name %q", fullMethod)
+ return nil, errs.Errorf("invalid service descriptor, full method name %q", fullMethod)
}
md, ok := sd.Methods().ByName(protoreflect.Name(methodTokens[2])).Options().(*descriptorpb.MethodOptions)
if !ok {
- return nil, errs.Errorf("invalid full method name %q", fullMethod)
+ return nil, errs.Errorf("invalid method options, full method name %q", fullMethod)
}
allowWithoutCredentialAny := proto.GetExtension(md, v1pb.E_AllowWithoutCredential)
allowWithoutCredential, ok := allowWithoutCredentialAny.(bool)
if !ok {
- return nil, errs.Errorf("invalid full method name %q", fullMethod)
+ return nil, errs.Errorf("invalid allow without credential extension, full method name %q", fullMethod)
}
permissionAny := proto.GetExtension(md, v1pb.E_Permission)
permission, ok := permissionAny.(string)
if !ok {
- return nil, errs.Errorf("invalid full method name %q", fullMethod)
+ return nil, errs.Errorf("invalid permission extension, full method name %q", fullMethod)
}
authMethodAny := proto.GetExtension(md, v1pb.E_AuthMethod)
am, ok := authMethodAny.(v1pb.AuthMethod)
if !ok {
- return nil, errs.Errorf("invalid full method name %q", fullMethod)
+ return nil, errs.Errorf("invalid auth method extension, full method name %q", fullMethod)
}
var authMethod common.AuthMethod
switch am {
@@ -365,10 +367,16 @@ func getAuthContext(fullMethod string) (*common.AuthContext, error) {
case v1pb.AuthMethod_CUSTOM:
authMethod = common.AuthMethodCustom
}
+ signatureAny := proto.GetExtension(md, annotationsproto.E_MethodSignature)
+ signature, ok := signatureAny.([]string)
+ if !ok {
+ return nil, errs.Errorf("invalid signature extension, full method name %q", fullMethod)
+ }
return &common.AuthContext{
AllowWithoutCredential: allowWithoutCredential,
Permission: permission,
AuthMethod: authMethod,
+ Signature: signature,
}, nil
}
diff --git a/backend/api/v1/acl.go b/backend/api/v1/acl.go
index da802f2f17..5c1768bfd6 100644
--- a/backend/api/v1/acl.go
+++ b/backend/api/v1/acl.go
@@ -2,17 +2,22 @@ package v1
import (
"context"
+ "log/slog"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/fieldmaskpb"
+ "github.com/pkg/errors"
+
"github.com/bytebase/bytebase/backend/api/auth"
"github.com/bytebase/bytebase/backend/common"
+ "github.com/bytebase/bytebase/backend/common/log"
"github.com/bytebase/bytebase/backend/component/config"
"github.com/bytebase/bytebase/backend/component/iam"
"github.com/bytebase/bytebase/backend/store"
+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
// ACLInterceptor is the v1 ACL interceptor for gRPC server.
@@ -151,3 +156,213 @@ func hasPath(fieldMask *fieldmaskpb.FieldMask, want string) bool {
}
return false
}
+
+func (in *ACLInterceptor) checkIAMPermission(ctx context.Context, fullMethod string, req any, user *store.UserMessage, authContext *common.AuthContext) (err error) {
+ defer func() {
+ if r := recover(); r != nil {
+ perr, ok := r.(error)
+ if !ok {
+ perr = errors.Errorf("%v", r)
+ }
+ err = errors.Errorf("iam check PANIC RECOVER, method: %v, err: %v", fullMethod, perr)
+
+ slog.Error("iam check PANIC RECOVER", log.BBError(perr), log.BBStack("panic-stack"))
+ }
+ }()
+ ok, extra, err := in.doIAMPermissionCheck(ctx, fullMethod, req, user, authContext)
+ if err != nil {
+ return status.Errorf(codes.Internal, "failed to check permission for method %q, extra %v, err: %v", fullMethod, extra, err)
+ }
+ if !ok {
+ return status.Errorf(codes.PermissionDenied, "permission denied for method %q, user does not have permission %q, extra %v", fullMethod, authContext.Permission, extra)
+ }
+
+ return nil
+}
+
+func isSkippedMethod(fullMethod string, authContext *common.AuthContext) bool {
+ if auth.IsAuthenticationAllowed(fullMethod, authContext) {
+ return true
+ }
+
+ // Below are the skipped.
+ switch fullMethod {
+ // skip methods that are not considered to be resource-related.
+ case
+ v1pb.ActuatorService_GetResourcePackage_FullMethodName,
+ v1pb.ActuatorService_GetActuatorInfo_FullMethodName,
+ v1pb.ActuatorService_UpdateActuatorInfo_FullMethodName,
+ v1pb.ActuatorService_DeleteCache_FullMethodName,
+ v1pb.ActuatorService_ListDebugLog_FullMethodName,
+ v1pb.AnomalyService_SearchAnomalies_FullMethodName,
+ v1pb.AuthService_GetUser_FullMethodName,
+ v1pb.AuthService_ListUsers_FullMethodName,
+ v1pb.AuthService_CreateUser_FullMethodName,
+ v1pb.AuthService_UpdateUser_FullMethodName,
+ v1pb.AuthService_DeleteUser_FullMethodName,
+ v1pb.AuthService_UndeleteUser_FullMethodName,
+ v1pb.AuthService_Login_FullMethodName,
+ v1pb.AuthService_Logout_FullMethodName,
+ v1pb.CelService_BatchParse_FullMethodName,
+ v1pb.CelService_BatchDeparse_FullMethodName,
+ v1pb.SQLService_Query_FullMethodName,
+ // TODO(steven): maybe needs to add a permission to check.
+ v1pb.SQLService_Execute_FullMethodName,
+ v1pb.SQLService_SearchQueryHistories_FullMethodName,
+ v1pb.SQLService_Export_FullMethodName,
+ v1pb.SQLService_DifferPreview_FullMethodName,
+ v1pb.SQLService_Check_FullMethodName,
+ v1pb.SQLService_ParseMyBatisMapper_FullMethodName,
+ v1pb.SQLService_Pretty_FullMethodName,
+ v1pb.SQLService_StringifyMetadata_FullMethodName,
+ v1pb.SQLService_GenerateRestoreSQL_FullMethodName,
+ v1pb.SubscriptionService_GetSubscription_FullMethodName,
+ v1pb.SubscriptionService_GetFeatureMatrix_FullMethodName,
+ v1pb.SubscriptionService_UpdateSubscription_FullMethodName,
+ // TODO(p0ny): permission for review config service.
+ v1pb.ReviewConfigService_CreateReviewConfig_FullMethodName,
+ v1pb.ReviewConfigService_ListReviewConfigs_FullMethodName,
+ v1pb.ReviewConfigService_GetReviewConfig_FullMethodName,
+ v1pb.ReviewConfigService_UpdateReviewConfig_FullMethodName,
+ v1pb.ReviewConfigService_DeleteReviewConfig_FullMethodName:
+ return true
+ // skip checking for sheet service because we want to
+ // discriminate bytebase artifact sheets and user sheets first.
+ // TODO(p0ny): implement
+ case
+ v1pb.SheetService_CreateSheet_FullMethodName,
+ v1pb.SheetService_GetSheet_FullMethodName,
+ v1pb.SheetService_UpdateSheet_FullMethodName:
+ return true
+ // skip checking for sheet service because we want to
+ // discriminate bytebase artifact sheets and user sheets first.
+ // TODO(p0ny): implement
+ case
+ v1pb.WorksheetService_CreateWorksheet_FullMethodName,
+ v1pb.WorksheetService_GetWorksheet_FullMethodName,
+ v1pb.WorksheetService_SearchWorksheets_FullMethodName,
+ v1pb.WorksheetService_UpdateWorksheet_FullMethodName,
+ v1pb.WorksheetService_UpdateWorksheetOrganizer_FullMethodName,
+ v1pb.WorksheetService_DeleteWorksheet_FullMethodName:
+ return true
+ // handled in the method because we need to consider branch.Creator.
+ case
+ v1pb.BranchService_UpdateBranch_FullMethodName,
+ v1pb.BranchService_DeleteBranch_FullMethodName,
+ v1pb.BranchService_MergeBranch_FullMethodName,
+ v1pb.BranchService_RebaseBranch_FullMethodName:
+ return true
+ // handled in the method because we need to consider changelist.Creator.
+ case
+ v1pb.ChangelistService_UpdateChangelist_FullMethodName,
+ v1pb.ChangelistService_DeleteChangelist_FullMethodName:
+ return true
+ // handled in the method because we need to consider plan.Creator.
+ case
+ v1pb.PlanService_UpdatePlan_FullMethodName,
+ // TODO: maybe needs to add permission checks.
+ v1pb.PlanService_BatchCancelPlanCheckRuns_FullMethodName:
+ return true
+ // handled in the method because we need to consider issue.Creator and issue type.
+ // additional bb.plans.action and bb.rollouts.action permissions are required if the issue type is change database.
+ case
+ v1pb.IssueService_GetIssue_FullMethodName,
+ v1pb.IssueService_ListIssueComments_FullMethodName,
+ v1pb.IssueService_CreateIssue_FullMethodName,
+ v1pb.IssueService_CreateIssueComment_FullMethodName,
+ v1pb.IssueService_UpdateIssue_FullMethodName,
+ v1pb.IssueService_BatchUpdateIssuesStatus_FullMethodName,
+ v1pb.IssueService_UpdateIssueComment_FullMethodName:
+ return true
+ // skip checking for custom approval.
+ case
+ v1pb.IssueService_ApproveIssue_FullMethodName,
+ v1pb.IssueService_RejectIssue_FullMethodName,
+ v1pb.IssueService_RequestIssue_FullMethodName:
+ return true
+ // skip checking for the rollout-related.
+ // these are determined by the rollout policy.
+ case
+ v1pb.RolloutService_BatchCancelTaskRuns_FullMethodName,
+ v1pb.RolloutService_BatchSkipTasks_FullMethodName,
+ v1pb.RolloutService_BatchRunTasks_FullMethodName:
+ return true
+ // handled in the method because checking is complex.
+ case
+ v1pb.AuditLogService_SearchAuditLogs_FullMethodName,
+ v1pb.AuditLogService_ExportAuditLogs_FullMethodName,
+ v1pb.InstanceService_SearchInstances_FullMethodName,
+ v1pb.DatabaseService_ListSlowQueries_FullMethodName,
+ v1pb.DatabaseService_ListDatabases_FullMethodName,
+ v1pb.DatabaseService_SearchDatabases_FullMethodName,
+ v1pb.IssueService_ListIssues_FullMethodName,
+ v1pb.IssueService_SearchIssues_FullMethodName,
+
+ v1pb.ProjectService_SearchProjects_FullMethodName,
+ v1pb.PlanService_ListPlans_FullMethodName,
+ v1pb.PlanService_SearchPlans_FullMethodName,
+ v1pb.UserGroupService_DeleteUserGroup_FullMethodName,
+ v1pb.UserGroupService_UpdateUserGroup_FullMethodName:
+ return true
+ }
+ return false
+}
+
+func (in *ACLInterceptor) doIAMPermissionCheck(ctx context.Context, fullMethod string, req any, user *store.UserMessage, authContext *common.AuthContext) (bool, []string, error) {
+ if isSkippedMethod(fullMethod, authContext) {
+ return true, nil, nil
+ }
+
+ p := authContext.Permission
+ switch fullMethod {
+ // special cases for bb.instance.get permission check.
+ // we permit users to get instances (and all the related info) if they can get any database in the instance, even if they don't have bb.instance.get permission.
+ case
+ v1pb.InstanceService_GetInstance_FullMethodName,
+ v1pb.InstanceRoleService_GetInstanceRole_FullMethodName,
+ v1pb.InstanceRoleService_ListInstanceRoles_FullMethodName:
+ var instanceID string
+ var err error
+ switch r := req.(type) {
+ case *v1pb.GetInstanceRequest:
+ instanceID, err = common.GetInstanceID(r.GetName())
+ case *v1pb.GetInstanceRoleRequest:
+ instanceID, _, err = common.GetInstanceRoleID(r.GetName())
+ case *v1pb.ListInstanceRolesRequest:
+ instanceID, err = common.GetInstanceID(r.GetParent())
+ }
+ if err != nil {
+ return false, []string{instanceID}, err
+ }
+ ok, err := in.checkIAMPermissionInstancesGet(ctx, user, instanceID)
+ return ok, []string{instanceID}, err
+ }
+
+ projectIDs, ok := common.GetProjectIDsFromContext(ctx)
+ if !ok {
+ return false, projectIDs, errors.Errorf("failed to get project ids")
+ }
+ ok, err := in.iamManager.CheckPermission(ctx, p, user, projectIDs...)
+ return ok, projectIDs, err
+}
+
+func (in *ACLInterceptor) checkIAMPermissionInstancesGet(ctx context.Context, user *store.UserMessage, instanceID string) (bool, error) {
+ // fast path for Admins and DBAs.
+ ok, err := in.iamManager.CheckPermission(ctx, iam.PermissionInstancesGet, user)
+ if err != nil {
+ return false, err
+ }
+ if ok {
+ return true, nil
+ }
+
+ databaseFind := &store.FindDatabaseMessage{
+ InstanceID: &instanceID,
+ ShowDeleted: true,
+ }
+ databases, err := searchDatabases(ctx, in.store, in.iamManager, databaseFind)
+ if err != nil {
+ return false, errors.Wrapf(err, "failed to search databases")
+ }
+ return len(databases) > 0, nil
+}
diff --git a/backend/api/v1/acl_iam.go b/backend/api/v1/acl_iam.go
deleted file mode 100644
index ea61517944..0000000000
--- a/backend/api/v1/acl_iam.go
+++ /dev/null
@@ -1,228 +0,0 @@
-package v1
-
-import (
- "context"
- "log/slog"
-
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
-
- "github.com/pkg/errors"
-
- "github.com/bytebase/bytebase/backend/api/auth"
- "github.com/bytebase/bytebase/backend/common"
- "github.com/bytebase/bytebase/backend/common/log"
- "github.com/bytebase/bytebase/backend/component/iam"
- "github.com/bytebase/bytebase/backend/store"
- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
-)
-
-func (in *ACLInterceptor) checkIAMPermission(ctx context.Context, fullMethod string, req any, user *store.UserMessage, authContext *common.AuthContext) (err error) {
- defer func() {
- if r := recover(); r != nil {
- perr, ok := r.(error)
- if !ok {
- perr = errors.Errorf("%v", r)
- }
- err = errors.Errorf("iam check PANIC RECOVER, method: %v, err: %v", fullMethod, perr)
-
- slog.Error("iam check PANIC RECOVER", log.BBError(perr), log.BBStack("panic-stack"))
- }
- }()
- ok, extra, err := in.doIAMPermissionCheck(ctx, fullMethod, req, user, authContext)
- if err != nil {
- return status.Errorf(codes.Internal, "failed to check permission for method %q, extra %v, err: %v", fullMethod, extra, err)
- }
- if !ok {
- return status.Errorf(codes.PermissionDenied, "permission denied for method %q, user does not have permission %q, extra %v", fullMethod, authContext.Permission, extra)
- }
-
- return nil
-}
-
-func isSkippedMethod(fullMethod string, authContext *common.AuthContext) bool {
- if auth.IsAuthenticationAllowed(fullMethod, authContext) {
- return true
- }
-
- // Below are the skipped.
- switch fullMethod {
- // skip methods that are not considered to be resource-related.
- case
- v1pb.ActuatorService_GetResourcePackage_FullMethodName,
- v1pb.ActuatorService_GetActuatorInfo_FullMethodName,
- v1pb.ActuatorService_UpdateActuatorInfo_FullMethodName,
- v1pb.ActuatorService_DeleteCache_FullMethodName,
- v1pb.ActuatorService_ListDebugLog_FullMethodName,
- v1pb.AnomalyService_SearchAnomalies_FullMethodName,
- v1pb.AuthService_GetUser_FullMethodName,
- v1pb.AuthService_ListUsers_FullMethodName,
- v1pb.AuthService_CreateUser_FullMethodName,
- v1pb.AuthService_UpdateUser_FullMethodName,
- v1pb.AuthService_DeleteUser_FullMethodName,
- v1pb.AuthService_UndeleteUser_FullMethodName,
- v1pb.AuthService_Login_FullMethodName,
- v1pb.AuthService_Logout_FullMethodName,
- v1pb.CelService_BatchParse_FullMethodName,
- v1pb.CelService_BatchDeparse_FullMethodName,
- v1pb.SQLService_Query_FullMethodName,
- // TODO(steven): maybe needs to add a permission to check.
- v1pb.SQLService_Execute_FullMethodName,
- v1pb.SQLService_SearchQueryHistories_FullMethodName,
- v1pb.SQLService_Export_FullMethodName,
- v1pb.SQLService_DifferPreview_FullMethodName,
- v1pb.SQLService_Check_FullMethodName,
- v1pb.SQLService_ParseMyBatisMapper_FullMethodName,
- v1pb.SQLService_Pretty_FullMethodName,
- v1pb.SQLService_StringifyMetadata_FullMethodName,
- v1pb.SQLService_GenerateRestoreSQL_FullMethodName,
- v1pb.SubscriptionService_GetSubscription_FullMethodName,
- v1pb.SubscriptionService_GetFeatureMatrix_FullMethodName,
- v1pb.SubscriptionService_UpdateSubscription_FullMethodName,
- // TODO(p0ny): permission for review config service.
- v1pb.ReviewConfigService_CreateReviewConfig_FullMethodName,
- v1pb.ReviewConfigService_ListReviewConfigs_FullMethodName,
- v1pb.ReviewConfigService_GetReviewConfig_FullMethodName,
- v1pb.ReviewConfigService_UpdateReviewConfig_FullMethodName,
- v1pb.ReviewConfigService_DeleteReviewConfig_FullMethodName:
- return true
- // skip checking for sheet service because we want to
- // discriminate bytebase artifact sheets and user sheets first.
- // TODO(p0ny): implement
- case
- v1pb.SheetService_CreateSheet_FullMethodName,
- v1pb.SheetService_GetSheet_FullMethodName,
- v1pb.SheetService_UpdateSheet_FullMethodName:
- return true
- // skip checking for sheet service because we want to
- // discriminate bytebase artifact sheets and user sheets first.
- // TODO(p0ny): implement
- case
- v1pb.WorksheetService_CreateWorksheet_FullMethodName,
- v1pb.WorksheetService_GetWorksheet_FullMethodName,
- v1pb.WorksheetService_SearchWorksheets_FullMethodName,
- v1pb.WorksheetService_UpdateWorksheet_FullMethodName,
- v1pb.WorksheetService_UpdateWorksheetOrganizer_FullMethodName,
- v1pb.WorksheetService_DeleteWorksheet_FullMethodName:
- return true
- // handled in the method because we need to consider branch.Creator.
- case
- v1pb.BranchService_UpdateBranch_FullMethodName,
- v1pb.BranchService_DeleteBranch_FullMethodName,
- v1pb.BranchService_MergeBranch_FullMethodName,
- v1pb.BranchService_RebaseBranch_FullMethodName:
- return true
- // handled in the method because we need to consider changelist.Creator.
- case
- v1pb.ChangelistService_UpdateChangelist_FullMethodName,
- v1pb.ChangelistService_DeleteChangelist_FullMethodName:
- return true
- // handled in the method because we need to consider plan.Creator.
- case
- v1pb.PlanService_UpdatePlan_FullMethodName,
- // TODO: maybe needs to add permission checks.
- v1pb.PlanService_BatchCancelPlanCheckRuns_FullMethodName:
- return true
- // handled in the method because we need to consider issue.Creator and issue type.
- // additional bb.plans.action and bb.rollouts.action permissions are required if the issue type is change database.
- case
- v1pb.IssueService_GetIssue_FullMethodName,
- v1pb.IssueService_ListIssueComments_FullMethodName,
- v1pb.IssueService_CreateIssue_FullMethodName,
- v1pb.IssueService_CreateIssueComment_FullMethodName,
- v1pb.IssueService_UpdateIssue_FullMethodName,
- v1pb.IssueService_BatchUpdateIssuesStatus_FullMethodName,
- v1pb.IssueService_UpdateIssueComment_FullMethodName:
- return true
- // skip checking for custom approval.
- case
- v1pb.IssueService_ApproveIssue_FullMethodName,
- v1pb.IssueService_RejectIssue_FullMethodName,
- v1pb.IssueService_RequestIssue_FullMethodName:
- return true
- // skip checking for the rollout-related.
- // these are determined by the rollout policy.
- case
- v1pb.RolloutService_BatchCancelTaskRuns_FullMethodName,
- v1pb.RolloutService_BatchSkipTasks_FullMethodName,
- v1pb.RolloutService_BatchRunTasks_FullMethodName:
- return true
- // handled in the method because checking is complex.
- case
- v1pb.AuditLogService_SearchAuditLogs_FullMethodName,
- v1pb.AuditLogService_ExportAuditLogs_FullMethodName,
- v1pb.InstanceService_SearchInstances_FullMethodName,
- v1pb.DatabaseService_ListSlowQueries_FullMethodName,
- v1pb.DatabaseService_ListDatabases_FullMethodName,
- v1pb.DatabaseService_SearchDatabases_FullMethodName,
- v1pb.IssueService_ListIssues_FullMethodName,
- v1pb.IssueService_SearchIssues_FullMethodName,
-
- v1pb.ProjectService_SearchProjects_FullMethodName,
- v1pb.PlanService_ListPlans_FullMethodName,
- v1pb.PlanService_SearchPlans_FullMethodName,
- v1pb.UserGroupService_DeleteUserGroup_FullMethodName,
- v1pb.UserGroupService_UpdateUserGroup_FullMethodName:
- return true
- }
- return false
-}
-
-func (in *ACLInterceptor) doIAMPermissionCheck(ctx context.Context, fullMethod string, req any, user *store.UserMessage, authContext *common.AuthContext) (bool, []string, error) {
- if isSkippedMethod(fullMethod, authContext) {
- return true, nil, nil
- }
-
- p := authContext.Permission
- switch fullMethod {
- // special cases for bb.instance.get permission check.
- // we permit users to get instances (and all the related info) if they can get any database in the instance, even if they don't have bb.instance.get permission.
- case
- v1pb.InstanceService_GetInstance_FullMethodName,
- v1pb.InstanceRoleService_GetInstanceRole_FullMethodName,
- v1pb.InstanceRoleService_ListInstanceRoles_FullMethodName:
- var instanceID string
- var err error
- switch r := req.(type) {
- case *v1pb.GetInstanceRequest:
- instanceID, err = common.GetInstanceID(r.GetName())
- case *v1pb.GetInstanceRoleRequest:
- instanceID, _, err = common.GetInstanceRoleID(r.GetName())
- case *v1pb.ListInstanceRolesRequest:
- instanceID, err = common.GetInstanceID(r.GetParent())
- }
- if err != nil {
- return false, []string{instanceID}, err
- }
- ok, err := in.checkIAMPermissionInstancesGet(ctx, user, instanceID)
- return ok, []string{instanceID}, err
- }
-
- projectIDs, ok := common.GetProjectIDsFromContext(ctx)
- if !ok {
- return false, projectIDs, errors.Errorf("failed to get project ids")
- }
- ok, err := in.iamManager.CheckPermission(ctx, p, user, projectIDs...)
- return ok, projectIDs, err
-}
-
-func (in *ACLInterceptor) checkIAMPermissionInstancesGet(ctx context.Context, user *store.UserMessage, instanceID string) (bool, error) {
- // fast path for Admins and DBAs.
- ok, err := in.iamManager.CheckPermission(ctx, iam.PermissionInstancesGet, user)
- if err != nil {
- return false, err
- }
- if ok {
- return true, nil
- }
-
- databaseFind := &store.FindDatabaseMessage{
- InstanceID: &instanceID,
- ShowDeleted: true,
- }
- databases, err := searchDatabases(ctx, in.store, in.iamManager, databaseFind)
- if err != nil {
- return false, errors.Wrapf(err, "failed to search databases")
- }
- return len(databases) > 0, nil
-}
diff --git a/backend/common/context.go b/backend/common/context.go
index 8637fcc9cb..b83a00722f 100644
--- a/backend/common/context.go
+++ b/backend/common/context.go
@@ -39,4 +39,5 @@ type AuthContext struct {
AllowWithoutCredential bool
Permission string
AuthMethod AuthMethod
+ Signature []string
}