resource

package
v0.0.0-...-04b2c92 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const ArnSplit = authz.ArnSplit
View Source
const SplitPolicyEffect = "&&"

Variables

This section is empty.

Functions

func DiffArrays

func DiffArrays[T int | int64 | string | float32 | float64](a []T, b []T) ([]T, []T)

DiffArrays 查找两数组新增及删除的元素: a:新数组 b:旧数组

func GeneralMFASecret

func GeneralMFASecret() string

GeneralMFASecret gen a secret for google authenticator

func MaskEmail

func MaskEmail(email string) string

MaskEmail 邮箱脱敏处理

func RandomStr

func RandomStr(n int) string

RandomStr generate random string,exclude 0,i,l

func RemoveDuplicateElement

func RemoveDuplicateElement[T int | int64 | string | float32 | float64](arr []T) []T

RemoveDuplicateElement 去重

func RemoveSliceElement

func RemoveSliceElement[T int | int64 | string | float32 | float64](a []T, el T) []T

RemoveSliceElement 移除数组指定元素

func SHA256

func SHA256(s string) string

func SaltSecret

func SaltSecret(ori, salt string) string

SaltSecret salt secret

func UpdateSliceElement

func UpdateSliceElement[T int | int64 | string | float32 | float64](a []T, newEl T, oldEl T) []T

UpdateSliceElement 更新数组指定元素

Types

type Service

type Service struct {
	Client *ent.Client
	KOSDK  *api.SDK
}

Service 企业目录服务管理

func (*Service) AllotOrganizationUser

func (s *Service) AllotOrganizationUser(ctx context.Context, input ent.CreateOrgUserInput) error

AllotOrganizationUser 将用户加入组织目录

func (*Service) AssignAppRolePolicy

func (s *Service) AssignAppRolePolicy(ctx context.Context, appID int, roleID int, policyIDs []int) error

AssignAppRolePolicy 角色添加权限

func (*Service) AssignOrganizationApp

func (s *Service) AssignOrganizationApp(ctx context.Context, orgID int, appID int) error

AssignOrganizationApp 分配应用到根组织下. 如: 新账户创建时, 根账户分配已有应用给子账户(需要验证根用户是否该应用权限,可在外层验证).

func (*Service) AssignOrganizationAppPolicy

func (s *Service) AssignOrganizationAppPolicy(ctx context.Context, orgID int, appPolicyID int) error

func (*Service) AssignOrganizationAppRole

func (s *Service) AssignOrganizationAppRole(ctx context.Context, orgID int, appRoleID int) error

func (*Service) AssignRoleUser

func (s *Service) AssignRoleUser(ctx context.Context, input model.AssignRoleUserInput) error

AssignRoleUser is the resolver for the assignRoleUser field.

func (*Service) ChangePassword

func (s *Service) ChangePassword(ctx context.Context, oldPwd, newPwd string) error

func (*Service) CheckPermission

func (s *Service) CheckPermission(ctx context.Context, permission string) (bool, error)

func (*Service) CreateApp

func (s *Service) CreateApp(ctx context.Context, input ent.CreateAppInput) (*ent.App, error)

CreateApp 创建应用,默认创建的应用都为公开的,不需要审核

TODO 应用工作流

func (*Service) CreateAppActions

func (s *Service) CreateAppActions(ctx context.Context, appID int, input []*ent.CreateAppActionInput) ([]*ent.AppAction, error)

CreateAppActions 创建应用权限

func (*Service) CreateAppMenus

func (s *Service) CreateAppMenus(ctx context.Context, appID int, input []*ent.CreateAppMenuInput) ([]*ent.AppMenu, error)

CreateAppMenus 创建应用菜单,如果有route项,则相应创建action

func (*Service) CreateAppPolicy

func (s *Service) CreateAppPolicy(ctx context.Context, appID int, input ent.CreateAppPolicyInput) (*ent.AppPolicy, error)

CreateAppPolicy 创建应用策略.

该方法会检查应用策略的规则中的action是否以应用代码开头.

func (*Service) CreateOrganization

func (s *Service) CreateOrganization(ctx context.Context, input ent.CreateOrgInput) (*ent.Org, error)

CreateOrganization 创建组织目录,基于根目录创建

func (*Service) CreateOrganizationAccount

func (s *Service) CreateOrganizationAccount(ctx context.Context, orgId int, input ent.CreateUserInput) (*ent.User, error)

CreateOrganizationAccount 创建组织目录账户,进入账户激活流程

- 管理员账户才能创建下级组织目录的账户

func (*Service) CreateOrganizationPolicy

func (s *Service) CreateOrganizationPolicy(ctx context.Context, input ent.CreateOrgPolicyInput) (*ent.OrgPolicy, error)

CreateOrganizationPolicy 创建组织策略,该策略属于租户组织

func (*Service) CreateOrganizationUser

func (s *Service) CreateOrganizationUser(ctx context.Context, orgId int, input ent.CreateUserInput, ut user.UserType) (*ent.User, error)

CreateOrganizationUser 创建组织目录用户

TODO 新用户需要激活,如在国内,用户往往需要绑定手机或邮箱,然后通过邮件或短信激活.

func (*Service) CreateRole

func (s *Service) CreateRole(ctx context.Context, input ent.CreateOrgRoleInput) (*ent.OrgRole, error)

CreateRole 创建角色或工作组

func (*Service) CreateRoot

func (s *Service) CreateRoot(ctx context.Context, input ent.CreateOrgInput) (*ent.Org, error)

CreateRoot 创建组织root

func (*Service) CreateUserPassword

func (s *Service) CreateUserPassword(ctx context.Context, input *ent.CreateUserPasswordInput) (pw *ent.UserPassword, err error)

func (*Service) DeleteAppAction

func (s *Service) DeleteAppAction(ctx context.Context, actionID int) error

DeleteAppAction 删除action时,同步删除app_policy与org_policy引用的action

func (*Service) DeleteAppMenu

func (s *Service) DeleteAppMenu(ctx context.Context, menuID int) error

DeleteAppMenu 删除应用菜单,删除关联的action

func (*Service) DeleteAppPolicy

func (s *Service) DeleteAppPolicy(ctx context.Context, policyID int) error

DeleteAppPolicy 删除应用策略,该应用必须属于(创建者)该租户才可删除 当应用策略被删除时,原有引用该策略的都保持不变

func (*Service) DeleteAppRole

func (s *Service) DeleteAppRole(ctx context.Context, roleID int) error

func (*Service) DeleteOrganization

func (s *Service) DeleteOrganization(ctx context.Context, id int) error

DeleteOrganization 删除组织目录

func (*Service) DeleteOrganizationPolicy

func (s *Service) DeleteOrganizationPolicy(ctx context.Context, orgPolicyID int) error

func (*Service) DeleteOrganizationUser

func (s *Service) DeleteOrganizationUser(ctx context.Context, userID int) error

DeleteOrganizationUser 删除本域下的用户,在用户没有被引用时,允许删除

func (*Service) DeleteRole

func (s *Service) DeleteRole(ctx context.Context, roleID int) error

DeleteRole 删除角色或工作组

func (*Service) DisableMFA

func (s *Service) DisableMFA(ctx context.Context, userID int) error

func (*Service) EnableMFA

func (s *Service) EnableMFA(ctx context.Context, userID int) (*model.Mfa, error)

EnableMFA 启用用户的MFA验证

func (*Service) EnableOrganization

func (s *Service) EnableOrganization(ctx context.Context, input model.EnableDirectoryInput) (*ent.Org, error)

EnableOrganization 开启组织目录

func (*Service) GetOrgDomain

func (s *Service) GetOrgDomain(ctx context.Context, orgID int) (string, error)

GetOrgDomain 获取组织域名.orgID为根组织.

func (*Service) GetRoleUserIds

func (s *Service) GetRoleUserIds(ctx context.Context, roleID int) ([]int, error)

GetRoleUserIds 获取组织用户组/角色用户ids

func (*Service) GetRootOrgByUser

func (s *Service) GetRootOrgByUser(ctx context.Context, uid int) (*ent.Org, error)

GetRootOrgByUser 获取用户的最顶级的根组织.在组织中,一个账户可能存在多个根组织.需要从context获取租户ID

func (*Service) GetUserApps

func (s *Service) GetUserApps(ctx context.Context) ([]*ent.App, error)

func (*Service) GetUserMenus

func (s *Service) GetUserMenus(ctx context.Context, appCode string) ([]*ent.AppMenu, error)

func (*Service) GetUserPermissions

func (s *Service) GetUserPermissions(ctx context.Context, where *ent.AppActionWhereInput) ([]*ent.AppAction, error)

GetUserPermissions 获取用户的全部权限

func (*Service) GetUserPermissionsByUserID

func (s *Service) GetUserPermissionsByUserID(ctx context.Context, userID int, where *ent.AppActionWhereInput) ([]*ent.AppAction, error)

func (*Service) Grant

Grant 给用户或角色授权.

此时先保证permission数据保存,如果cashbin操作失败,返回状态失败,再需要通过权限管理界面再次激活..

func (*Service) IsAllowRevokeAppPolicy

func (s *Service) IsAllowRevokeAppPolicy(ctx context.Context, orgID int, appPolicyID int) (bool, error)

IsAllowRevokeAppPolicy 应用策略是否允许解除授权组织 如果授权组织的应用角色包含该策略,则该策略不允许单独解除授权

func (*Service) IsAllowRevokeOrgRole

func (s *Service) IsAllowRevokeOrgRole(ctx context.Context, userID int, orgRoleID int) (bool, error)

func (*Service) IsAllowRevokePermission

func (s *Service) IsAllowRevokePermission(ctx context.Context, p *ent.Permission) (bool, error)

func (*Service) IsRootOrg

func (s *Service) IsRootOrg(ctx context.Context, orgID int) (bool, error)

IsRootOrg 判断组织是否root

func (*Service) MoveAppDictItem

func (s *Service) MoveAppDictItem(ctx context.Context, sourceID int, targetID int, action model.TreeAction) error

func (*Service) MoveAppMenu

func (s *Service) MoveAppMenu(ctx context.Context, src int, tar int, action model.TreeAction) (err error)

MoveAppMenu 移动菜单

func (*Service) MoveOrganization

func (s *Service) MoveOrganization(ctx context.Context, src, tar int, action model.TreeAction) (err error)

MoveOrganization 移动组织目录.

func (*Service) RecoverOrgUser

func (s *Service) RecoverOrgUser(ctx context.Context, userID int, userInput ent.UpdateUserInput, pwdKind userloginprofile.SetKind, pwdInput *ent.CreateUserPasswordInput) (*ent.User, error)

RecoverOrgUser 恢复删除用户

func (*Service) RemoveOrganizationUser

func (s *Service) RemoveOrganizationUser(ctx context.Context, orgID int, userID int) error

RemoveOrganizationUser 将用户从组织目录中移除.

func (*Service) ResetUserPasswordByEmail

func (s *Service) ResetUserPasswordByEmail(ctx context.Context, userID int) error

func (*Service) Revoke

func (s *Service) Revoke(ctx context.Context, orgID int, permissionID int) error

Revoke 撤销用户或角色的权限.

func (*Service) RevokeAppRolePolicy

func (s *Service) RevokeAppRolePolicy(ctx context.Context, appID int, roleID int, policyIDs []int) error

func (*Service) RevokeOrganizationApp

func (s *Service) RevokeOrganizationApp(ctx context.Context, orgID int, appID int) error

RevokeOrganizationApp 移除组织下的应用,同时物理删除授权信息与收回授权.

func (*Service) RevokeOrganizationAppPolicy

func (s *Service) RevokeOrganizationAppPolicy(ctx context.Context, orgID int, appPolicyID int) error

func (*Service) RevokeOrganizationAppRole

func (s *Service) RevokeOrganizationAppRole(ctx context.Context, orgID int, appRoleID int) error

func (*Service) RevokeRoleUser

func (s *Service) RevokeRoleUser(ctx context.Context, roleID int, userID int) error

RevokeRoleUser is the resolver for the revokeRoleUser field.

func (*Service) SaveOrgUserPreference

func (s *Service) SaveOrgUserPreference(ctx context.Context, input model.OrgUserPreferenceInput) (*ent.OrgUserPreference, error)

func (*Service) SendMFAToUserByEmail

func (s *Service) SendMFAToUserByEmail(ctx context.Context, userID int) error

func (*Service) UpdateApp

func (s *Service) UpdateApp(ctx context.Context, appID int, input ent.UpdateAppInput) (*ent.App, error)

UpdateApp 更新应用

func (*Service) UpdateAppAction

func (s *Service) UpdateAppAction(ctx context.Context, actionID int, input ent.UpdateAppActionInput) (*ent.AppAction, error)

UpdateAppAction 更新action时,同步更新app_policy与org_policy引用的action

func (*Service) UpdateAppMenu

func (s *Service) UpdateAppMenu(ctx context.Context, menuID int, input ent.UpdateAppMenuInput) (*ent.AppMenu, error)

UpdateAppMenu 更新应用菜单,如果更新了route,则更新action

func (*Service) UpdateAppPolicy

func (s *Service) UpdateAppPolicy(ctx context.Context, policyID int, input ent.UpdateAppPolicyInput) (*ent.AppPolicy, error)

UpdateAppPolicy 更新应用策略,该应用必须属于(创建者)该租户才可更新 当应用策略更新时,会被当前最新的策略模板,原有引用该策略的都更新

func (*Service) UpdateAppRole

func (s *Service) UpdateAppRole(ctx context.Context, roleID int, input ent.UpdateAppRoleInput) (*ent.AppRole, error)

func (*Service) UpdateLoginProfile

func (s *Service) UpdateLoginProfile(ctx context.Context, userID int, input ent.UpdateUserLoginProfileInput) (*ent.UserLoginProfile, error)

func (*Service) UpdateOrganizationPolicy

func (s *Service) UpdateOrganizationPolicy(ctx context.Context, id int, input ent.UpdateOrgPolicyInput) (*ent.OrgPolicy, error)

func (*Service) UpdatePermission

func (s *Service) UpdatePermission(ctx context.Context, permissionID int, input ent.UpdatePermissionInput) (*ent.Permission, error)

UpdatePermission 更新权限的

func (*Service) UpdateRole

func (s *Service) UpdateRole(ctx context.Context, roleID int, input ent.UpdateOrgRoleInput) (*ent.OrgRole, error)

UpdateRole 更新角色或工作组

func (*Service) UpdateUser

func (s *Service) UpdateUser(ctx context.Context, userID int, input ent.UpdateUserInput) (*ent.User, error)

UpdateUser 更新用户信息,允许更新用户的email,phone,但这些信息需要通过验证被引入UserIdentity中才能生效.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL