MCPcopy Create free account
hub / github.com/astercloud/aster / getParentRolePermissions

Method getParentRolePermissions

pkg/security/access_control.go:797–812  ·  view source on GitHub ↗

getParentRolePermissions 获取父角色权限

(role *Role)

Source from the content-addressed store, hash-verified

795
796// getParentRolePermissions 获取父角色权限
797func (ac *AccessController) getParentRolePermissions(role *Role) []string {
798 var permissions []string
799
800 for _, parentID := range role.Parents {
801 if parentRole, exists := ac.roles[parentID]; exists {
802 // 获取父角色的直接权限
803 permissions = append(permissions, parentRole.Permissions...)
804
805 // 递归获取祖先角色的权限
806 ancestorPermissions := ac.getParentRolePermissions(parentRole)
807 permissions = append(permissions, ancestorPermissions...)
808 }
809 }
810
811 return permissions
812}
813
814// checkPermissionList 检查权限列表
815func (ac *AccessController) checkPermissionList(permissionIDs []string, resource, action string, context map[string]any) bool {

Callers 1

getUserPermissionsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected