mirror of
https://github.com/zitadel/zitadel.git
synced 2025-04-03 10:05:41 +00:00

* fix: wait for projection initialization to be done * feat: allow domain discovery for unknown usernames * fix linting * Update console/src/assets/i18n/de.json Co-authored-by: Fabi <38692350+hifabienne@users.noreply.github.com> * Update console/src/assets/i18n/en.json Co-authored-by: Fabi <38692350+hifabienne@users.noreply.github.com> * Update console/src/assets/i18n/it.json Co-authored-by: Fabi <38692350+hifabienne@users.noreply.github.com> * Update console/src/assets/i18n/fr.json Co-authored-by: Fabi <38692350+hifabienne@users.noreply.github.com> * fix zh i18n text * fix projection table name Co-authored-by: Fabi <38692350+hifabienne@users.noreply.github.com>
99 lines
3.1 KiB
Go
99 lines
3.1 KiB
Go
package command
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
"github.com/zitadel/zitadel/internal/repository/policy"
|
|
)
|
|
|
|
type LoginPolicyWriteModel struct {
|
|
eventstore.WriteModel
|
|
|
|
AllowUserNamePassword bool
|
|
AllowRegister bool
|
|
AllowExternalIDP bool
|
|
ForceMFA bool
|
|
HidePasswordReset bool
|
|
IgnoreUnknownUsernames bool
|
|
AllowDomainDiscovery bool
|
|
PasswordlessType domain.PasswordlessType
|
|
DefaultRedirectURI string
|
|
PasswordCheckLifetime time.Duration
|
|
ExternalLoginCheckLifetime time.Duration
|
|
MFAInitSkipLifetime time.Duration
|
|
SecondFactorCheckLifetime time.Duration
|
|
MultiFactorCheckLifetime time.Duration
|
|
State domain.PolicyState
|
|
}
|
|
|
|
func (wm *LoginPolicyWriteModel) Reduce() error {
|
|
for _, event := range wm.Events {
|
|
switch e := event.(type) {
|
|
case *policy.LoginPolicyAddedEvent:
|
|
wm.AllowRegister = e.AllowRegister
|
|
wm.AllowUserNamePassword = e.AllowUserNamePassword
|
|
wm.AllowExternalIDP = e.AllowExternalIDP
|
|
wm.ForceMFA = e.ForceMFA
|
|
wm.PasswordlessType = e.PasswordlessType
|
|
wm.HidePasswordReset = e.HidePasswordReset
|
|
wm.IgnoreUnknownUsernames = e.IgnoreUnknownUsernames
|
|
wm.AllowDomainDiscovery = e.AllowDomainDiscovery
|
|
wm.DefaultRedirectURI = e.DefaultRedirectURI
|
|
wm.PasswordCheckLifetime = e.PasswordCheckLifetime
|
|
wm.ExternalLoginCheckLifetime = e.ExternalLoginCheckLifetime
|
|
wm.MFAInitSkipLifetime = e.MFAInitSkipLifetime
|
|
wm.SecondFactorCheckLifetime = e.SecondFactorCheckLifetime
|
|
wm.MultiFactorCheckLifetime = e.MultiFactorCheckLifetime
|
|
wm.State = domain.PolicyStateActive
|
|
case *policy.LoginPolicyChangedEvent:
|
|
if e.AllowRegister != nil {
|
|
wm.AllowRegister = *e.AllowRegister
|
|
}
|
|
if e.AllowUserNamePassword != nil {
|
|
wm.AllowUserNamePassword = *e.AllowUserNamePassword
|
|
}
|
|
if e.AllowExternalIDP != nil {
|
|
wm.AllowExternalIDP = *e.AllowExternalIDP
|
|
}
|
|
if e.ForceMFA != nil {
|
|
wm.ForceMFA = *e.ForceMFA
|
|
}
|
|
if e.HidePasswordReset != nil {
|
|
wm.HidePasswordReset = *e.HidePasswordReset
|
|
}
|
|
if e.IgnoreUnknownUsernames != nil {
|
|
wm.IgnoreUnknownUsernames = *e.IgnoreUnknownUsernames
|
|
}
|
|
if e.AllowDomainDiscovery != nil {
|
|
wm.AllowDomainDiscovery = *e.AllowDomainDiscovery
|
|
}
|
|
if e.PasswordlessType != nil {
|
|
wm.PasswordlessType = *e.PasswordlessType
|
|
}
|
|
if e.DefaultRedirectURI != nil {
|
|
wm.DefaultRedirectURI = *e.DefaultRedirectURI
|
|
}
|
|
if e.PasswordCheckLifetime != nil {
|
|
wm.PasswordCheckLifetime = *e.PasswordCheckLifetime
|
|
}
|
|
if e.ExternalLoginCheckLifetime != nil {
|
|
wm.ExternalLoginCheckLifetime = *e.ExternalLoginCheckLifetime
|
|
}
|
|
if e.MFAInitSkipLifetime != nil {
|
|
wm.MFAInitSkipLifetime = *e.MFAInitSkipLifetime
|
|
}
|
|
if e.SecondFactorCheckLifetime != nil {
|
|
wm.SecondFactorCheckLifetime = *e.SecondFactorCheckLifetime
|
|
}
|
|
if e.MultiFactorCheckLifetime != nil {
|
|
wm.MultiFactorCheckLifetime = *e.MultiFactorCheckLifetime
|
|
}
|
|
case *policy.LoginPolicyRemovedEvent:
|
|
wm.State = domain.PolicyStateRemoved
|
|
}
|
|
}
|
|
return wm.WriteModel.Reduce()
|
|
}
|