Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/dms/service/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type User struct {
ThirdPartyUserID string `json:"third_party_user_id"`
ThirdPartyUserInfo string `json:"third_party_user_info"`
UserAuthenticationType string `json:"user_authentication_type"`
// Business write permission, only effective for system administrators
BusinessWritePermission *bool `json:"business_write_permission"`
}

// swagger:model
Expand Down Expand Up @@ -100,6 +102,8 @@ type UpdateUser struct {
UserAuthenticationType *string `json:"user_authentication_type"`
// User system
System *UserSystem `json:"system"`
// Business write permission for system administrators
BusinessWritePermission *bool `json:"business_write_permission"`
}

// swagger:model
Expand Down
27 changes: 26 additions & 1 deletion api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -11204,7 +11204,7 @@
"x-go-name": "Users"
}
},
"x-go-package": "github.com/actiontech/dms/api/dms/service/v1"
"x-go-package": "github.com/actiontech/dms/pkg/dms-common/api/dms/v1"
},
"GetMemberGroupReply": {
"type": "object",
Expand Down Expand Up @@ -11627,6 +11627,11 @@
"x-go-enum-desc": "ldap UserAuthenticationTypeLDAP\ndms UserAuthenticationTypeDMS\noauth2 UserAuthenticationTypeOAUTH2\nunknown UserAuthenticationTypeUnknown",
"x-go-name": "AuthenticationType"
},
"business_write_permission": {
"description": "business write permission",
"type": "boolean",
"x-go-name": "BusinessWritePermission"
},
"email": {
"description": "user email",
"type": "string",
Expand Down Expand Up @@ -11769,6 +11774,11 @@
"description": "user op permission reply\nis user admin, admin has all permissions",
"type": "object",
"properties": {
"business_write_permission": {
"description": "business write permission",
"type": "boolean",
"x-go-name": "BusinessWritePermission"
},
"is_admin": {
"type": "boolean",
"x-go-name": "IsAdmin"
Expand Down Expand Up @@ -14835,6 +14845,11 @@
"x-go-enum-desc": "ldap UserAuthenticationTypeLDAP\ndms UserAuthenticationTypeDMS\noauth2 UserAuthenticationTypeOAUTH2\nunknown UserAuthenticationTypeUnknown",
"x-go-name": "AuthenticationType"
},
"business_write_permission": {
"description": "business write permission",
"type": "boolean",
"x-go-name": "BusinessWritePermission"
},
"email": {
"description": "user email",
"type": "string",
Expand Down Expand Up @@ -18602,6 +18617,11 @@
"UpdateUser": {
"type": "object",
"properties": {
"business_write_permission": {
"description": "Business write permission for system administrators",
"type": "boolean",
"x-go-name": "BusinessWritePermission"
},
"email": {
"description": "User email",
"type": "string",
Expand Down Expand Up @@ -18772,6 +18792,11 @@
"name"
],
"properties": {
"business_write_permission": {
"description": "Business write permission, only effective for system administrators",
"type": "boolean",
"x-go-name": "BusinessWritePermission"
},
"desc": {
"description": "user description",
"type": "string",
Expand Down
22 changes: 21 additions & 1 deletion api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ definitions:
type: array
x-go-name: Users
type: object
x-go-package: github.com/actiontech/dms/api/dms/service/v1
x-go-package: github.com/actiontech/dms/pkg/dms-common/api/dms/v1
GetMemberGroupReply:
properties:
code:
Expand Down Expand Up @@ -2599,6 +2599,10 @@ definitions:
oauth2 UserAuthenticationTypeOAUTH2
unknown UserAuthenticationTypeUnknown
x-go-name: AuthenticationType
business_write_permission:
description: business write permission
type: boolean
x-go-name: BusinessWritePermission
email:
description: user email
type: string
Expand Down Expand Up @@ -2730,6 +2734,10 @@ definitions:
user op permission reply
is user admin, admin has all permissions
properties:
business_write_permission:
description: business write permission
type: boolean
x-go-name: BusinessWritePermission
is_admin:
type: boolean
x-go-name: IsAdmin
Expand Down Expand Up @@ -5242,6 +5250,10 @@ definitions:
oauth2 UserAuthenticationTypeOAUTH2
unknown UserAuthenticationTypeUnknown
x-go-name: AuthenticationType
business_write_permission:
description: business write permission
type: boolean
x-go-name: BusinessWritePermission
email:
description: user email
type: string
Expand Down Expand Up @@ -8332,6 +8344,10 @@ definitions:
x-go-package: github.com/actiontech/dms/pkg/dms-common/api/dms/v1
UpdateUser:
properties:
business_write_permission:
description: Business write permission for system administrators
type: boolean
x-go-name: BusinessWritePermission
email:
description: User email
type: string
Expand Down Expand Up @@ -8461,6 +8477,10 @@ definitions:
User:
description: A user
properties:
business_write_permission:
description: Business write permission, only effective for system administrators
type: boolean
x-go-name: BusinessWritePermission
desc:
description: user description
type: string
Expand Down
2 changes: 1 addition & 1 deletion internal/dms/biz/cloudbeaver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ func (cu *CloudbeaverUsecase) connectManagement(ctx context.Context, cloudbeaver
return cu.clearConnection(ctx)
}

hasGlobalOpPermission, err := cu.opPermissionVerifyUsecase.CanOpGlobal(ctx, dmsUser.UID)
hasGlobalOpPermission, err := cu.opPermissionVerifyUsecase.CanOpGlobal(ctx, dmsUser.UID, true)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/dms/biz/environment_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (uc *EnvironmentTagUsecase) CreateEnvironmentTag(ctx context.Context, proje
}

// 检查当前用户有项目管理员权限
if canOpProject, err := uc.opPermissionVerifyUsecase.CanOpProject(ctx, currentUserUid, projectUid); err != nil {
if canOpProject, err := uc.opPermissionVerifyUsecase.CanOpProject(ctx, currentUserUid, projectUid, false); err != nil {
return fmt.Errorf("check user is project admin or golobal op permission failed: %v", err)
} else if !canOpProject {
return fmt.Errorf("user is not project admin or golobal op permission user")
Expand Down Expand Up @@ -116,7 +116,7 @@ func (uc *EnvironmentTagUsecase) UpdateEnvironmentTag(ctx context.Context, proje
}

// 检查当前用户有项目管理员权限
if canOpProject, err := uc.opPermissionVerifyUsecase.CanOpProject(ctx, currentUserUid, projectUid); err != nil {
if canOpProject, err := uc.opPermissionVerifyUsecase.CanOpProject(ctx, currentUserUid, projectUid, false); err != nil {
return fmt.Errorf("check user is project admin or golobal op permission failed: %v", err)
} else if !canOpProject {
return fmt.Errorf("user is not project admin or golobal op permission user")
Expand Down Expand Up @@ -145,7 +145,7 @@ func (uc *EnvironmentTagUsecase) DeleteEnvironmentTag(ctx context.Context, proje
}

// 检查当前用户有项目管理员权限
if canOpProject, err := uc.opPermissionVerifyUsecase.CanOpProject(ctx, currentUserUid, projectUid); err != nil {
if canOpProject, err := uc.opPermissionVerifyUsecase.CanOpProject(ctx, currentUserUid, projectUid, false); err != nil {
return fmt.Errorf("check user is project admin or golobal op permission failed: %v", err)
} else if !canOpProject {
return fmt.Errorf("user is not project admin or golobal op permission user")
Expand Down
2 changes: 1 addition & 1 deletion internal/dms/biz/maintenance_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (m *MaintenanceTimeUsecase) CheckSQLExecutionAllowed(
}

// 4. 检查用户是否为管理员
isAdmin, err := m.opPermissionVerifyUsecase.CanOpGlobal(ctx, userUid)
isAdmin, err := m.opPermissionVerifyUsecase.CanOpGlobal(ctx, userUid, false)
if err != nil {
return false, "", fmt.Errorf("failed to check user admin permission: %v", err)
}
Expand Down
8 changes: 1 addition & 7 deletions internal/dms/biz/op_permission.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"

v1 "github.com/actiontech/dms/api/dms/service/v1"

pkgConst "github.com/actiontech/dms/internal/dms/pkg/constant"
Expand Down Expand Up @@ -92,13 +93,6 @@ func initOpPermission() []*OpPermission {
Desc: "具备系统最高权限,可进行系统配置、用户管理等操作",
Service: v1.ServiceSQLE,
},
{
UID: pkgConst.UIDOfOpPermissionCreateProject,
Name: "项目总监", // todo i18n 返回时会根据uid国际化,name、desc已弃用;数据库name字段是唯一键,故暂时保留
RangeType: OpRangeTypeGlobal,
Desc: "创建项目、配置项目资源",
Service: v1.ServiceSQLE,
},
{
UID: pkgConst.UIDOfOrdinaryUser,
Name: "普通用户", // todo i18n 返回时会根据uid国际化,name、desc已弃用;数据库name字段是唯一键,故暂时保留
Expand Down
Loading