mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 12:27:59 +00:00
fa9f581d56
* chore: move to new org * logging * fix: org rename caos -> zitadel Co-authored-by: adlerhurst <silvan.reusser@gmail.com>
40 lines
1.0 KiB
Go
40 lines
1.0 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"
|
|
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
|
|
}
|