Skip to content

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

feat: iam for risks (#9818)

p0nyea7cece0d04f
diff --git a/backend/api/v1/acl_config.go b/backend/api/v1/acl_config.go
index e47db8a273..31cb334cdd 100644
--- a/backend/api/v1/acl_config.go
+++ b/backend/api/v1/acl_config.go
@@ -125,6 +125,11 @@ var methodPermissionMap = map[string]iam.Permission{
v1pb.ProjectService_DeleteSchemaGroup_FullMethodName: iam.PermissionProjectsUpdate,
v1pb.ProjectService_GetProjectProtectionRules_FullMethodName: iam.PermissionProjectsGet,
v1pb.ProjectService_UpdateProjectProtectionRules_FullMethodName: iam.PermissionProjectsUpdate,
+
+ v1pb.RiskService_ListRisks_FullMethodName: iam.PermissionRisksList,
+ v1pb.RiskService_CreateRisk_FullMethodName: iam.PermissionRisksCreate,
+ v1pb.RiskService_UpdateRisk_FullMethodName: iam.PermissionRisksUpdate,
+ v1pb.RiskService_DeleteRisk_FullMethodName: iam.PermissionRisksDelete,
}
func isOwnerAndDBAMethod(methodName string) bool {
diff --git a/backend/api/v1/acl_iam.go b/backend/api/v1/acl_iam.go
index f3cae97b07..0e153e7a1b 100644
--- a/backend/api/v1/acl_iam.go
+++ b/backend/api/v1/acl_iam.go
@@ -37,9 +37,7 @@ func (in *ACLInterceptor) checkIAMPermission(ctx context.Context, fullMethod str
if !ok {
return nil
}
- projectIDsGetter := func(context.Context, any) ([]string, error) {
- return nil, nil
- }
+ var projectIDsGetter func(context.Context, any) ([]string, error)
switch fullMethod {
// below are "workspace-level" permissions.
@@ -67,7 +65,15 @@ func (in *ACLInterceptor) checkIAMPermission(ctx context.Context, fullMethod str
v1pb.EnvironmentService_UndeleteEnvironment_FullMethodName,
v1pb.EnvironmentService_GetEnvironment_FullMethodName,
v1pb.EnvironmentService_ListEnvironments_FullMethodName,
- v1pb.EnvironmentService_UpdateBackupSetting_FullMethodName:
+ v1pb.EnvironmentService_UpdateBackupSetting_FullMethodName,
+ v1pb.RiskService_ListRisks_FullMethodName,
+ v1pb.RiskService_CreateRisk_FullMethodName,
+ v1pb.RiskService_UpdateRisk_FullMethodName,
+ v1pb.RiskService_DeleteRisk_FullMethodName:
+
+ projectIDsGetter = func(context.Context, any) ([]string, error) {
+ return nil, nil
+ }
case
v1pb.DatabaseService_GetDatabase_FullMethodName,
v1pb.DatabaseService_UpdateDatabase_FullMethodName,
diff --git a/backend/component/iam/acl.yaml b/backend/component/iam/acl.yaml
index 36cdf3509f..430d15c16f 100644
--- a/backend/component/iam/acl.yaml
+++ b/backend/component/iam/acl.yaml
@@ -45,6 +45,10 @@ roles:
- bb.projects.undelete
- bb.projects.getIamPolicy
- bb.projects.setIamPolicy
+ - bb.risks.list
+ - bb.risks.create
+ - bb.risks.update
+ - bb.risks.delete
- name: roles/workspaceDBA
permissions:
- bb.instances.list
@@ -91,6 +95,10 @@ roles:
- bb.projects.undelete
- bb.projects.getIamPolicy
- bb.projects.setIamPolicy
+ - bb.risks.list
+ - bb.risks.create
+ - bb.risks.update
+ - bb.risks.delete
- name: roles/workspaceMember
permissions:
- bb.environments.list
diff --git a/backend/component/iam/permission.go b/backend/component/iam/permission.go
index e6db9df19e..d856bbd4e9 100644
--- a/backend/component/iam/permission.go
+++ b/backend/component/iam/permission.go
@@ -52,4 +52,9 @@ const (
PermissionProjectsUndelete Permission = "bb.projects.undelete"
PermissionProjectsGetIAMPolicy Permission = "bb.projects.getIamPolicy"
PermissionProjectsSetIAMPolicy Permission = "bb.projects.setIamPolicy"
+
+ PermissionRisksList Permission = "bb.risks.list"
+ PermissionRisksCreate Permission = "bb.risks.create"
+ PermissionRisksUpdate Permission = "bb.risks.update"
+ PermissionRisksDelete Permission = "bb.risks.delete"
)
diff --git a/backend/component/iam/permission_test.go b/backend/component/iam/permission_test.go
index caf20075ac..1898c4cb5c 100644
--- a/backend/component/iam/permission_test.go
+++ b/backend/component/iam/permission_test.go
@@ -68,7 +68,11 @@ func permissionExist(p Permission) bool {
PermissionProjectsDelete,
PermissionProjectsUndelete,
PermissionProjectsGetIAMPolicy,
- PermissionProjectsSetIAMPolicy:
+ PermissionProjectsSetIAMPolicy,
+ PermissionRisksList,
+ PermissionRisksCreate,
+ PermissionRisksUpdate,
+ PermissionRisksDelete:
return true
default:
return false