2021-01-04 13:52:13 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/domain"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
|
|
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
2021-01-04 13:52:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func writeModelToObjectRoot(writeModel eventstore.WriteModel) models.ObjectRoot {
|
|
|
|
return models.ObjectRoot{
|
|
|
|
AggregateID: writeModel.AggregateID,
|
|
|
|
ChangeDate: writeModel.ChangeDate,
|
|
|
|
ResourceOwner: writeModel.ResourceOwner,
|
|
|
|
Sequence: writeModel.ProcessedSequence,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-06 09:47:55 +00:00
|
|
|
func writeModelToIAM(wm *IAMWriteModel) *domain.IAM {
|
|
|
|
return &domain.IAM{
|
2021-01-04 13:52:13 +00:00
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
|
|
|
SetUpStarted: wm.SetUpStarted,
|
|
|
|
SetUpDone: wm.SetUpDone,
|
|
|
|
GlobalOrgID: wm.GlobalOrgID,
|
|
|
|
IAMProjectID: wm.ProjectID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-08 10:33:45 +00:00
|
|
|
func memberWriteModelToMember(writeModel *MemberWriteModel) *domain.Member {
|
|
|
|
return &domain.Member{
|
|
|
|
ObjectRoot: writeModelToObjectRoot(writeModel.WriteModel),
|
2021-01-04 13:52:13 +00:00
|
|
|
Roles: writeModel.Roles,
|
|
|
|
UserID: writeModel.UserID,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-18 10:24:15 +00:00
|
|
|
func writeModelToLoginPolicy(wm *LoginPolicyWriteModel) *domain.LoginPolicy {
|
2021-01-05 08:33:45 +00:00
|
|
|
return &domain.LoginPolicy{
|
2021-01-18 10:24:15 +00:00
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
2021-01-04 13:52:13 +00:00
|
|
|
AllowUsernamePassword: wm.AllowUserNamePassword,
|
|
|
|
AllowRegister: wm.AllowRegister,
|
2021-02-08 10:30:30 +00:00
|
|
|
AllowExternalIDP: wm.AllowExternalIDP,
|
2021-01-04 13:52:13 +00:00
|
|
|
ForceMFA: wm.ForceMFA,
|
2021-01-05 08:33:45 +00:00
|
|
|
PasswordlessType: wm.PasswordlessType,
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-18 10:24:15 +00:00
|
|
|
func writeModelToLabelPolicy(wm *LabelPolicyWriteModel) *domain.LabelPolicy {
|
2021-01-05 08:33:45 +00:00
|
|
|
return &domain.LabelPolicy{
|
2021-01-18 10:24:15 +00:00
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
2021-01-04 13:52:13 +00:00
|
|
|
PrimaryColor: wm.PrimaryColor,
|
|
|
|
SecondaryColor: wm.SecondaryColor,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-10 09:48:40 +00:00
|
|
|
func writeModelToMailTemplate(wm *MailTemplateWriteModel) *domain.MailTemplate {
|
|
|
|
return &domain.MailTemplate{
|
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
|
|
|
Template: wm.Template,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func writeModelToMailText(wm *MailTextWriteModel) *domain.MailText {
|
|
|
|
return &domain.MailText{
|
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
|
|
|
MailTextType: wm.MailTextType,
|
|
|
|
Language: wm.Language,
|
|
|
|
Title: wm.Title,
|
|
|
|
PreHeader: wm.PreHeader,
|
|
|
|
Subject: wm.Subject,
|
|
|
|
Greeting: wm.Greeting,
|
|
|
|
Text: wm.Text,
|
|
|
|
ButtonText: wm.ButtonText,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 08:33:45 +00:00
|
|
|
func writeModelToOrgIAMPolicy(wm *IAMOrgIAMPolicyWriteModel) *domain.OrgIAMPolicy {
|
|
|
|
return &domain.OrgIAMPolicy{
|
2021-01-04 13:52:13 +00:00
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.PolicyOrgIAMWriteModel.WriteModel),
|
|
|
|
UserLoginMustBeDomain: wm.UserLoginMustBeDomain,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-10 09:48:40 +00:00
|
|
|
func writeModelToMailTemplatePolicy(wm *MailTemplateWriteModel) *domain.MailTemplate {
|
|
|
|
return &domain.MailTemplate{
|
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
|
|
|
Template: wm.Template,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func writeModelToMailTextPolicy(wm *MailTextWriteModel) *domain.MailText {
|
|
|
|
return &domain.MailText{
|
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
|
|
|
State: wm.State,
|
|
|
|
MailTextType: wm.MailTextType,
|
|
|
|
Language: wm.Language,
|
|
|
|
Title: wm.Title,
|
|
|
|
PreHeader: wm.PreHeader,
|
|
|
|
Subject: wm.Subject,
|
|
|
|
Greeting: wm.Greeting,
|
|
|
|
Text: wm.Text,
|
|
|
|
ButtonText: wm.ButtonText,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-18 10:24:15 +00:00
|
|
|
func writeModelToPasswordAgePolicy(wm *PasswordAgePolicyWriteModel) *domain.PasswordAgePolicy {
|
2021-01-05 08:33:45 +00:00
|
|
|
return &domain.PasswordAgePolicy{
|
2021-01-18 10:24:15 +00:00
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
2021-01-04 13:52:13 +00:00
|
|
|
MaxAgeDays: wm.MaxAgeDays,
|
|
|
|
ExpireWarnDays: wm.ExpireWarnDays,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-18 10:24:15 +00:00
|
|
|
func writeModelToPasswordComplexityPolicy(wm *PasswordComplexityPolicyWriteModel) *domain.PasswordComplexityPolicy {
|
2021-01-05 08:33:45 +00:00
|
|
|
return &domain.PasswordComplexityPolicy{
|
2021-01-18 10:24:15 +00:00
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
2021-01-04 13:52:13 +00:00
|
|
|
MinLength: wm.MinLength,
|
|
|
|
HasLowercase: wm.HasLowercase,
|
2021-01-18 10:24:15 +00:00
|
|
|
HasUppercase: wm.HasUppercase,
|
2021-01-04 13:52:13 +00:00
|
|
|
HasNumber: wm.HasNumber,
|
|
|
|
HasSymbol: wm.HasSymbol,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-18 10:24:15 +00:00
|
|
|
func writeModelToPasswordLockoutPolicy(wm *PasswordLockoutPolicyWriteModel) *domain.PasswordLockoutPolicy {
|
2021-01-05 08:33:45 +00:00
|
|
|
return &domain.PasswordLockoutPolicy{
|
2021-01-18 10:24:15 +00:00
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
2021-01-04 13:52:13 +00:00
|
|
|
MaxAttempts: wm.MaxAttempts,
|
|
|
|
ShowLockOutFailures: wm.ShowLockOutFailures,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-20 10:06:52 +00:00
|
|
|
func writeModelToIDPConfig(wm *IDPConfigWriteModel) *domain.IDPConfig {
|
2021-01-05 08:33:45 +00:00
|
|
|
return &domain.IDPConfig{
|
2021-01-04 13:52:13 +00:00
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
|
|
|
IDPConfigID: wm.ConfigID,
|
|
|
|
Name: wm.Name,
|
2021-01-05 08:33:45 +00:00
|
|
|
State: wm.State,
|
|
|
|
StylingType: wm.StylingType,
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-05 08:33:45 +00:00
|
|
|
func writeModelToIDPOIDCConfig(wm *OIDCConfigWriteModel) *domain.OIDCIDPConfig {
|
|
|
|
return &domain.OIDCIDPConfig{
|
2021-01-04 13:52:13 +00:00
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
|
|
|
ClientID: wm.ClientID,
|
|
|
|
IDPConfigID: wm.IDPConfigID,
|
2021-01-05 08:33:45 +00:00
|
|
|
IDPDisplayNameMapping: wm.IDPDisplayNameMapping,
|
2021-01-04 13:52:13 +00:00
|
|
|
Issuer: wm.Issuer,
|
|
|
|
Scopes: wm.Scopes,
|
2021-01-05 08:33:45 +00:00
|
|
|
UsernameMapping: wm.UserNameMapping,
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-18 10:24:15 +00:00
|
|
|
func writeModelToIDPProvider(wm *IdentityProviderWriteModel) *domain.IDPProvider {
|
2021-01-05 08:33:45 +00:00
|
|
|
return &domain.IDPProvider{
|
2021-01-18 10:24:15 +00:00
|
|
|
ObjectRoot: writeModelToObjectRoot(wm.WriteModel),
|
2021-01-04 13:52:13 +00:00
|
|
|
IDPConfigID: wm.IDPConfigID,
|
2021-01-05 08:33:45 +00:00
|
|
|
Type: wm.IDPProviderType,
|
2021-01-04 13:52:13 +00:00
|
|
|
}
|
|
|
|
}
|