mirror of
https://github.com/zitadel/zitadel.git
synced 2025-10-23 20:41:56 +00:00
fix: use domain models for v2 eventstore (#1151)
* fix: use domain models for v2 eventstore * fix: user domain model * Update internal/api/grpc/admin/login_policy_converter.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: converter Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/caos/zitadel/internal/eventstore/models"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/iam/model"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
)
|
||||
|
||||
func readModelToIAM(readModel *ReadModel) *model.IAM {
|
||||
@@ -24,25 +25,28 @@ func readModelToIAM(readModel *ReadModel) *model.IAM {
|
||||
}
|
||||
}
|
||||
|
||||
func readModelToIDPConfigView(rm *IAMIDPConfigReadModel) *model.IDPConfigView {
|
||||
return &model.IDPConfigView{
|
||||
AggregateID: rm.AggregateID,
|
||||
ChangeDate: rm.ChangeDate,
|
||||
CreationDate: rm.CreationDate,
|
||||
IDPConfigID: rm.ConfigID,
|
||||
IDPProviderType: model.IDPProviderType(rm.ProviderType),
|
||||
IsOIDC: rm.OIDCConfig != nil,
|
||||
Name: rm.Name,
|
||||
OIDCClientID: rm.OIDCConfig.ClientID,
|
||||
OIDCClientSecret: rm.OIDCConfig.ClientSecret,
|
||||
OIDCIDPDisplayNameMapping: model.OIDCMappingField(rm.OIDCConfig.IDPDisplayNameMapping),
|
||||
OIDCIssuer: rm.OIDCConfig.Issuer,
|
||||
OIDCScopes: rm.OIDCConfig.Scopes,
|
||||
OIDCUsernameMapping: model.OIDCMappingField(rm.OIDCConfig.UserNameMapping),
|
||||
Sequence: rm.ProcessedSequence,
|
||||
State: model.IDPConfigState(rm.State),
|
||||
StylingType: model.IDPStylingType(rm.StylingType),
|
||||
func readModelToIDPConfigView(rm *IAMIDPConfigReadModel) *domain.IDPConfigView {
|
||||
converted := &domain.IDPConfigView{
|
||||
AggregateID: rm.AggregateID,
|
||||
ChangeDate: rm.ChangeDate,
|
||||
CreationDate: rm.CreationDate,
|
||||
IDPConfigID: rm.ConfigID,
|
||||
IDPProviderType: rm.ProviderType,
|
||||
IsOIDC: rm.OIDCConfig != nil,
|
||||
Name: rm.Name,
|
||||
Sequence: rm.ProcessedSequence,
|
||||
State: rm.State,
|
||||
StylingType: rm.StylingType,
|
||||
}
|
||||
if rm.OIDCConfig != nil {
|
||||
converted.OIDCClientID = rm.OIDCConfig.ClientID
|
||||
converted.OIDCClientSecret = rm.OIDCConfig.ClientSecret
|
||||
converted.OIDCIDPDisplayNameMapping = rm.OIDCConfig.IDPDisplayNameMapping
|
||||
converted.OIDCIssuer = rm.OIDCConfig.Issuer
|
||||
converted.OIDCScopes = rm.OIDCConfig.Scopes
|
||||
converted.OIDCUsernameMapping = rm.OIDCConfig.UserNameMapping
|
||||
}
|
||||
return converted
|
||||
}
|
||||
|
||||
func readModelToMember(readModel *MemberReadModel) *model.IAMMember {
|
||||
|
16
internal/v2/query/iam_idp_config.go
Normal file
16
internal/v2/query/iam_idp_config.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
)
|
||||
|
||||
func (r *QuerySide) DefaultIDPConfigByID(ctx context.Context, idpConfigID string) (*domain.IDPConfigView, error) {
|
||||
idpConfig := NewIAMIDPConfigReadModel(r.iamID, idpConfigID)
|
||||
err := r.eventstore.FilterToQueryReducer(ctx, idpConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return readModelToIDPConfigView(idpConfig), nil
|
||||
}
|
@@ -1,16 +0,0 @@
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/caos/zitadel/internal/iam/model"
|
||||
)
|
||||
|
||||
func (r *QuerySide) DefaultIDPConfigByID(ctx context.Context, iamID, idpConfigID string) (*model.IDPConfigView, error) {
|
||||
idpConfig := NewIAMIDPConfigReadModel(iamID, idpConfigID)
|
||||
err := r.eventstore.FilterToQueryReducer(ctx, idpConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return readModelToIDPConfigView(idpConfig), nil
|
||||
}
|
@@ -13,6 +13,7 @@ import (
|
||||
)
|
||||
|
||||
type QuerySide struct {
|
||||
iamID string
|
||||
eventstore *eventstore.Eventstore
|
||||
idGenerator id.Generator
|
||||
secretCrypto crypto.Crypto
|
||||
@@ -25,6 +26,7 @@ type Config struct {
|
||||
|
||||
func StartQuerySide(config *Config) (repo *QuerySide, err error) {
|
||||
repo = &QuerySide{
|
||||
iamID: config.SystemDefaults.IamID,
|
||||
eventstore: config.Eventstore,
|
||||
idGenerator: id.SonyFlakeGenerator,
|
||||
}
|
||||
|
Reference in New Issue
Block a user