Skip to content

Commit 8ff68b1

Browse files
Merge pull request #3079 from actiontech/fix_audit_plan_permit
fix: save audit plan permission
2 parents 9dd221c + 8eecf17 commit 8ff68b1

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

sqle/api/controller/v1/audit_plan.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ func GetAuditPlans(c echo.Context) error {
666666
"offset": offset,
667667
}
668668
if !up.CanViewProject() {
669-
instanceNames, err := dms.GetInstanceNamesInProjectByIds(c.Request().Context(), projectUid, up.GetInstancesByOP(v1.OpPermissionTypeViewOtherAuditPlan))
669+
instanceNames, err := dms.GetInstanceNamesInProjectByIds(c.Request().Context(), projectUid, up.GetInstancesByOP(v1.OpPermissionTypeSaveAuditPlan))
670670
if err != nil {
671671
return err
672672
}
@@ -797,7 +797,7 @@ func GetAuditPlanReports(c echo.Context) error {
797797
}
798798
apName := c.Param("audit_plan_name")
799799

800-
_, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, v1.OpPermissionTypeViewOtherAuditPlan)
800+
_, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, v1.OpPermissionTypeSaveAuditPlan)
801801
if err != nil {
802802
return controller.JSONBaseErrorReq(c, err)
803803
}
@@ -857,7 +857,7 @@ func GetAuditPlanReport(c echo.Context) error {
857857
}
858858
apName := c.Param("audit_plan_name")
859859

860-
ap, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, v1.OpPermissionTypeViewOtherAuditPlan)
860+
ap, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, v1.OpPermissionTypeSaveAuditPlan)
861861
if err != nil {
862862
return controller.JSONBaseErrorReq(c, err)
863863
}
@@ -1225,7 +1225,7 @@ func GetAuditPlanNotifyConfig(c echo.Context) error {
12251225
}
12261226
apName := c.Param("audit_plan_name")
12271227

1228-
ap, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, v1.OpPermissionTypeViewOtherAuditPlan)
1228+
ap, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, v1.OpPermissionTypeSaveAuditPlan)
12291229
if err != nil {
12301230
return controller.JSONBaseErrorReq(c, err)
12311231
}
@@ -1401,7 +1401,7 @@ func GetAuditPlanSQLs(c echo.Context) error {
14011401
}
14021402
apName := c.Param("audit_plan_name")
14031403

1404-
ap, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, v1.OpPermissionTypeViewOtherAuditPlan)
1404+
ap, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, v1.OpPermissionTypeSaveAuditPlan)
14051405
if err != nil {
14061406
return controller.JSONBaseErrorReq(c, err)
14071407
}
@@ -1482,7 +1482,7 @@ func GetAuditPlanReportSQLsV1(c echo.Context) error {
14821482
}
14831483
apName := c.Param("audit_plan_name")
14841484

1485-
ap, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, v1.OpPermissionTypeViewOtherAuditPlan)
1485+
ap, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, v1.OpPermissionTypeSaveAuditPlan)
14861486
if err != nil {
14871487
return controller.JSONBaseErrorReq(c, err)
14881488
}

sqle/api/controller/v1/project_permission.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ func GetInstanceAuditPlanIfCurrentUserCanView(c echo.Context, projectId, instanc
329329
return ap, true, nil
330330
}
331331
}
332-
opTypes := []dmsV1.OpPermissionType{dmsV1.OpPermissionTypeViewOtherAuditPlan, dmsV1.OpPermissionTypeSaveAuditPlan}
332+
opTypes := []dmsV1.OpPermissionType{dmsV1.OpPermissionTypeSaveAuditPlan}
333333
for _, opType := range opTypes {
334334
dbServiceReq := &dmsV2.ListDBServiceReq{
335335
ProjectUid: projectId,
@@ -344,7 +344,7 @@ func GetInstanceAuditPlanIfCurrentUserCanView(c echo.Context, projectId, instanc
344344
}
345345
}
346346
}
347-
return ap, false, errors.NewUserNotPermissionError(dmsV1.GetOperationTypeDesc(dmsV1.OpPermissionTypeViewOtherAuditPlan))
347+
return ap, false, errors.NewUserNotPermissionError(dmsV1.GetOperationTypeDesc(dmsV1.OpPermissionTypeSaveAuditPlan))
348348
}
349349

350350
func GetInstanceAuditPlanIfCurrentUserCanOp(c echo.Context, projectId, instanceAuditPlanID string, opType dmsV1.OpPermissionType) (*model.InstanceAuditPlan, bool, error) {
@@ -399,7 +399,7 @@ func GetAuditPlantReportAndInstanceIfCurrentUserCanView(c echo.Context, projectI
399399
auditPlanReport *model.AuditPlanReportV2, auditPlanReportSQLV2 *model.AuditPlanReportSQLV2, instance *model.Instance,
400400
err error) {
401401

402-
ap, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectId, auditPlanName, dmsV1.OpPermissionTypeViewOtherAuditPlan)
402+
ap, exist, err := GetAuditPlanIfCurrentUserCanView(c, projectId, auditPlanName, dmsV1.OpPermissionTypeSaveAuditPlan)
403403
if err != nil {
404404
return nil, nil, nil, err
405405
}

sqle/api/controller/v2/audit_plan.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func GetAuditPlans(c echo.Context) error {
101101
"offset": offset,
102102
}
103103
if !up.IsAdmin() {
104-
instanceNames, err := dms.GetInstanceNamesInProjectByIds(c.Request().Context(), projectUid, up.GetInstancesByOP(dmsV1.OpPermissionTypeViewOtherAuditPlan))
104+
instanceNames, err := dms.GetInstanceNamesInProjectByIds(c.Request().Context(), projectUid, up.GetInstancesByOP(dmsV1.OpPermissionTypeSaveAuditPlan))
105105
if err != nil {
106106
return err
107107
}
@@ -195,7 +195,7 @@ func GetAuditPlanReportSQLs(c echo.Context) error {
195195
}
196196
apName := c.Param("audit_plan_name")
197197

198-
ap, exist, err := v1.GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, dmsV1.OpPermissionTypeViewOtherAuditPlan)
198+
ap, exist, err := v1.GetAuditPlanIfCurrentUserCanView(c, projectUid, apName, dmsV1.OpPermissionTypeSaveAuditPlan)
199199
if err != nil {
200200
return controller.JSONBaseErrorReq(c, err)
201201
}

sqle/api/controller/v2/instance_audit_plan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func GetInstanceAuditPlans(c echo.Context) error {
249249
}
250250
if !up.CanViewProject() {
251251
// 如果有配置SQL管控权限,那么可以查看自己创建的或者该权限对应数据源的
252-
accessibleInstanceId := up.GetInstancesByOP(dmsCommonV1.OpPermissionTypeViewOtherAuditPlan, dmsCommonV1.OpPermissionTypeSaveAuditPlan)
252+
accessibleInstanceId := up.GetInstancesByOP(dmsCommonV1.OpPermissionTypeSaveAuditPlan)
253253
if len(accessibleInstanceId) > 0 {
254254
data["accessible_instances_id"] = fmt.Sprintf("\"%s\"", strings.Join(accessibleInstanceId, "\",\""))
255255
}

0 commit comments

Comments
 (0)