mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-11 22:53:40 +00:00
3eb909c4b4
* add setup steps * refactoring * omitempty * cleanup * begin org * create org * setup org * setup org * merge * fixes * fixes * fixes * add project * add oidc application * fix app creation * add resourceOwner to writemodels * resource owner * cleanup * global org, iam project and iam member in setup * logs * logs * logs * cleanup * Update internal/v2/command/project.go Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com> * check project state * add org domain commands * add org status changes and member commands * fixes * policies * login policy * fix iam project event * mapper * label policy * change to command * fix * fix * handle change event differently and lot of fixes * fixes * changedEvent handling Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com>
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package domain
|
|
|
|
import (
|
|
http_util "github.com/caos/zitadel/internal/api/http"
|
|
"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
|
|
}
|
|
|
|
func (domain *OrgDomain) IsValid() bool {
|
|
return domain.AggregateID != "" && domain.Domain != ""
|
|
}
|
|
|
|
func (domain *OrgDomain) GenerateVerificationCode(codeGenerator crypto.Generator) (string, error) {
|
|
validationCodeCrypto, validationCode, err := crypto.NewCode(codeGenerator)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
domain.ValidationCode = validationCodeCrypto
|
|
return validationCode, nil
|
|
}
|
|
|
|
type OrgDomainValidationType int32
|
|
|
|
const (
|
|
OrgDomainValidationTypeUnspecified OrgDomainValidationType = iota
|
|
OrgDomainValidationTypeHTTP
|
|
OrgDomainValidationTypeDNS
|
|
)
|
|
|
|
func (t OrgDomainValidationType) CheckType() (http_util.CheckType, bool) {
|
|
switch t {
|
|
case OrgDomainValidationTypeHTTP:
|
|
return http_util.CheckTypeHTTP, true
|
|
case OrgDomainValidationTypeDNS:
|
|
return http_util.CheckTypeDNS, true
|
|
default:
|
|
return -1, false
|
|
}
|
|
}
|
|
|
|
type OrgDomainState int32
|
|
|
|
const (
|
|
OrgDomainStateUnspecified OrgDomainState = iota
|
|
OrgDomainStateActive
|
|
OrgDomainStateRemoved
|
|
|
|
orgDomainStateCount
|
|
)
|
|
|
|
func (f OrgDomainState) Valid() bool {
|
|
return f >= 0 && f < orgDomainStateCount
|
|
}
|