Livio Spring bffb10a4b4
feat: allow domain discovery for unknown usernames (#4484)
* 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>
2022-10-06 13:30:14 +02:00

103 lines
2.5 KiB
Go

package instance
import (
"context"
"time"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/eventstore/repository"
"github.com/zitadel/zitadel/internal/repository/policy"
)
var (
LoginPolicyAddedEventType = instanceEventTypePrefix + policy.LoginPolicyAddedEventType
LoginPolicyChangedEventType = instanceEventTypePrefix + policy.LoginPolicyChangedEventType
)
type LoginPolicyAddedEvent struct {
policy.LoginPolicyAddedEvent
}
func NewLoginPolicyAddedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
allowUsernamePassword,
allowRegister,
allowExternalIDP,
forceMFA,
hidePasswordReset,
ignoreUnknownUsernames,
allowDomainDiscovery bool,
passwordlessType domain.PasswordlessType,
defaultRedirectURI string,
passwordCheckLifetime,
externalLoginCheckLifetime,
mfaInitSkipLifetime,
secondFactorCheckLifetime,
multiFactorCheckLifetime time.Duration,
) *LoginPolicyAddedEvent {
return &LoginPolicyAddedEvent{
LoginPolicyAddedEvent: *policy.NewLoginPolicyAddedEvent(
eventstore.NewBaseEventForPush(
ctx,
aggregate,
LoginPolicyAddedEventType),
allowUsernamePassword,
allowRegister,
allowExternalIDP,
forceMFA,
hidePasswordReset,
ignoreUnknownUsernames,
allowDomainDiscovery,
passwordlessType,
defaultRedirectURI,
passwordCheckLifetime,
externalLoginCheckLifetime,
mfaInitSkipLifetime,
secondFactorCheckLifetime,
multiFactorCheckLifetime),
}
}
func LoginPolicyAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
e, err := policy.LoginPolicyAddedEventMapper(event)
if err != nil {
return nil, err
}
return &LoginPolicyAddedEvent{LoginPolicyAddedEvent: *e.(*policy.LoginPolicyAddedEvent)}, nil
}
type LoginPolicyChangedEvent struct {
policy.LoginPolicyChangedEvent
}
func NewLoginPolicyChangedEvent(
ctx context.Context,
aggregate *eventstore.Aggregate,
changes []policy.LoginPolicyChanges,
) (*LoginPolicyChangedEvent, error) {
changedEvent, err := policy.NewLoginPolicyChangedEvent(
eventstore.NewBaseEventForPush(
ctx,
aggregate,
LoginPolicyChangedEventType),
changes,
)
if err != nil {
return nil, err
}
return &LoginPolicyChangedEvent{LoginPolicyChangedEvent: *changedEvent}, nil
}
func LoginPolicyChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
e, err := policy.LoginPolicyChangedEventMapper(event)
if err != nil {
return nil, err
}
return &LoginPolicyChangedEvent{LoginPolicyChangedEvent: *e.(*policy.LoginPolicyChangedEvent)}, nil
}