mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 19:44:21 +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.
151 lines
3.4 KiB
Go
151 lines
3.4 KiB
Go
package idp
|
|
|
|
import (
|
|
"github.com/zitadel/zitadel/internal/errors"
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
)
|
|
|
|
type JWTIDPAddedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
ID string `json:"id"`
|
|
Name string `json:"name,omitempty"`
|
|
Issuer string `json:"issuer,omitempty"`
|
|
JWTEndpoint string `json:"jwtEndpoint,omitempty"`
|
|
KeysEndpoint string `json:"keysEndpoint,omitempty"`
|
|
HeaderName string `json:"headerName,omitempty"`
|
|
Options
|
|
}
|
|
|
|
func NewJWTIDPAddedEvent(
|
|
base *eventstore.BaseEvent,
|
|
id,
|
|
name,
|
|
issuer,
|
|
jwtEndpoint,
|
|
keysEndpoint,
|
|
headerName string,
|
|
options Options,
|
|
) *JWTIDPAddedEvent {
|
|
return &JWTIDPAddedEvent{
|
|
BaseEvent: *base,
|
|
ID: id,
|
|
Name: name,
|
|
Issuer: issuer,
|
|
JWTEndpoint: jwtEndpoint,
|
|
KeysEndpoint: keysEndpoint,
|
|
HeaderName: headerName,
|
|
Options: options,
|
|
}
|
|
}
|
|
|
|
func (e *JWTIDPAddedEvent) Payload() interface{} {
|
|
return e
|
|
}
|
|
|
|
func (e *JWTIDPAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func JWTIDPAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
|
e := &JWTIDPAddedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := event.Unmarshal(e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "IDP-Et1dq", "unable to unmarshal event")
|
|
}
|
|
|
|
return e, nil
|
|
}
|
|
|
|
type JWTIDPChangedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
ID string `json:"id"`
|
|
Name *string `json:"name,omitempty"`
|
|
Issuer *string `json:"issuer,omitempty"`
|
|
JWTEndpoint *string `json:"jwtEndpoint,omitempty"`
|
|
KeysEndpoint *string `json:"keysEndpoint,omitempty"`
|
|
HeaderName *string `json:"headerName,omitempty"`
|
|
OptionChanges
|
|
}
|
|
|
|
func NewJWTIDPChangedEvent(
|
|
base *eventstore.BaseEvent,
|
|
id string,
|
|
changes []JWTIDPChanges,
|
|
) (*JWTIDPChangedEvent, error) {
|
|
if len(changes) == 0 {
|
|
return nil, errors.ThrowPreconditionFailed(nil, "IDP-BH3dl", "Errors.NoChangesFound")
|
|
}
|
|
changedEvent := &JWTIDPChangedEvent{
|
|
BaseEvent: *base,
|
|
ID: id,
|
|
}
|
|
for _, change := range changes {
|
|
change(changedEvent)
|
|
}
|
|
return changedEvent, nil
|
|
}
|
|
|
|
type JWTIDPChanges func(*JWTIDPChangedEvent)
|
|
|
|
func ChangeJWTName(name string) func(*JWTIDPChangedEvent) {
|
|
return func(e *JWTIDPChangedEvent) {
|
|
e.Name = &name
|
|
}
|
|
}
|
|
|
|
func ChangeJWTIssuer(issuer string) func(*JWTIDPChangedEvent) {
|
|
return func(e *JWTIDPChangedEvent) {
|
|
e.Issuer = &issuer
|
|
}
|
|
}
|
|
|
|
func ChangeJWTEndpoint(jwtEndpoint string) func(*JWTIDPChangedEvent) {
|
|
return func(e *JWTIDPChangedEvent) {
|
|
e.JWTEndpoint = &jwtEndpoint
|
|
}
|
|
}
|
|
|
|
func ChangeJWTKeysEndpoint(keysEndpoint string) func(*JWTIDPChangedEvent) {
|
|
return func(e *JWTIDPChangedEvent) {
|
|
e.KeysEndpoint = &keysEndpoint
|
|
}
|
|
}
|
|
|
|
func ChangeJWTHeaderName(headerName string) func(*JWTIDPChangedEvent) {
|
|
return func(e *JWTIDPChangedEvent) {
|
|
e.HeaderName = &headerName
|
|
}
|
|
}
|
|
|
|
func ChangeJWTOptions(options OptionChanges) func(*JWTIDPChangedEvent) {
|
|
return func(e *JWTIDPChangedEvent) {
|
|
e.OptionChanges = options
|
|
}
|
|
}
|
|
|
|
func (e *JWTIDPChangedEvent) Payload() interface{} {
|
|
return e
|
|
}
|
|
|
|
func (e *JWTIDPChangedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func JWTIDPChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
|
e := &JWTIDPChangedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := event.Unmarshal(e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "IDP-D3gjzh", "unable to unmarshal event")
|
|
}
|
|
|
|
return e, nil
|
|
}
|