mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-21 23:37:31 +00:00
b5564572bc
This implementation increases parallel write capabilities of the eventstore. Please have a look at the technical advisories: [05](https://zitadel.com/docs/support/advisory/a10005) and [06](https://zitadel.com/docs/support/advisory/a10006). The implementation of eventstore.push is rewritten and stored events are migrated to a new table `eventstore.events2`. If you are using cockroach: make sure that the database user of ZITADEL has `VIEWACTIVITY` grant. This is used to query events.
96 lines
2.3 KiB
Go
96 lines
2.3 KiB
Go
package org
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
"github.com/zitadel/zitadel/internal/repository/idpconfig"
|
|
)
|
|
|
|
const (
|
|
IDPOIDCConfigAddedEventType eventstore.EventType = "org.idp." + idpconfig.OIDCConfigAddedEventType
|
|
IDPOIDCConfigChangedEventType eventstore.EventType = "org.idp." + idpconfig.OIDCConfigChangedEventType
|
|
)
|
|
|
|
type IDPOIDCConfigAddedEvent struct {
|
|
idpconfig.OIDCConfigAddedEvent
|
|
}
|
|
|
|
func NewIDPOIDCConfigAddedEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
clientID,
|
|
idpConfigID,
|
|
issuer,
|
|
authorizationEndpoint,
|
|
tokenEndpoint string,
|
|
clientSecret *crypto.CryptoValue,
|
|
idpDisplayNameMapping,
|
|
userNameMapping domain.OIDCMappingField,
|
|
scopes ...string,
|
|
) *IDPOIDCConfigAddedEvent {
|
|
|
|
return &IDPOIDCConfigAddedEvent{
|
|
OIDCConfigAddedEvent: *idpconfig.NewOIDCConfigAddedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
IDPOIDCConfigAddedEventType,
|
|
),
|
|
clientID,
|
|
idpConfigID,
|
|
issuer,
|
|
authorizationEndpoint,
|
|
tokenEndpoint,
|
|
clientSecret,
|
|
idpDisplayNameMapping,
|
|
userNameMapping,
|
|
scopes...,
|
|
),
|
|
}
|
|
}
|
|
|
|
func IDPOIDCConfigAddedEventMapper(event eventstore.Event) (eventstore.Event, 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,
|
|
aggregate *eventstore.Aggregate,
|
|
idpConfigID string,
|
|
changes []idpconfig.OIDCConfigChanges,
|
|
) (*IDPOIDCConfigChangedEvent, error) {
|
|
changeEvent, err := idpconfig.NewOIDCConfigChangedEvent(
|
|
eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
IDPOIDCConfigChangedEventType),
|
|
idpConfigID,
|
|
changes,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &IDPOIDCConfigChangedEvent{OIDCConfigChangedEvent: *changeEvent}, nil
|
|
}
|
|
|
|
func IDPOIDCConfigChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
|
e, err := idpconfig.OIDCConfigChangedEventMapper(event)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &IDPOIDCConfigChangedEvent{OIDCConfigChangedEvent: *e.(*idpconfig.OIDCConfigChangedEvent)}, nil
|
|
}
|