mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-07 15:17:55 +00:00
fix idp mappers
This commit is contained in:
parent
d494da67be
commit
cf1df99a10
@ -24,7 +24,7 @@ func readModelToIAM(readModel *iam_repo.ReadModel) *model.IAM {
|
|||||||
DefaultPasswordAgePolicy: readModelToPasswordAgePolicy(&readModel.DefaultPasswordAgePolicy),
|
DefaultPasswordAgePolicy: readModelToPasswordAgePolicy(&readModel.DefaultPasswordAgePolicy),
|
||||||
DefaultPasswordComplexityPolicy: readModelToPasswordComplexityPolicy(&readModel.DefaultPasswordComplexityPolicy),
|
DefaultPasswordComplexityPolicy: readModelToPasswordComplexityPolicy(&readModel.DefaultPasswordComplexityPolicy),
|
||||||
DefaultPasswordLockoutPolicy: readModelToPasswordLockoutPolicy(&readModel.DefaultPasswordLockoutPolicy),
|
DefaultPasswordLockoutPolicy: readModelToPasswordLockoutPolicy(&readModel.DefaultPasswordLockoutPolicy),
|
||||||
// TODO: IDPs: []*model.IDPConfig,
|
IDPs: readModelToIDPConfigs(&readModel.IDPs),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,6 +155,14 @@ func readModelToIDPConfigView(rm *iam.IDPConfigReadModel) *model.IDPConfigView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func readModelToIDPConfigs(rm *iam.IDPConfigsReadModel) []*model.IDPConfig {
|
||||||
|
configs := make([]*model.IDPConfig, len(rm.Configs))
|
||||||
|
for i, config := range rm.Configs {
|
||||||
|
configs[i] = readModelToIDPConfig(&iam.IDPConfigReadModel{ConfigReadModel: *config})
|
||||||
|
}
|
||||||
|
return configs
|
||||||
|
}
|
||||||
|
|
||||||
func readModelToIDPConfig(rm *iam.IDPConfigReadModel) *model.IDPConfig {
|
func readModelToIDPConfig(rm *iam.IDPConfigReadModel) *model.IDPConfig {
|
||||||
return &model.IDPConfig{
|
return &model.IDPConfig{
|
||||||
ObjectRoot: readModelToObjectRoot(rm.ReadModel),
|
ObjectRoot: readModelToObjectRoot(rm.ReadModel),
|
||||||
|
@ -39,7 +39,14 @@ func (r *Repository) AddIDPConfig(ctx context.Context, config *iam_model.IDPConf
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeModel, err := r.pushIDPWriteModel(ctx, config.AggregateID, idpConfigID, func(a *iam.Aggregate, _ *iam.IDPConfigWriteModel) *iam.Aggregate {
|
writeModel, err := r.pushIDPWriteModel(ctx, config.AggregateID, idpConfigID, func(a *iam.Aggregate, _ *iam.IDPConfigWriteModel) *iam.Aggregate {
|
||||||
return a.PushIDPOIDCConfigAdded(
|
return a.
|
||||||
|
PushIDPConfigAdded(
|
||||||
|
ctx,
|
||||||
|
idpConfigID,
|
||||||
|
config.Name,
|
||||||
|
idp.ConfigType(config.Type),
|
||||||
|
idp.StylingType(config.StylingType)).
|
||||||
|
PushIDPOIDCConfigAdded(
|
||||||
ctx,
|
ctx,
|
||||||
config.OIDCConfig.ClientID,
|
config.OIDCConfig.ClientID,
|
||||||
idpConfigID,
|
idpConfigID,
|
||||||
@ -114,7 +121,6 @@ func (r *Repository) pushIDPWriteModel(ctx context.Context, iamID, idpID string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
aggregate := eventSetter(iam.AggregateFromWriteModel(&writeModel.WriteModel), writeModel)
|
aggregate := eventSetter(iam.AggregateFromWriteModel(&writeModel.WriteModel), writeModel)
|
||||||
|
|
||||||
err = r.eventstore.PushAggregate(ctx, writeModel, aggregate)
|
err = r.eventstore.PushAggregate(ctx, writeModel, aggregate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -22,5 +22,12 @@ func RegisterEventMappers(es *eventstore.Eventstore) {
|
|||||||
RegisterFilterEventMapper(PasswordLockoutPolicyChangedEventType, PasswordLockoutPolicyChangedEventMapper).
|
RegisterFilterEventMapper(PasswordLockoutPolicyChangedEventType, PasswordLockoutPolicyChangedEventMapper).
|
||||||
RegisterFilterEventMapper(MemberAddedEventType, MemberAddedEventMapper).
|
RegisterFilterEventMapper(MemberAddedEventType, MemberAddedEventMapper).
|
||||||
RegisterFilterEventMapper(MemberChangedEventType, MemberChangedEventMapper).
|
RegisterFilterEventMapper(MemberChangedEventType, MemberChangedEventMapper).
|
||||||
RegisterFilterEventMapper(MemberRemovedEventType, MemberRemovedEventMapper)
|
RegisterFilterEventMapper(MemberRemovedEventType, MemberRemovedEventMapper).
|
||||||
|
RegisterFilterEventMapper(IDPConfigAddedEventType, IDPConfigAddedEventMapper).
|
||||||
|
RegisterFilterEventMapper(IDPConfigChangedEventType, IDPConfigChangedEventMapper).
|
||||||
|
RegisterFilterEventMapper(IDPConfigRemovedEventType, IDPConfigRemovedEventMapper).
|
||||||
|
RegisterFilterEventMapper(IDPConfigDeactivatedEventType, IDPConfigDeactivatedEventMapper).
|
||||||
|
RegisterFilterEventMapper(IDPConfigReactivatedEventType, IDPConfigReactivatedEventMapper).
|
||||||
|
RegisterFilterEventMapper(IDPOIDCConfigAddedEventType, IDPOIDCConfigAddedEventMapper).
|
||||||
|
RegisterFilterEventMapper(IDPOIDCConfigChangedEventType, IDPOIDCConfigChangedEventMapper)
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
IDPOIDCConfigAddedEventType eventstore.EventType = "iam.idp.oidc.config.added"
|
IDPOIDCConfigAddedEventType eventstore.EventType = "iam.idp." + oidc.ConfigAddedEventType
|
||||||
IDPOIDCConfigChangedEventType eventstore.EventType = "iam.idp.oidc.config.changed"
|
IDPOIDCConfigChangedEventType eventstore.EventType = "iam.idp." + oidc.ConfigChangedEventType
|
||||||
)
|
)
|
||||||
|
|
||||||
type IDPOIDCConfigWriteModel struct {
|
type IDPOIDCConfigWriteModel struct {
|
||||||
|
@ -9,6 +9,10 @@ import (
|
|||||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ConfigAddedEventType eventstore.EventType = "oidc.config.added"
|
||||||
|
)
|
||||||
|
|
||||||
type ConfigAddedEvent struct {
|
type ConfigAddedEvent struct {
|
||||||
eventstore.BaseEvent
|
eventstore.BaseEvent
|
||||||
|
|
||||||
|
@ -11,6 +11,10 @@ import (
|
|||||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ConfigChangedEventType eventstore.EventType = "oidc.config.changed"
|
||||||
|
)
|
||||||
|
|
||||||
type ConfigChangedEvent struct {
|
type ConfigChangedEvent struct {
|
||||||
eventstore.BaseEvent `json:"-"`
|
eventstore.BaseEvent `json:"-"`
|
||||||
|
|
||||||
|
@ -14,10 +14,6 @@ const (
|
|||||||
LabelPolicyRemovedEventType = "policy.label.removed"
|
LabelPolicyRemovedEventType = "policy.label.removed"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LabelPolicyAggregate struct {
|
|
||||||
eventstore.Aggregate
|
|
||||||
}
|
|
||||||
|
|
||||||
type LabelPolicyReadModel struct {
|
type LabelPolicyReadModel struct {
|
||||||
eventstore.ReadModel
|
eventstore.ReadModel
|
||||||
|
|
||||||
|
@ -17,10 +17,6 @@ const (
|
|||||||
LoginPolicyIDPProviderRemovedEventType = "policy.login." + provider.RemovedEventType
|
LoginPolicyIDPProviderRemovedEventType = "policy.login." + provider.RemovedEventType
|
||||||
)
|
)
|
||||||
|
|
||||||
type LoginPolicyAggregate struct {
|
|
||||||
eventstore.Aggregate
|
|
||||||
}
|
|
||||||
|
|
||||||
type LoginPolicyReadModel struct {
|
type LoginPolicyReadModel struct {
|
||||||
eventstore.ReadModel
|
eventstore.ReadModel
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user