Documentation ¶
Index ¶
- Constants
- func DiffArrays[T int | int64 | string | float32 | float64](a []T, b []T) ([]T, []T)
- func GeneralMFASecret() string
- func MaskEmail(email string) string
- func RandomStr(n int) string
- func RemoveDuplicateElement[T int | int64 | string | float32 | float64](arr []T) []T
- func RemoveSliceElement[T int | int64 | string | float32 | float64](a []T, el T) []T
- func SHA256(s string) string
- func SaltSecret(ori, salt string) string
- func UpdateSliceElement[T int | int64 | string | float32 | float64](a []T, newEl T, oldEl T) []T
- type Service
- func (s *Service) AllotOrganizationUser(ctx context.Context, input ent.CreateOrgUserInput) error
- func (s *Service) AssignAppRolePolicy(ctx context.Context, appID int, roleID int, policyIDs []int) error
- func (s *Service) AssignOrganizationApp(ctx context.Context, orgID int, appID int) error
- func (s *Service) AssignOrganizationAppPolicy(ctx context.Context, orgID int, appPolicyID int) error
- func (s *Service) AssignOrganizationAppRole(ctx context.Context, orgID int, appRoleID int) error
- func (s *Service) AssignRoleUser(ctx context.Context, input model.AssignRoleUserInput) error
- func (s *Service) ChangePassword(ctx context.Context, oldPwd, newPwd string) error
- func (s *Service) CheckPermission(ctx context.Context, permission string) (bool, error)
- func (s *Service) CreateApp(ctx context.Context, input ent.CreateAppInput) (*ent.App, error)
- func (s *Service) CreateAppActions(ctx context.Context, appID int, input []*ent.CreateAppActionInput) ([]*ent.AppAction, error)
- func (s *Service) CreateAppMenus(ctx context.Context, appID int, input []*ent.CreateAppMenuInput) ([]*ent.AppMenu, error)
- func (s *Service) CreateAppPolicy(ctx context.Context, appID int, input ent.CreateAppPolicyInput) (*ent.AppPolicy, error)
- func (s *Service) CreateOrganization(ctx context.Context, input ent.CreateOrgInput) (*ent.Org, error)
- func (s *Service) CreateOrganizationAccount(ctx context.Context, orgId int, input ent.CreateUserInput) (*ent.User, error)
- func (s *Service) CreateOrganizationPolicy(ctx context.Context, input ent.CreateOrgPolicyInput) (*ent.OrgPolicy, error)
- func (s *Service) CreateOrganizationUser(ctx context.Context, orgId int, input ent.CreateUserInput, ut user.UserType) (*ent.User, error)
- func (s *Service) CreateRole(ctx context.Context, input ent.CreateOrgRoleInput) (*ent.OrgRole, error)
- func (s *Service) CreateRoot(ctx context.Context, input ent.CreateOrgInput) (*ent.Org, error)
- func (s *Service) CreateUserPassword(ctx context.Context, input *ent.CreateUserPasswordInput) (pw *ent.UserPassword, err error)
- func (s *Service) DeleteAppAction(ctx context.Context, actionID int) error
- func (s *Service) DeleteAppMenu(ctx context.Context, menuID int) error
- func (s *Service) DeleteAppPolicy(ctx context.Context, policyID int) error
- func (s *Service) DeleteAppRole(ctx context.Context, roleID int) error
- func (s *Service) DeleteOrganization(ctx context.Context, id int) error
- func (s *Service) DeleteOrganizationPolicy(ctx context.Context, orgPolicyID int) error
- func (s *Service) DeleteOrganizationUser(ctx context.Context, userID int) error
- func (s *Service) DeleteRole(ctx context.Context, roleID int) error
- func (s *Service) DisableMFA(ctx context.Context, userID int) error
- func (s *Service) EnableMFA(ctx context.Context, userID int) (*model.Mfa, error)
- func (s *Service) EnableOrganization(ctx context.Context, input model.EnableDirectoryInput) (*ent.Org, error)
- func (s *Service) GetOrgDomain(ctx context.Context, orgID int) (string, error)
- func (s *Service) GetRoleUserIds(ctx context.Context, roleID int) ([]int, error)
- func (s *Service) GetRootOrgByUser(ctx context.Context, uid int) (*ent.Org, error)
- func (s *Service) GetUserApps(ctx context.Context) ([]*ent.App, error)
- func (s *Service) GetUserMenus(ctx context.Context, appCode string) ([]*ent.AppMenu, error)
- func (s *Service) GetUserPermissions(ctx context.Context, where *ent.AppActionWhereInput) ([]*ent.AppAction, error)
- func (s *Service) GetUserPermissionsByUserID(ctx context.Context, userID int, where *ent.AppActionWhereInput) ([]*ent.AppAction, error)
- func (s *Service) Grant(ctx context.Context, input ent.CreatePermissionInput) (*ent.Permission, error)
- func (s *Service) IsAllowRevokeAppPolicy(ctx context.Context, orgID int, appPolicyID int) (bool, error)
- func (s *Service) IsAllowRevokeOrgRole(ctx context.Context, userID int, orgRoleID int) (bool, error)
- func (s *Service) IsAllowRevokePermission(ctx context.Context, p *ent.Permission) (bool, error)
- func (s *Service) IsRootOrg(ctx context.Context, orgID int) (bool, error)
- func (s *Service) MoveAppDictItem(ctx context.Context, sourceID int, targetID int, action model.TreeAction) error
- func (s *Service) MoveAppMenu(ctx context.Context, src int, tar int, action model.TreeAction) (err error)
- func (s *Service) MoveOrganization(ctx context.Context, src, tar int, action model.TreeAction) (err error)
- func (s *Service) RecoverOrgUser(ctx context.Context, userID int, userInput ent.UpdateUserInput, ...) (*ent.User, error)
- func (s *Service) RemoveOrganizationUser(ctx context.Context, orgID int, userID int) error
- func (s *Service) ResetUserPasswordByEmail(ctx context.Context, userID int) error
- func (s *Service) Revoke(ctx context.Context, orgID int, permissionID int) error
- func (s *Service) RevokeAppRolePolicy(ctx context.Context, appID int, roleID int, policyIDs []int) error
- func (s *Service) RevokeOrganizationApp(ctx context.Context, orgID int, appID int) error
- func (s *Service) RevokeOrganizationAppPolicy(ctx context.Context, orgID int, appPolicyID int) error
- func (s *Service) RevokeOrganizationAppRole(ctx context.Context, orgID int, appRoleID int) error
- func (s *Service) RevokeRoleUser(ctx context.Context, roleID int, userID int) error
- func (s *Service) SaveOrgUserPreference(ctx context.Context, input model.OrgUserPreferenceInput) (*ent.OrgUserPreference, error)
- func (s *Service) SendMFAToUserByEmail(ctx context.Context, userID int) error
- func (s *Service) UpdateApp(ctx context.Context, appID int, input ent.UpdateAppInput) (*ent.App, error)
- func (s *Service) UpdateAppAction(ctx context.Context, actionID int, input ent.UpdateAppActionInput) (*ent.AppAction, error)
- func (s *Service) UpdateAppMenu(ctx context.Context, menuID int, input ent.UpdateAppMenuInput) (*ent.AppMenu, error)
- func (s *Service) UpdateAppPolicy(ctx context.Context, policyID int, input ent.UpdateAppPolicyInput) (*ent.AppPolicy, error)
- func (s *Service) UpdateAppRole(ctx context.Context, roleID int, input ent.UpdateAppRoleInput) (*ent.AppRole, error)
- func (s *Service) UpdateLoginProfile(ctx context.Context, userID int, input ent.UpdateUserLoginProfileInput) (*ent.UserLoginProfile, error)
- func (s *Service) UpdateOrganizationPolicy(ctx context.Context, id int, input ent.UpdateOrgPolicyInput) (*ent.OrgPolicy, error)
- func (s *Service) UpdatePermission(ctx context.Context, permissionID int, input ent.UpdatePermissionInput) (*ent.Permission, error)
- func (s *Service) UpdateRole(ctx context.Context, roleID int, input ent.UpdateOrgRoleInput) (*ent.OrgRole, error)
- func (s *Service) UpdateUser(ctx context.Context, userID int, input ent.UpdateUserInput) (*ent.User, error)
Constants ¶
const ArnSplit = authz.ArnSplit
const SplitPolicyEffect = "&&"
Variables ¶
This section is empty.
Functions ¶
func DiffArrays ¶
DiffArrays 查找两数组新增及删除的元素: a:新数组 b:旧数组
func GeneralMFASecret ¶
func GeneralMFASecret() string
GeneralMFASecret gen a secret for google authenticator
func RemoveDuplicateElement ¶
RemoveDuplicateElement 去重
func RemoveSliceElement ¶
RemoveSliceElement 移除数组指定元素
Types ¶
type Service ¶
Service 企业目录服务管理
func (*Service) AllotOrganizationUser ¶
AllotOrganizationUser 将用户加入组织目录
func (*Service) AssignAppRolePolicy ¶
func (s *Service) AssignAppRolePolicy(ctx context.Context, appID int, roleID int, policyIDs []int) error
AssignAppRolePolicy 角色添加权限
func (*Service) AssignOrganizationApp ¶
AssignOrganizationApp 分配应用到根组织下. 如: 新账户创建时, 根账户分配已有应用给子账户(需要验证根用户是否该应用权限,可在外层验证).
func (*Service) AssignOrganizationAppPolicy ¶
func (*Service) AssignOrganizationAppRole ¶
func (*Service) AssignRoleUser ¶
AssignRoleUser is the resolver for the assignRoleUser field.
func (*Service) ChangePassword ¶
func (*Service) CheckPermission ¶
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 ¶
CreateRoot 创建组织root
func (*Service) CreateUserPassword ¶
func (s *Service) CreateUserPassword(ctx context.Context, input *ent.CreateUserPasswordInput) (pw *ent.UserPassword, err error)
func (*Service) DeleteAppAction ¶
DeleteAppAction 删除action时,同步删除app_policy与org_policy引用的action
func (*Service) DeleteAppMenu ¶
DeleteAppMenu 删除应用菜单,删除关联的action
func (*Service) DeleteAppPolicy ¶
DeleteAppPolicy 删除应用策略,该应用必须属于(创建者)该租户才可删除 当应用策略被删除时,原有引用该策略的都保持不变
func (*Service) DeleteAppRole ¶
func (*Service) DeleteOrganization ¶
DeleteOrganization 删除组织目录
func (*Service) DeleteOrganizationPolicy ¶
func (*Service) DeleteOrganizationUser ¶
DeleteOrganizationUser 删除本域下的用户,在用户没有被引用时,允许删除
func (*Service) DeleteRole ¶
DeleteRole 删除角色或工作组
func (*Service) EnableOrganization ¶
func (s *Service) EnableOrganization(ctx context.Context, input model.EnableDirectoryInput) (*ent.Org, error)
EnableOrganization 开启组织目录
func (*Service) GetOrgDomain ¶
GetOrgDomain 获取组织域名.orgID为根组织.
func (*Service) GetRoleUserIds ¶
GetRoleUserIds 获取组织用户组/角色用户ids
func (*Service) GetRootOrgByUser ¶
GetRootOrgByUser 获取用户的最顶级的根组织.在组织中,一个账户可能存在多个根组织.需要从context获取租户ID
func (*Service) GetUserApps ¶
func (*Service) GetUserMenus ¶
func (*Service) GetUserPermissions ¶
func (s *Service) GetUserPermissions(ctx context.Context, where *ent.AppActionWhereInput) ([]*ent.AppAction, error)
GetUserPermissions 获取用户的全部权限
func (*Service) GetUserPermissionsByUserID ¶
func (*Service) Grant ¶
func (s *Service) Grant(ctx context.Context, input ent.CreatePermissionInput) (*ent.Permission, error)
Grant 给用户或角色授权.
此时先保证permission数据保存,如果cashbin操作失败,返回状态失败,再需要通过权限管理界面再次激活..
func (*Service) IsAllowRevokeAppPolicy ¶
func (s *Service) IsAllowRevokeAppPolicy(ctx context.Context, orgID int, appPolicyID int) (bool, error)
IsAllowRevokeAppPolicy 应用策略是否允许解除授权组织 如果授权组织的应用角色包含该策略,则该策略不允许单独解除授权
func (*Service) IsAllowRevokeOrgRole ¶
func (*Service) IsAllowRevokePermission ¶
func (*Service) MoveAppDictItem ¶
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 ¶
RemoveOrganizationUser 将用户从组织目录中移除.
func (*Service) ResetUserPasswordByEmail ¶
func (*Service) RevokeAppRolePolicy ¶
func (*Service) RevokeOrganizationApp ¶
RevokeOrganizationApp 移除组织下的应用,同时物理删除授权信息与收回授权.
func (*Service) RevokeOrganizationAppPolicy ¶
func (*Service) RevokeOrganizationAppRole ¶
func (*Service) RevokeRoleUser ¶
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 (*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 (*Service) UpdateLoginProfile ¶
func (s *Service) UpdateLoginProfile(ctx context.Context, userID int, input ent.UpdateUserLoginProfileInput) (*ent.UserLoginProfile, error)
func (*Service) UpdateOrganizationPolicy ¶
func (*Service) UpdatePermission ¶
func (s *Service) UpdatePermission(ctx context.Context, permissionID int, input ent.UpdatePermissionInput) (*ent.Permission, error)
UpdatePermission 更新权限的