mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +00:00
c2e6e782a8
* add setup steps * refactoring * omitempty * cleanup * begin org * create org * setup org * setup org * merge * fixes * fixes * fixes * add project * add oidc application * fix app creation * add resourceOwner to writemodels * resource owner * cleanup * global org, iam project and iam member in setup * logs * logs * logs * cleanup * Update internal/v2/command/project.go Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com> * check project state * add org domain commands * add org status changes and member commands * fixes * policies * login policy * fix iam project event * mapper * label policy * change to command * fix * fix * handle change event differently and lot of fixes * idps * fixes * fixes * fixes * changedEvent handling * fix change events * remove creation date Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com>
62 lines
1.6 KiB
Go
62 lines
1.6 KiB
Go
package query
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/crypto"
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
"github.com/caos/zitadel/internal/v2/domain"
|
|
"github.com/caos/zitadel/internal/v2/repository/idpconfig"
|
|
)
|
|
|
|
type OIDCConfigReadModel struct {
|
|
eventstore.ReadModel
|
|
|
|
IDPConfigID string
|
|
ClientID string
|
|
ClientSecret *crypto.CryptoValue
|
|
Issuer string
|
|
Scopes []string
|
|
IDPDisplayNameMapping domain.OIDCMappingField
|
|
UserNameMapping domain.OIDCMappingField
|
|
}
|
|
|
|
func (rm *OIDCConfigReadModel) Reduce() error {
|
|
for _, event := range rm.Events {
|
|
switch e := event.(type) {
|
|
case *idpconfig.OIDCConfigAddedEvent:
|
|
rm.reduceConfigAddedEvent(e)
|
|
case *idpconfig.OIDCConfigChangedEvent:
|
|
rm.reduceConfigChangedEvent(e)
|
|
}
|
|
}
|
|
|
|
return rm.ReadModel.Reduce()
|
|
}
|
|
|
|
func (rm *OIDCConfigReadModel) reduceConfigAddedEvent(e *idpconfig.OIDCConfigAddedEvent) {
|
|
rm.IDPConfigID = e.IDPConfigID
|
|
rm.ClientID = e.ClientID
|
|
rm.ClientSecret = e.ClientSecret
|
|
rm.Issuer = e.Issuer
|
|
rm.Scopes = e.Scopes
|
|
rm.IDPDisplayNameMapping = e.IDPDisplayNameMapping
|
|
rm.UserNameMapping = e.UserNameMapping
|
|
}
|
|
|
|
func (rm *OIDCConfigReadModel) reduceConfigChangedEvent(e *idpconfig.OIDCConfigChangedEvent) {
|
|
if e.ClientID != nil {
|
|
rm.ClientID = *e.ClientID
|
|
}
|
|
if e.Issuer != nil {
|
|
rm.Issuer = *e.Issuer
|
|
}
|
|
if len(e.Scopes) > 0 {
|
|
rm.Scopes = e.Scopes
|
|
}
|
|
if e.IDPDisplayNameMapping != nil && e.IDPDisplayNameMapping.Valid() {
|
|
rm.IDPDisplayNameMapping = *e.IDPDisplayNameMapping
|
|
}
|
|
if e.UserNameMapping != nil && e.UserNameMapping.Valid() {
|
|
rm.UserNameMapping = *e.UserNameMapping
|
|
}
|
|
}
|