chore: Update rego to be partial execution friendly (#3449)

- Improves performance of batch authorization calls
- Enables possibility to convert rego auth calls into SQL WHERE clauses
This commit is contained in:
Steven Masley
2022-08-11 17:07:48 -05:00
committed by GitHub
parent 4a17e0d91f
commit 3ae42f4de9
16 changed files with 1131 additions and 825 deletions

View File

@ -222,6 +222,18 @@ func RoleByName(name string) (Role, error) {
return role, nil
}
func RolesByNames(roleNames []string) ([]Role, error) {
roles := make([]Role, 0, len(roleNames))
for _, n := range roleNames {
r, err := RoleByName(n)
if err != nil {
return nil, xerrors.Errorf("get role permissions: %w", err)
}
roles = append(roles, r)
}
return roles, nil
}
func IsOrgRole(roleName string) (string, bool) {
_, orgID, err := roleSplit(roleName)
if err == nil && orgID != "" {