mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-25 05:58:45 +00:00
feat(eventstore): increase parallel write capabilities (#5940)
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.
This commit is contained in:
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
caos_errs "github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/v1/models"
|
||||
"github.com/zitadel/zitadel/internal/project/model"
|
||||
"github.com/zitadel/zitadel/internal/repository/project"
|
||||
@@ -37,25 +36,25 @@ type ApplicationView struct {
|
||||
HasProjectCheck bool `json:"hasProjectCheck" gorm:"column:has_project_check"`
|
||||
PrivateLabelingSetting domain.PrivateLabelingSetting `json:"privateLabelingSetting" gorm:"column:private_labeling_setting"`
|
||||
|
||||
IsOIDC bool `json:"-" gorm:"column:is_oidc"`
|
||||
OIDCVersion int32 `json:"oidcVersion" gorm:"column:oidc_version"`
|
||||
OIDCClientID string `json:"clientId" gorm:"column:oidc_client_id"`
|
||||
OIDCRedirectUris database.StringArray `json:"redirectUris" gorm:"column:oidc_redirect_uris"`
|
||||
OIDCResponseTypes database.EnumArray[domain.OIDCResponseType] `json:"responseTypes" gorm:"column:oidc_response_types"`
|
||||
OIDCGrantTypes database.EnumArray[domain.OIDCGrantType] `json:"grantTypes" gorm:"column:oidc_grant_types"`
|
||||
OIDCApplicationType int32 `json:"applicationType" gorm:"column:oidc_application_type"`
|
||||
OIDCAuthMethodType int32 `json:"authMethodType" gorm:"column:oidc_auth_method_type"`
|
||||
OIDCPostLogoutRedirectUris database.StringArray `json:"postLogoutRedirectUris" gorm:"column:oidc_post_logout_redirect_uris"`
|
||||
NoneCompliant bool `json:"-" gorm:"column:none_compliant"`
|
||||
ComplianceProblems database.StringArray `json:"-" gorm:"column:compliance_problems"`
|
||||
DevMode bool `json:"devMode" gorm:"column:dev_mode"`
|
||||
OriginAllowList database.StringArray `json:"-" gorm:"column:origin_allow_list"`
|
||||
AdditionalOrigins database.StringArray `json:"additionalOrigins" gorm:"column:additional_origins"`
|
||||
AccessTokenType int32 `json:"accessTokenType" gorm:"column:access_token_type"`
|
||||
AccessTokenRoleAssertion bool `json:"accessTokenRoleAssertion" gorm:"column:access_token_role_assertion"`
|
||||
IDTokenRoleAssertion bool `json:"idTokenRoleAssertion" gorm:"column:id_token_role_assertion"`
|
||||
IDTokenUserinfoAssertion bool `json:"idTokenUserinfoAssertion" gorm:"column:id_token_userinfo_assertion"`
|
||||
ClockSkew time.Duration `json:"clockSkew" gorm:"column:clock_skew"`
|
||||
IsOIDC bool `json:"-" gorm:"column:is_oidc"`
|
||||
OIDCVersion int32 `json:"oidcVersion" gorm:"column:oidc_version"`
|
||||
OIDCClientID string `json:"clientId" gorm:"column:oidc_client_id"`
|
||||
OIDCRedirectUris database.TextArray[string] `json:"redirectUris" gorm:"column:oidc_redirect_uris"`
|
||||
OIDCResponseTypes database.Array[domain.OIDCResponseType] `json:"responseTypes" gorm:"column:oidc_response_types"`
|
||||
OIDCGrantTypes database.Array[domain.OIDCGrantType] `json:"grantTypes" gorm:"column:oidc_grant_types"`
|
||||
OIDCApplicationType int32 `json:"applicationType" gorm:"column:oidc_application_type"`
|
||||
OIDCAuthMethodType int32 `json:"authMethodType" gorm:"column:oidc_auth_method_type"`
|
||||
OIDCPostLogoutRedirectUris database.TextArray[string] `json:"postLogoutRedirectUris" gorm:"column:oidc_post_logout_redirect_uris"`
|
||||
NoneCompliant bool `json:"-" gorm:"column:none_compliant"`
|
||||
ComplianceProblems database.TextArray[string] `json:"-" gorm:"column:compliance_problems"`
|
||||
DevMode bool `json:"devMode" gorm:"column:dev_mode"`
|
||||
OriginAllowList database.TextArray[string] `json:"-" gorm:"column:origin_allow_list"`
|
||||
AdditionalOrigins database.TextArray[string] `json:"additionalOrigins" gorm:"column:additional_origins"`
|
||||
AccessTokenType int32 `json:"accessTokenType" gorm:"column:access_token_type"`
|
||||
AccessTokenRoleAssertion bool `json:"accessTokenRoleAssertion" gorm:"column:access_token_role_assertion"`
|
||||
IDTokenRoleAssertion bool `json:"idTokenRoleAssertion" gorm:"column:id_token_role_assertion"`
|
||||
IDTokenUserinfoAssertion bool `json:"idTokenUserinfoAssertion" gorm:"column:id_token_userinfo_assertion"`
|
||||
ClockSkew time.Duration `json:"clockSkew" gorm:"column:clock_skew"`
|
||||
|
||||
IsSAML bool `json:"-" gorm:"column:is_saml"`
|
||||
Metadata []byte `json:"metadata" gorm:"column:metadata"`
|
||||
@@ -82,7 +81,7 @@ func OIDCGrantTypesToModel(granttypes []domain.OIDCGrantType) []model.OIDCGrantT
|
||||
|
||||
func (a *ApplicationView) AppendEventIfMyApp(event *models.Event) (err error) {
|
||||
view := new(ApplicationView)
|
||||
switch eventstore.EventType(event.Type) {
|
||||
switch event.Type() {
|
||||
case project.ApplicationAddedType:
|
||||
err = view.SetData(event)
|
||||
if err != nil {
|
||||
@@ -120,9 +119,9 @@ func (a *ApplicationView) AppendEventIfMyApp(event *models.Event) (err error) {
|
||||
}
|
||||
|
||||
func (a *ApplicationView) AppendEvent(event *models.Event) (err error) {
|
||||
a.Sequence = event.Sequence
|
||||
a.Sequence = event.Seq
|
||||
a.ChangeDate = event.CreationDate
|
||||
switch eventstore.EventType(event.Type) {
|
||||
switch event.Type() {
|
||||
case project.ApplicationAddedType:
|
||||
a.setRootData(event)
|
||||
a.CreationDate = event.CreationDate
|
||||
@@ -180,7 +179,7 @@ func (a *ApplicationView) SetData(event *models.Event) error {
|
||||
}
|
||||
|
||||
func (a *ApplicationView) setOriginAllowList() error {
|
||||
allowList := make(database.StringArray, 0)
|
||||
allowList := make(database.TextArray[string], 0)
|
||||
for _, redirect := range a.OIDCRedirectUris {
|
||||
origin, err := http_util.GetOriginFromURLString(redirect)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user