mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-02 19:22:25 +00:00
This implementation increases parallel write capabilities of the eventstore. Please have a look at the technical advisories: [05](https://zitadel.com/docs/support/advisory/a10005) and [06](https://zitadel.com/docs/support/advisory/a10006). The implementation of eventstore.push is rewritten and stored events are migrated to a new table `eventstore.events2`. If you are using cockroach: make sure that the database user of ZITADEL has `VIEWACTIVITY` grant. This is used to query events.
136 lines
3.4 KiB
Go
136 lines
3.4 KiB
Go
package org
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
"github.com/zitadel/zitadel/internal/repository/policy"
|
|
)
|
|
|
|
var (
|
|
LoginPolicyAddedEventType = orgEventTypePrefix + policy.LoginPolicyAddedEventType
|
|
LoginPolicyChangedEventType = orgEventTypePrefix + policy.LoginPolicyChangedEventType
|
|
LoginPolicyRemovedEventType = orgEventTypePrefix + policy.LoginPolicyRemovedEventType
|
|
)
|
|
|
|
type LoginPolicyAddedEvent struct {
|
|
policy.LoginPolicyAddedEvent
|
|
}
|
|
|
|
func NewLoginPolicyAddedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
allowUsernamePassword,
|
|
allowRegister,
|
|
allowExternalIDP,
|
|
forceMFA,
|
|
forceMFALocalOnly,
|
|
hidePasswordReset,
|
|
ignoreUnknownUsernames,
|
|
allowDomainDiscovery,
|
|
disableLoginWithEmail,
|
|
disableLoginWithPhone 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,
|
|
forceMFALocalOnly,
|
|
hidePasswordReset,
|
|
ignoreUnknownUsernames,
|
|
allowDomainDiscovery,
|
|
disableLoginWithEmail,
|
|
disableLoginWithPhone,
|
|
passwordlessType,
|
|
defaultRedirectURI,
|
|
passwordCheckLifetime,
|
|
externalLoginCheckLifetime,
|
|
mfaInitSkipLifetime,
|
|
secondFactorCheckLifetime,
|
|
multiFactorCheckLifetime,
|
|
),
|
|
}
|
|
}
|
|
|
|
func LoginPolicyAddedEventMapper(event eventstore.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 eventstore.Event) (eventstore.Event, error) {
|
|
e, err := policy.LoginPolicyChangedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &LoginPolicyChangedEvent{LoginPolicyChangedEvent: *e.(*policy.LoginPolicyChangedEvent)}, nil
|
|
}
|
|
|
|
type LoginPolicyRemovedEvent struct {
|
|
policy.LoginPolicyRemovedEvent
|
|
}
|
|
|
|
func NewLoginPolicyRemovedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
) *LoginPolicyRemovedEvent {
|
|
return &LoginPolicyRemovedEvent{
|
|
LoginPolicyRemovedEvent: *policy.NewLoginPolicyRemovedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
LoginPolicyRemovedEventType),
|
|
),
|
|
}
|
|
}
|
|
|
|
func LoginPolicyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
|
e, err := policy.LoginPolicyRemovedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &LoginPolicyRemovedEvent{LoginPolicyRemovedEvent: *e.(*policy.LoginPolicyRemovedEvent)}, nil
|
|
}
|