mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +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>
87 lines
2.2 KiB
Go
87 lines
2.2 KiB
Go
package iam
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/crypto"
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
|
"github.com/caos/zitadel/internal/v2/domain"
|
|
"github.com/caos/zitadel/internal/v2/repository/idpconfig"
|
|
)
|
|
|
|
const (
|
|
IDPOIDCConfigAddedEventType eventstore.EventType = "iam.idp." + idpconfig.OIDCConfigAddedEventType
|
|
IDPOIDCConfigChangedEventType eventstore.EventType = "iam.idp." + idpconfig.ConfigChangedEventType
|
|
)
|
|
|
|
type IDPOIDCConfigAddedEvent struct {
|
|
idpconfig.OIDCConfigAddedEvent
|
|
}
|
|
|
|
func NewIDPOIDCConfigAddedEvent(
|
|
ctx context.Context,
|
|
clientID,
|
|
idpConfigID,
|
|
issuer string,
|
|
clientSecret *crypto.CryptoValue,
|
|
idpDisplayNameMapping,
|
|
userNameMapping domain.OIDCMappingField,
|
|
scopes ...string,
|
|
) *IDPOIDCConfigAddedEvent {
|
|
|
|
return &IDPOIDCConfigAddedEvent{
|
|
OIDCConfigAddedEvent: *idpconfig.NewOIDCConfigAddedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
IDPOIDCConfigAddedEventType,
|
|
),
|
|
clientID,
|
|
idpConfigID,
|
|
issuer,
|
|
clientSecret,
|
|
idpDisplayNameMapping,
|
|
userNameMapping,
|
|
scopes...,
|
|
),
|
|
}
|
|
}
|
|
|
|
func IDPOIDCConfigAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e, err := idpconfig.OIDCConfigAddedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &IDPOIDCConfigAddedEvent{OIDCConfigAddedEvent: *e.(*idpconfig.OIDCConfigAddedEvent)}, nil
|
|
}
|
|
|
|
type IDPOIDCConfigChangedEvent struct {
|
|
idpconfig.OIDCConfigChangedEvent
|
|
}
|
|
|
|
func NewIDPOIDCConfigChangedEvent(
|
|
ctx context.Context,
|
|
idpConfigID string,
|
|
changes []idpconfig.OIDCConfigChanges,
|
|
) (*IDPOIDCConfigChangedEvent, error) {
|
|
changeEvent, err := idpconfig.NewOIDCConfigChangedEvent(
|
|
eventstore.NewBaseEventForPush(ctx, IDPOIDCConfigChangedEventType),
|
|
idpConfigID,
|
|
changes,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &IDPOIDCConfigChangedEvent{OIDCConfigChangedEvent: *changeEvent}, nil
|
|
}
|
|
|
|
func IDPOIDCConfigChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e, err := idpconfig.OIDCConfigChangedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &IDPOIDCConfigChangedEvent{OIDCConfigChangedEvent: *e.(*idpconfig.OIDCConfigChangedEvent)}, nil
|
|
}
|