mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
56b916a2b0
* begin init checks for projections * first projection checks * debug notification providers with query fixes * more projections and first index * more projections * more projections * finish projections * fix tests (remove db name) * create tables in setup * fix logging / error handling * add tenant to views * rename tenant to instance_id * add instance_id to all projections * add instance_id to all queries * correct instance_id on projections * add instance_id to failed_events * use separate context for instance * implement features projection * implement features projection * remove unique constraint from setup when migration failed * add error to failed setup event * add instance_id to primary keys * fix IAM projection * remove old migrations folder * fix keysFromYAML test
61 lines
1.4 KiB
Go
61 lines
1.4 KiB
Go
package query
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/caos/zitadel/internal/api/authz"
|
|
"github.com/caos/zitadel/internal/domain"
|
|
)
|
|
|
|
func (q *Queries) GetIAMMemberRoles() []string {
|
|
roles := make([]string, 0)
|
|
for _, roleMap := range q.zitadelRoles {
|
|
if strings.HasPrefix(roleMap.Role, "IAM") {
|
|
roles = append(roles, roleMap.Role)
|
|
}
|
|
}
|
|
return roles
|
|
}
|
|
|
|
func (q *Queries) GetOrgMemberRoles(isGlobal bool) []string {
|
|
roles := make([]string, 0)
|
|
for _, roleMap := range q.zitadelRoles {
|
|
if strings.HasPrefix(roleMap.Role, "ORG") {
|
|
roles = append(roles, roleMap.Role)
|
|
}
|
|
}
|
|
if isGlobal {
|
|
roles = append(roles, domain.RoleSelfManagementGlobal)
|
|
}
|
|
return roles
|
|
}
|
|
|
|
func (q *Queries) GetProjectMemberRoles(ctx context.Context) ([]string, error) {
|
|
iam, err := q.IAM(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
roles := make([]string, 0)
|
|
global := authz.GetCtxData(ctx).OrgID == iam.GlobalOrgID
|
|
for _, roleMap := range q.zitadelRoles {
|
|
if strings.HasPrefix(roleMap.Role, "PROJECT") && !strings.HasPrefix(roleMap.Role, "PROJECT_GRANT") {
|
|
if global && !strings.HasSuffix(roleMap.Role, "GLOBAL") {
|
|
continue
|
|
}
|
|
roles = append(roles, roleMap.Role)
|
|
}
|
|
}
|
|
return roles, nil
|
|
}
|
|
|
|
func (q *Queries) GetProjectGrantMemberRoles() []string {
|
|
roles := make([]string, 0)
|
|
for _, roleMap := range q.zitadelRoles {
|
|
if strings.HasPrefix(roleMap.Role, "PROJECT_GRANT") {
|
|
roles = append(roles, roleMap.Role)
|
|
}
|
|
}
|
|
return roles
|
|
}
|