2021-01-20 10:06:52 +00:00
|
|
|
package org
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-03 08:19:07 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
2021-02-18 13:48:27 +00:00
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
|
|
|
"github.com/zitadel/zitadel/internal/repository/idpconfig"
|
2021-01-20 10:06:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
IDPConfigAddedEventType eventstore.EventType = "org.idp.config.added"
|
|
|
|
IDPConfigChangedEventType eventstore.EventType = "org.idp.config.changed"
|
|
|
|
IDPConfigRemovedEventType eventstore.EventType = "org.idp.config.removed"
|
|
|
|
IDPConfigDeactivatedEventType eventstore.EventType = "org.idp.config.deactivated"
|
|
|
|
IDPConfigReactivatedEventType eventstore.EventType = "org.idp.config.reactivated"
|
|
|
|
)
|
|
|
|
|
|
|
|
type IDPConfigAddedEvent struct {
|
|
|
|
idpconfig.IDPConfigAddedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewIDPConfigAddedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-21 09:49:38 +00:00
|
|
|
configID,
|
2021-01-20 10:06:52 +00:00
|
|
|
name string,
|
|
|
|
configType domain.IDPConfigType,
|
|
|
|
stylingType domain.IDPConfigStylingType,
|
2021-09-10 07:49:49 +00:00
|
|
|
autoRegister bool,
|
2021-01-20 10:06:52 +00:00
|
|
|
) *IDPConfigAddedEvent {
|
|
|
|
|
|
|
|
return &IDPConfigAddedEvent{
|
|
|
|
IDPConfigAddedEvent: *idpconfig.NewIDPConfigAddedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
2021-01-20 10:06:52 +00:00
|
|
|
ctx,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate,
|
2021-01-20 10:06:52 +00:00
|
|
|
IDPConfigAddedEventType,
|
|
|
|
),
|
|
|
|
configID,
|
|
|
|
name,
|
|
|
|
configType,
|
|
|
|
stylingType,
|
2021-09-10 07:49:49 +00:00
|
|
|
autoRegister,
|
2021-01-20 10:06:52 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func IDPConfigAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-20 10:06:52 +00:00
|
|
|
e, err := idpconfig.IDPConfigAddedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &IDPConfigAddedEvent{IDPConfigAddedEvent: *e.(*idpconfig.IDPConfigAddedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type IDPConfigChangedEvent struct {
|
|
|
|
idpconfig.IDPConfigChangedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewIDPConfigChangedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-02-15 12:31:24 +00:00
|
|
|
configID,
|
|
|
|
oldName string,
|
2021-01-20 10:06:52 +00:00
|
|
|
changes []idpconfig.IDPConfigChanges,
|
|
|
|
) (*IDPConfigChangedEvent, error) {
|
|
|
|
changeEvent, err := idpconfig.NewIDPConfigChangedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(ctx,
|
|
|
|
aggregate,
|
|
|
|
IDPConfigChangedEventType),
|
2021-01-20 10:06:52 +00:00
|
|
|
configID,
|
2021-02-15 12:31:24 +00:00
|
|
|
oldName,
|
2021-01-20 10:06:52 +00:00
|
|
|
changes,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &IDPConfigChangedEvent{IDPConfigChangedEvent: *changeEvent}, nil
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func IDPConfigChangedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-20 10:06:52 +00:00
|
|
|
e, err := idpconfig.IDPConfigChangedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &IDPConfigChangedEvent{IDPConfigChangedEvent: *e.(*idpconfig.IDPConfigChangedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type IDPConfigRemovedEvent struct {
|
|
|
|
idpconfig.IDPConfigRemovedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewIDPConfigRemovedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-21 09:49:38 +00:00
|
|
|
configID,
|
|
|
|
name string,
|
2021-01-20 10:06:52 +00:00
|
|
|
) *IDPConfigRemovedEvent {
|
|
|
|
|
|
|
|
return &IDPConfigRemovedEvent{
|
|
|
|
IDPConfigRemovedEvent: *idpconfig.NewIDPConfigRemovedEvent(
|
2021-02-18 13:48:27 +00:00
|
|
|
eventstore.NewBaseEventForPush(
|
2021-01-20 10:06:52 +00:00
|
|
|
ctx,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate,
|
2021-01-20 10:06:52 +00:00
|
|
|
IDPConfigRemovedEventType,
|
|
|
|
),
|
|
|
|
configID,
|
2021-01-21 09:49:38 +00:00
|
|
|
name,
|
2021-01-20 10:06:52 +00:00
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func IDPConfigRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-20 10:06:52 +00:00
|
|
|
e, err := idpconfig.IDPConfigRemovedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &IDPConfigRemovedEvent{IDPConfigRemovedEvent: *e.(*idpconfig.IDPConfigRemovedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type IDPConfigDeactivatedEvent struct {
|
|
|
|
idpconfig.IDPConfigDeactivatedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewIDPConfigDeactivatedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-20 10:06:52 +00:00
|
|
|
configID string,
|
|
|
|
) *IDPConfigDeactivatedEvent {
|
|
|
|
|
|
|
|
return &IDPConfigDeactivatedEvent{
|
|
|
|
IDPConfigDeactivatedEvent: *idpconfig.NewIDPConfigDeactivatedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate,
|
2021-01-20 10:06:52 +00:00
|
|
|
IDPConfigDeactivatedEventType,
|
|
|
|
),
|
|
|
|
configID,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func IDPConfigDeactivatedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-20 10:06:52 +00:00
|
|
|
e, err := idpconfig.IDPConfigDeactivatedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &IDPConfigDeactivatedEvent{IDPConfigDeactivatedEvent: *e.(*idpconfig.IDPConfigDeactivatedEvent)}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
type IDPConfigReactivatedEvent struct {
|
|
|
|
idpconfig.IDPConfigReactivatedEvent
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewIDPConfigReactivatedEvent(
|
|
|
|
ctx context.Context,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate *eventstore.Aggregate,
|
2021-01-20 10:06:52 +00:00
|
|
|
configID string,
|
|
|
|
) *IDPConfigReactivatedEvent {
|
|
|
|
|
|
|
|
return &IDPConfigReactivatedEvent{
|
|
|
|
IDPConfigReactivatedEvent: *idpconfig.NewIDPConfigReactivatedEvent(
|
|
|
|
eventstore.NewBaseEventForPush(
|
|
|
|
ctx,
|
2021-02-18 13:48:27 +00:00
|
|
|
aggregate,
|
2021-01-20 10:06:52 +00:00
|
|
|
IDPConfigReactivatedEventType,
|
|
|
|
),
|
|
|
|
configID,
|
|
|
|
),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-03 08:19:07 +00:00
|
|
|
func IDPConfigReactivatedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
2021-01-20 10:06:52 +00:00
|
|
|
e, err := idpconfig.IDPConfigReactivatedEventMapper(event)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &IDPConfigReactivatedEvent{IDPConfigReactivatedEvent: *e.(*idpconfig.IDPConfigReactivatedEvent)}, nil
|
|
|
|
}
|