mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-05 09:52:03 +00:00
* fix: split command query side * fix: split command query side * fix: members in correct pkg structure * fix: label policy in correct pkg structure * fix: structure * fix: structure of login policy * fix: identityprovider structure * fix: org iam policy structure * fix: password age policy structure * fix: password complexity policy structure * fix: password lockout policy structure * fix: idp structure * fix: user events structure * fix: user write model * fix: profile email changed command * fix: address changed command * fix: user states * fix: user * fix: org structure and add human * begin iam setup command side * setup * step2 * step2 * fix: add user * step2 * isvalid * fix: folder structure v2 business Co-authored-by: Fabiennne <fabienne.gerschwiler@gmail.com>
188 lines
4.2 KiB
Go
188 lines
4.2 KiB
Go
package idpconfig
|
|
|
|
import (
|
|
"encoding/json"
|
|
"github.com/caos/zitadel/internal/errors"
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
|
"github.com/caos/zitadel/internal/v2/domain"
|
|
)
|
|
|
|
type IDPConfigAddedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
ConfigID string `json:"idpConfigId"`
|
|
Name string `json:"name,omitempty"`
|
|
Typ domain.IDPConfigType `json:"idpType,omitempty"`
|
|
StylingType domain.IDPConfigStylingType `json:"stylingType,omitempty"`
|
|
}
|
|
|
|
func NewIDPConfigAddedEvent(
|
|
base *eventstore.BaseEvent,
|
|
configID string,
|
|
name string,
|
|
configType domain.IDPConfigType,
|
|
stylingType domain.IDPConfigStylingType,
|
|
) *IDPConfigAddedEvent {
|
|
|
|
return &IDPConfigAddedEvent{
|
|
BaseEvent: *base,
|
|
ConfigID: configID,
|
|
Name: name,
|
|
StylingType: stylingType,
|
|
Typ: configType,
|
|
}
|
|
}
|
|
|
|
func (e *IDPConfigAddedEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func IDPConfigAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &IDPConfigAddedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
|
}
|
|
|
|
return e, nil
|
|
}
|
|
|
|
type IDPConfigChangedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
ConfigID string `json:"idpConfigId"`
|
|
Name string `json:"name,omitempty"`
|
|
StylingType domain.IDPConfigStylingType `json:"stylingType,omitempty"`
|
|
}
|
|
|
|
func (e *IDPConfigChangedEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func NewIDPConfigChangedEvent(
|
|
base *eventstore.BaseEvent,
|
|
) *IDPConfigChangedEvent {
|
|
return &IDPConfigChangedEvent{
|
|
BaseEvent: *base,
|
|
}
|
|
}
|
|
|
|
func IDPConfigChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &IDPConfigChangedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
|
}
|
|
|
|
return e, nil
|
|
}
|
|
|
|
type IDPConfigDeactivatedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
ConfigID string `idpConfigId`
|
|
}
|
|
|
|
func NewIDPConfigDeactivatedEvent(
|
|
base *eventstore.BaseEvent,
|
|
configID string,
|
|
) *IDPConfigDeactivatedEvent {
|
|
|
|
return &IDPConfigDeactivatedEvent{
|
|
BaseEvent: *base,
|
|
ConfigID: configID,
|
|
}
|
|
}
|
|
|
|
func (e *IDPConfigDeactivatedEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func IDPConfigDeactivatedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &IDPConfigDeactivatedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
|
}
|
|
|
|
return e, nil
|
|
}
|
|
|
|
type IDPConfigReactivatedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
ConfigID string `idpConfigId`
|
|
}
|
|
|
|
func NewIDPConfigReactivatedEvent(
|
|
base *eventstore.BaseEvent,
|
|
configID string,
|
|
) *IDPConfigReactivatedEvent {
|
|
|
|
return &IDPConfigReactivatedEvent{
|
|
BaseEvent: *base,
|
|
ConfigID: configID,
|
|
}
|
|
}
|
|
|
|
func (e *IDPConfigReactivatedEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func IDPConfigReactivatedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &IDPConfigReactivatedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
|
}
|
|
|
|
return e, nil
|
|
}
|
|
|
|
type IDPConfigRemovedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
ConfigID string `idpConfigId`
|
|
}
|
|
|
|
func NewIDPConfigRemovedEvent(
|
|
base *eventstore.BaseEvent,
|
|
configID string,
|
|
) *IDPConfigRemovedEvent {
|
|
|
|
return &IDPConfigRemovedEvent{
|
|
BaseEvent: *base,
|
|
ConfigID: configID,
|
|
}
|
|
}
|
|
|
|
func (e *IDPConfigRemovedEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func IDPConfigRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &IDPConfigRemovedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
|
}
|
|
|
|
return e, nil
|
|
}
|