mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +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),
|
||||
DefaultPasswordComplexityPolicy: readModelToPasswordComplexityPolicy(&readModel.DefaultPasswordComplexityPolicy),
|
||||
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 {
|
||||
return &model.IDPConfig{
|
||||
ObjectRoot: readModelToObjectRoot(rm.ReadModel),
|
||||
|
@ -39,15 +39,22 @@ 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 {
|
||||
return a.PushIDPOIDCConfigAdded(
|
||||
ctx,
|
||||
config.OIDCConfig.ClientID,
|
||||
idpConfigID,
|
||||
config.OIDCConfig.Issuer,
|
||||
clientSecret,
|
||||
oidc.MappingField(config.OIDCConfig.IDPDisplayNameMapping),
|
||||
oidc.MappingField(config.OIDCConfig.UsernameMapping),
|
||||
config.OIDCConfig.Scopes...)
|
||||
return a.
|
||||
PushIDPConfigAdded(
|
||||
ctx,
|
||||
idpConfigID,
|
||||
config.Name,
|
||||
idp.ConfigType(config.Type),
|
||||
idp.StylingType(config.StylingType)).
|
||||
PushIDPOIDCConfigAdded(
|
||||
ctx,
|
||||
config.OIDCConfig.ClientID,
|
||||
idpConfigID,
|
||||
config.OIDCConfig.Issuer,
|
||||
clientSecret,
|
||||
oidc.MappingField(config.OIDCConfig.IDPDisplayNameMapping),
|
||||
oidc.MappingField(config.OIDCConfig.UsernameMapping),
|
||||
config.OIDCConfig.Scopes...)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -114,7 +121,6 @@ func (r *Repository) pushIDPWriteModel(ctx context.Context, iamID, idpID string,
|
||||
}
|
||||
|
||||
aggregate := eventSetter(iam.AggregateFromWriteModel(&writeModel.WriteModel), writeModel)
|
||||
|
||||
err = r.eventstore.PushAggregate(ctx, writeModel, aggregate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -22,5 +22,12 @@ func RegisterEventMappers(es *eventstore.Eventstore) {
|
||||
RegisterFilterEventMapper(PasswordLockoutPolicyChangedEventType, PasswordLockoutPolicyChangedEventMapper).
|
||||
RegisterFilterEventMapper(MemberAddedEventType, MemberAddedEventMapper).
|
||||
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 (
|
||||
IDPOIDCConfigAddedEventType eventstore.EventType = "iam.idp.oidc.config.added"
|
||||
IDPOIDCConfigChangedEventType eventstore.EventType = "iam.idp.oidc.config.changed"
|
||||
IDPOIDCConfigAddedEventType eventstore.EventType = "iam.idp." + oidc.ConfigAddedEventType
|
||||
IDPOIDCConfigChangedEventType eventstore.EventType = "iam.idp." + oidc.ConfigChangedEventType
|
||||
)
|
||||
|
||||
type IDPOIDCConfigWriteModel struct {
|
||||
|
@ -9,6 +9,10 @@ import (
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
ConfigAddedEventType eventstore.EventType = "oidc.config.added"
|
||||
)
|
||||
|
||||
type ConfigAddedEvent struct {
|
||||
eventstore.BaseEvent
|
||||
|
||||
|
@ -11,6 +11,10 @@ import (
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
ConfigChangedEventType eventstore.EventType = "oidc.config.changed"
|
||||
)
|
||||
|
||||
type ConfigChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
|
@ -14,10 +14,6 @@ const (
|
||||
LabelPolicyRemovedEventType = "policy.label.removed"
|
||||
)
|
||||
|
||||
type LabelPolicyAggregate struct {
|
||||
eventstore.Aggregate
|
||||
}
|
||||
|
||||
type LabelPolicyReadModel struct {
|
||||
eventstore.ReadModel
|
||||
|
||||
|
@ -17,10 +17,6 @@ const (
|
||||
LoginPolicyIDPProviderRemovedEventType = "policy.login." + provider.RemovedEventType
|
||||
)
|
||||
|
||||
type LoginPolicyAggregate struct {
|
||||
eventstore.Aggregate
|
||||
}
|
||||
|
||||
type LoginPolicyReadModel struct {
|
||||
eventstore.ReadModel
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user