mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
3f345b1ade
* fix: org tests * fix: org tests * fix: user grant test * fix: user grant test * fix: project and project role test * fix: project grant test * fix: project grant test * fix: project member, grant member, app changed tests * fix: application tests * fix: application tests * fix: add oidc app test * fix: add oidc app test * fix: add api keys test * fix: iam policies * fix: iam and org member tests * fix: idp config tests * fix: iam tests * fix: user tests * fix: user tests * fix: user tests * fix: user tests * fix: user tests * fix: user tests * fix: user tests * fix: user tests * fix: user tests * fix: user tests * fix: org domain test * fix: org tests * fix: org tests * fix: implement org idps * fix: pr requests * fix: email tests * fix: fix idp check * fix: fix user profile
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/v1/models"
|
|
)
|
|
|
|
type OrgDomain struct {
|
|
models.ObjectRoot
|
|
|
|
Domain string
|
|
Primary bool
|
|
Verified bool
|
|
ValidationType OrgDomainValidationType
|
|
ValidationCode *crypto.CryptoValue
|
|
}
|
|
|
|
func (domain *OrgDomain) IsValid() bool {
|
|
return 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
|
|
}
|