2021-01-22 12:31:52 +00:00
|
|
|
package domain
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
import es_models "github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
2021-01-22 12:31:52 +00:00
|
|
|
|
|
|
|
type UserGrant struct {
|
|
|
|
es_models.ObjectRoot
|
|
|
|
|
|
|
|
State UserGrantState
|
|
|
|
UserID string
|
|
|
|
ProjectID string
|
|
|
|
ProjectGrantID string
|
|
|
|
RoleKeys []string
|
|
|
|
}
|
|
|
|
|
|
|
|
type UserGrantState int32
|
|
|
|
|
|
|
|
const (
|
|
|
|
UserGrantStateUnspecified UserGrantState = iota
|
|
|
|
UserGrantStateActive
|
|
|
|
UserGrantStateInactive
|
|
|
|
UserGrantStateRemoved
|
|
|
|
)
|
|
|
|
|
|
|
|
func (u *UserGrant) IsValid() bool {
|
|
|
|
return u.ProjectID != "" && u.UserID != ""
|
|
|
|
}
|
2021-03-15 11:51:15 +00:00
|
|
|
|
|
|
|
func (g *UserGrant) HasInvalidRoles(validRoles []string) bool {
|
|
|
|
for _, roleKey := range g.RoleKeys {
|
|
|
|
if !containsRoleKey(roleKey, validRoles) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|