mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 14:47:33 +00:00

# Which Problems Are Solved Permission checks in project v2beta API did not cover projects and granted projects correctly. # How the Problems Are Solved Add permission checks v1 correctly to the list queries, add correct permission checks v2 for projects. # Additional Changes Correct Pre-Checks for project grants that the right resource owner is used. # Additional Context Permission checks v2 for project grants is still outstanding under #9972.
41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package domain
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
)
|
|
|
|
const (
|
|
IAMRolePrefix = "IAM"
|
|
OrgRolePrefix = "ORG"
|
|
ProjectRolePrefix = "PROJECT"
|
|
ProjectGrantRolePrefix = "PROJECT_GRANT"
|
|
RoleOrgOwner = "ORG_OWNER"
|
|
RoleOrgProjectCreator = "ORG_PROJECT_CREATOR"
|
|
RoleIAMOwner = "IAM_OWNER"
|
|
RoleProjectOwner = "PROJECT_OWNER"
|
|
RoleProjectOwnerGlobal = "PROJECT_OWNER_GLOBAL"
|
|
RoleProjectGrantOwner = "PROJECT_GRANT_OWNER"
|
|
RoleSelfManagementGlobal = "SELF_MANAGEMENT_GLOBAL"
|
|
)
|
|
|
|
func CheckForInvalidRoles(roles []string, rolePrefix string, validRoles []authz.RoleMapping) []string {
|
|
invalidRoles := make([]string, 0)
|
|
for _, role := range roles {
|
|
if !containsRole(role, rolePrefix, validRoles) {
|
|
invalidRoles = append(invalidRoles, role)
|
|
}
|
|
}
|
|
return invalidRoles
|
|
}
|
|
|
|
func containsRole(role, rolePrefix string, validRoles []authz.RoleMapping) bool {
|
|
for _, validRole := range validRoles {
|
|
if role == validRole.Role && strings.HasPrefix(role, rolePrefix) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|