mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:17:32 +00:00
feat: set up org (#1157)
* add setup steps * refactoring * omitempty * cleanup * begin org * create org * setup org * setup org * merge * fixes * fixes * fixes
This commit is contained in:
@@ -15,6 +15,12 @@ type Password struct {
|
||||
ChangeRequired bool
|
||||
}
|
||||
|
||||
func NewPassword(password string) *Password {
|
||||
return &Password{
|
||||
SecretString: password,
|
||||
}
|
||||
}
|
||||
|
||||
type PasswordCode struct {
|
||||
es_models.ObjectRoot
|
||||
|
||||
|
@@ -11,7 +11,7 @@ type IAM struct {
|
||||
IAMProjectID string
|
||||
SetUpDone Step
|
||||
SetUpStarted Step
|
||||
Members []*IAMMember
|
||||
Members []*Member
|
||||
IDPs []*IDPConfig
|
||||
DefaultLoginPolicy *LoginPolicy
|
||||
DefaultLabelPolicy *LabelPolicy
|
||||
|
@@ -4,14 +4,24 @@ import (
|
||||
es_models "github.com/caos/zitadel/internal/eventstore/models"
|
||||
)
|
||||
|
||||
type IAMMember struct {
|
||||
type Member struct {
|
||||
es_models.ObjectRoot
|
||||
|
||||
UserID string
|
||||
Roles []string
|
||||
}
|
||||
|
||||
func (i *IAMMember) IsValid() bool {
|
||||
func NewMember(aggregateID, userID string, roles ...string) *Member {
|
||||
return &Member{
|
||||
ObjectRoot: es_models.ObjectRoot{
|
||||
AggregateID: aggregateID,
|
||||
},
|
||||
UserID: userID,
|
||||
Roles: roles,
|
||||
}
|
||||
}
|
||||
|
||||
func (i *Member) IsValid() bool {
|
||||
return i.AggregateID != "" && i.UserID != "" && len(i.Roles) != 0
|
||||
}
|
||||
|
43
internal/v2/domain/org.go
Normal file
43
internal/v2/domain/org.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/models"
|
||||
)
|
||||
|
||||
type Org struct {
|
||||
models.ObjectRoot
|
||||
|
||||
State OrgState
|
||||
Name string
|
||||
|
||||
Domains []*OrgDomain
|
||||
Members []*Member
|
||||
OrgIamPolicy *OrgIAMPolicy
|
||||
LoginPolicy *LoginPolicy
|
||||
LabelPolicy *LabelPolicy
|
||||
PasswordComplexityPolicy *PasswordComplexityPolicy
|
||||
PasswordAgePolicy *PasswordAgePolicy
|
||||
PasswordLockoutPolicy *PasswordLockoutPolicy
|
||||
IDPs []*IDPConfig
|
||||
}
|
||||
|
||||
func (o *Org) IsValid() bool {
|
||||
return o.Name != ""
|
||||
}
|
||||
|
||||
func (o *Org) AddIAMDomain(iamDomain string) {
|
||||
o.Domains = append(o.Domains, &OrgDomain{Domain: o.nameForDomain(iamDomain), Verified: true, Primary: true})
|
||||
}
|
||||
|
||||
func (o *Org) nameForDomain(iamDomain string) string {
|
||||
return strings.ToLower(strings.ReplaceAll(o.Name, " ", "-") + "." + iamDomain)
|
||||
}
|
||||
|
||||
type OrgState int32
|
||||
|
||||
const (
|
||||
OrgStateActive OrgState = iota
|
||||
OrgStateInactive
|
||||
)
|
38
internal/v2/domain/org_domain.go
Normal file
38
internal/v2/domain/org_domain.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"github.com/caos/zitadel/internal/eventstore/models"
|
||||
)
|
||||
|
||||
type OrgDomain struct {
|
||||
models.ObjectRoot
|
||||
|
||||
Domain string
|
||||
Primary bool
|
||||
Verified bool
|
||||
ValidationType OrgDomainValidationType
|
||||
ValidationCode *crypto.CryptoValue
|
||||
}
|
||||
|
||||
type OrgDomainValidationType int32
|
||||
|
||||
const (
|
||||
OrgDomainValidationTypeUnspecified OrgDomainValidationType = iota
|
||||
OrgDomainValidationTypeHTTP
|
||||
OrgDomainValidationTypeDNS
|
||||
)
|
||||
|
||||
type OrgDomainState int32
|
||||
|
||||
const (
|
||||
OrgDomainStateUnspecified OrgDomainState = iota
|
||||
OrgDomainStateActive
|
||||
OrgDomainStateRemoved
|
||||
|
||||
orgDomainStateCount
|
||||
)
|
||||
|
||||
func (f OrgDomainState) Valid() bool {
|
||||
return f >= 0 && f < orgDomainStateCount
|
||||
}
|
5
internal/v2/domain/roles.go
Normal file
5
internal/v2/domain/roles.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package domain
|
||||
|
||||
const (
|
||||
OrgOwnerRole = "ORG_OWNER"
|
||||
)
|
Reference in New Issue
Block a user