feat: custom domain feature (#1618)

* fix: custom domain

* fix: custom domain

* fix: custom domain

* fix: custom domain feature in proto

* fix: remove custom domains on feature downgrade

* fix test

* fix: custom domain feature in proto

* ensure tests work

Co-authored-by: fabi <fabienne.gerschwiler@gmail.com>
This commit is contained in:
Livio Amstutz
2021-04-19 16:43:36 +02:00
committed by GitHub
parent 8da733315a
commit 6863aeac59
20 changed files with 692 additions and 70 deletions

View File

@@ -15,6 +15,7 @@ const (
FeatureLoginPolicyUsernameLogin = FeatureLoginPolicy + ".username_login"
FeaturePasswordComplexityPolicy = "password_complexity_policy"
FeatureLabelPolicy = "label_policy"
FeatureCustomDomain = "custom_domain"
)
type Features struct {
@@ -34,6 +35,7 @@ type Features struct {
LoginPolicyUsernameLogin bool
PasswordComplexityPolicy bool
LabelPolicy bool
CustomDomain bool
}
type FeaturesState int32

View File

@@ -1,8 +1,6 @@
package domain
import (
"strings"
"github.com/caos/zitadel/internal/eventstore/v1/models"
)
@@ -29,11 +27,7 @@ func (o *Org) IsValid() bool {
}
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)
o.Domains = append(o.Domains, &OrgDomain{Domain: NewIAMDomainName(o.Name, iamDomain), Verified: true, Primary: true})
}
type OrgState int32

View File

@@ -1,6 +1,8 @@
package domain
import (
"strings"
http_util "github.com/caos/zitadel/internal/api/http"
"github.com/caos/zitadel/internal/crypto"
"github.com/caos/zitadel/internal/eventstore/v1/models"
@@ -29,6 +31,10 @@ func (domain *OrgDomain) GenerateVerificationCode(codeGenerator crypto.Generator
return validationCode, nil
}
func NewIAMDomainName(orgName, iamDomain string) string {
return strings.ToLower(strings.ReplaceAll(orgName, " ", "-") + "." + iamDomain)
}
type OrgDomainValidationType int32
const (