Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eventstore): sub queries #1805

Merged
merged 22 commits into from Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Expand Up @@ -23,10 +23,11 @@ We add the label "good first issue" for problems we think are a good starting po

If you like to contribute fork the ZITADEL repository. After you implemented the new feature create a PullRequest in the ZITADEL reposiotry.

Make sure you use semantic release.
feat: New Feature
fix: Bug Fix
docs: Documentation
Make sure you use semantic release:

* feat: New Feature
* fix: Bug Fix
* docs: Documentation

## Want to start ZITADEL?

Expand Down
23 changes: 14 additions & 9 deletions README.md
Expand Up @@ -42,14 +42,15 @@ For example, **ZITADEL** is event sourced but it does not rely on a pub/sub syst
### Self-Managed

You can run an automatically operated **ZITADEL** instance on a CNCF compliant Kubernetes cluster of your choice:
- [CRD Mode on an existing k8s cluster](https://docs.zitadel.ch/docs/guides/installation/crd)
- [GitOps Mode on an existing k8s cluster](https://docs.zitadel.ch/docs/guides/installation/gitops)
- [GitOps Mode on VM/bare-metal](https://docs.zitadel.ch/docs/guides/installation/managed-dedicated-instance) using [ORBOS](https://docs.zitadel.ch/docs/guides/installation/orbos)

* [CRD Mode on an existing k8s cluster](https://docs.zitadel.ch/docs/guides/installation/crd)
* [GitOps Mode on an existing k8s cluster](https://docs.zitadel.ch/docs/guides/installation/gitops)
* [GitOps Mode on VM/bare-metal](https://docs.zitadel.ch/docs/guides/installation/managed-dedicated-instance) using [ORBOS](https://docs.zitadel.ch/docs/guides/installation/orbos)

### CAOS-Managed

- **ZITADEL Cloud:** [**ZITADEL.ch**](https://zitadel.ch) is our shared cloud service hosted in Switzerland. [Get started](https://docs.zitadel.ch/docs/guides/usage/get-started) and try the free tier, including already unlimited users and all necessary security features.
- **ZITADEL Enterprise:** We operate and support a private instance of **ZITADEL** for you. [Get in touch!](https://zitadel.ch/contact/)
* **ZITADEL Cloud:** [**ZITADEL.ch**](https://zitadel.ch) is our shared cloud service hosted in Switzerland. [Get started](https://docs.zitadel.ch/docs/guides/usage/get-started) and try the free tier, including already unlimited users and all necessary security features.
* **ZITADEL Enterprise:** We operate and support a private instance of **ZITADEL** for you. [Get in touch!](https://zitadel.ch/contact/)

## Start using ZITADEL

Expand All @@ -58,6 +59,7 @@ You can run an automatically operated **ZITADEL** instance on a CNCF compliant K
See our [Documentation](https://docs.zitadel.ch/docs/quickstarts/introduction) to get started with ZITADEL quickly. Let us know, if you are missing a language or framework in the [Q&A](https://github.com/caos/zitadel/discussions/1717).

### Client libraries

* [Go](https://github.com/caos/zitadel-go) client library
* [.NET](https://github.com/caos/zitadel-net) client library
* [Dart](https://github.com/caos/zitadel-dart) client library
Expand All @@ -71,16 +73,19 @@ See our [Documentation](https://docs.zitadel.ch/docs/quickstarts/introduction) t
## Showcase

### Passwordless Login

Use our login widget to allow easy and sucure access to your applications and enjoy all the benefits of passwordless (FIDO 2 / WebAuthN):
- works on all modern platforms, devices, and browsers
- phishing resistant alternative
- requires only one gesture by the user
- easy [enrollment](https://docs.zitadel.ch/docs/manuals/user-factors) of the device during registration

* works on all modern platforms, devices, and browsers
* phishing resistant alternative
* requires only one gesture by the user
* easy [enrollment](https://docs.zitadel.ch/docs/manuals/user-factors) of the device during registration

![passwordless-windows-hello](https://user-images.githubusercontent.com/1366906/118765435-5d419780-b87b-11eb-95bf-55140119c0d8.gif)
![passwordless-iphone](https://user-images.githubusercontent.com/1366906/118765439-5fa3f180-b87b-11eb-937b-b4acb7854086.gif)

### Admin Console

Use [Console](https://docs.zitadel.ch/docs/manuals/introduction) or our [APIs](https://docs.zitadel.ch/docs/apis/introduction) to setup organizations, projects and applications.

Register new applications
Expand Down
15 changes: 8 additions & 7 deletions internal/command/existing_label_policies_model.go
Expand Up @@ -42,13 +42,14 @@ func (rm *ExistingLabelPoliciesReadModel) Reduce() error {
}

func (rm *ExistingLabelPoliciesReadModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(
eventstore.ColumnsEvent,
iam.AggregateType,
org.AggregateType).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
AddQuery().
AggregateTypes(iam.AggregateType).
EventTypes(iam.LabelPolicyAddedEventType).
Or().
AggregateTypes(org.AggregateType).
EventTypes(
iam.LabelPolicyAddedEventType,
org.LabelPolicyAddedEventType,
org.LabelPolicyRemovedEventType,
)
org.LabelPolicyRemovedEventType).
Builder()
}
9 changes: 6 additions & 3 deletions internal/command/iam_custom_login_text_model.go
Expand Up @@ -40,10 +40,13 @@ func (wm *IAMCustomLoginTextReadModel) Reduce() error {
}

func (wm *IAMCustomLoginTextReadModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.CustomLoginTextReadModel.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateIDs(wm.CustomLoginTextReadModel.AggregateID).
AggregateTypes(iam.AggregateType).
EventTypes(
iam.CustomTextSetEventType,
iam.CustomTextRemovedEventType)
iam.CustomTextRemovedEventType).
Builder()
}
10 changes: 6 additions & 4 deletions internal/command/iam_custom_message_text_model.go
Expand Up @@ -39,9 +39,11 @@ func (wm *IAMCustomMessageTextReadModel) Reduce() error {
}

func (wm *IAMCustomMessageTextReadModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.CustomMessageTextReadModel.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
EventTypes(
iam.CustomTextSetEventType)
AddQuery().
AggregateTypes(iam.AggregateType).
AggregateIDs(wm.CustomMessageTextReadModel.AggregateID).
EventTypes(iam.CustomTextSetEventType).
Builder()
}
9 changes: 6 additions & 3 deletions internal/command/iam_custom_text_model.go
Expand Up @@ -39,9 +39,12 @@ func (wm *IAMCustomTextWriteModel) Reduce() error {
}

func (wm *IAMCustomTextWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.CustomTextWriteModel.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateIDs(wm.CustomTextWriteModel.AggregateID).
AggregateTypes(iam.AggregateType).
EventTypes(
iam.CustomTextSetEventType)
iam.CustomTextSetEventType).
Builder()
}
8 changes: 5 additions & 3 deletions internal/command/iam_features_model.go
Expand Up @@ -43,10 +43,12 @@ func (wm *IAMFeaturesWriteModel) Reduce() error {
}

func (wm *IAMFeaturesWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.FeaturesWriteModel.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
EventTypes(iam.FeaturesSetEventType)
AddQuery().
EventTypes(iam.FeaturesSetEventType).
AggregateTypes(iam.AggregateType).
Builder()
}

func (wm *IAMFeaturesWriteModel) NewSetEvent(
Expand Down
11 changes: 7 additions & 4 deletions internal/command/iam_idp_config_model.go
Expand Up @@ -2,6 +2,7 @@ package command

import (
"context"

"github.com/caos/zitadel/internal/eventstore"

"github.com/caos/zitadel/internal/domain"
Expand All @@ -26,18 +27,20 @@ func NewIAMIDPConfigWriteModel(configID string) *IAMIDPConfigWriteModel {
}

func (wm *IAMIDPConfigWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateTypes(iam.AggregateType).
AggregateIDs(wm.AggregateID).
EventTypes(
iam.IDPConfigAddedEventType,
iam.IDPConfigChangedEventType,
iam.IDPConfigDeactivatedEventType,
iam.IDPConfigReactivatedEventType,
iam.IDPConfigRemovedEventType,
iam.IDPOIDCConfigAddedEventType,
iam.IDPOIDCConfigChangedEventType,
)
iam.IDPOIDCConfigChangedEventType).
Builder()
}

func (wm *IAMIDPConfigWriteModel) AppendEvents(events ...eventstore.EventReader) {
Expand Down
12 changes: 8 additions & 4 deletions internal/command/iam_idp_oidc_config_model.go
Expand Up @@ -2,9 +2,10 @@ package command

import (
"context"
"github.com/caos/zitadel/internal/eventstore"
"reflect"

"github.com/caos/zitadel/internal/eventstore"

"github.com/caos/zitadel/internal/crypto"
"github.com/caos/zitadel/internal/domain"
"github.com/caos/zitadel/internal/repository/iam"
Expand Down Expand Up @@ -69,15 +70,18 @@ func (wm *IAMIDPOIDCConfigWriteModel) Reduce() error {
}

func (wm *IAMIDPOIDCConfigWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateTypes(iam.AggregateType).
AggregateIDs(wm.AggregateID).
EventTypes(
iam.IDPOIDCConfigAddedEventType,
iam.IDPOIDCConfigChangedEventType,
iam.IDPConfigReactivatedEventType,
iam.IDPConfigDeactivatedEventType,
iam.IDPConfigRemovedEventType)
iam.IDPConfigRemovedEventType).
Builder()
}

func (wm *IAMIDPOIDCConfigWriteModel) NewChangedEvent(
Expand Down
9 changes: 6 additions & 3 deletions internal/command/iam_member_model.go
Expand Up @@ -54,12 +54,15 @@ func (wm *IAMMemberWriteModel) Reduce() error {
}

func (wm *IAMMemberWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.MemberWriteModel.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateTypes(iam.AggregateType).
AggregateIDs(wm.MemberWriteModel.AggregateID).
EventTypes(
iam.MemberAddedEventType,
iam.MemberChangedEventType,
iam.MemberRemovedEventType,
iam.MemberCascadeRemovedEventType)
iam.MemberCascadeRemovedEventType).
Builder()
}
9 changes: 6 additions & 3 deletions internal/command/iam_model.go
Expand Up @@ -44,14 +44,17 @@ func (wm *IAMWriteModel) Reduce() error {
}

func (wm *IAMWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateTypes(iam.AggregateType).
AggregateIDs(wm.AggregateID).
EventTypes(
iam.ProjectSetEventType,
iam.GlobalOrgSetEventType,
iam.SetupStartedEventType,
iam.SetupDoneEventType)
iam.SetupDoneEventType).
Builder()
}

func IAMAggregateFromWriteModel(wm *eventstore.WriteModel) *eventstore.Aggregate {
Expand Down
10 changes: 6 additions & 4 deletions internal/command/iam_policy_label_model.go
Expand Up @@ -62,9 +62,11 @@ func (wm *IAMLabelPolicyWriteModel) Reduce() error {
}

func (wm *IAMLabelPolicyWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.LabelPolicyWriteModel.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateTypes(iam.AggregateType).
AggregateIDs(wm.LabelPolicyWriteModel.AggregateID).
EventTypes(
iam.LabelPolicyAddedEventType,
iam.LabelPolicyChangedEventType,
Expand All @@ -77,8 +79,8 @@ func (wm *IAMLabelPolicyWriteModel) Query() *eventstore.SearchQueryBuilder {
iam.LabelPolicyIconDarkAddedEventType,
iam.LabelPolicyIconDarkRemovedEventType,
iam.LabelPolicyFontAddedEventType,
iam.LabelPolicyFontRemovedEventType,
)
iam.LabelPolicyFontRemovedEventType).
Builder()
}

func (wm *IAMLabelPolicyWriteModel) NewChangedEvent(
Expand Down
18 changes: 12 additions & 6 deletions internal/command/iam_policy_login_factors_model.go
Expand Up @@ -42,12 +42,15 @@ func (wm *IAMSecondFactorWriteModel) Reduce() error {
}

func (wm *IAMSecondFactorWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.WriteModel.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateTypes(iam.AggregateType).
AggregateIDs(wm.WriteModel.AggregateID).
EventTypes(
iam.LoginPolicySecondFactorAddedEventType,
iam.LoginPolicySecondFactorRemovedEventType)
iam.LoginPolicySecondFactorRemovedEventType).
Builder()
}

type IAMMultiFactorWriteModel struct {
Expand Down Expand Up @@ -86,10 +89,13 @@ func (wm *IAMMultiFactorWriteModel) Reduce() error {
}

func (wm *IAMMultiFactorWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.WriteModel.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateTypes(iam.AggregateType).
AggregateIDs(wm.WriteModel.AggregateID).
EventTypes(
iam.LoginPolicyMultiFactorAddedEventType,
iam.LoginPolicyMultiFactorRemovedEventType)
iam.LoginPolicyMultiFactorRemovedEventType).
Builder()
}
7 changes: 5 additions & 2 deletions internal/command/iam_policy_login_identity_provider_model.go
Expand Up @@ -44,7 +44,10 @@ func (wm *IAMIdentityProviderWriteModel) Reduce() error {
}

func (wm *IAMIdentityProviderWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateTypes(iam.AggregateType).
AggregateIDs(wm.AggregateID).
ResourceOwner(wm.ResourceOwner)
Builder()
}
10 changes: 7 additions & 3 deletions internal/command/iam_policy_login_model.go
Expand Up @@ -2,6 +2,7 @@ package command

import (
"context"

"github.com/caos/zitadel/internal/eventstore"

"github.com/caos/zitadel/internal/domain"
Expand Down Expand Up @@ -44,12 +45,15 @@ func (wm *IAMLoginPolicyWriteModel) Reduce() error {
}

func (wm *IAMLoginPolicyWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.LoginPolicyWriteModel.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateTypes(iam.AggregateType).
AggregateIDs(wm.LoginPolicyWriteModel.AggregateID).
EventTypes(
iam.LoginPolicyAddedEventType,
iam.LoginPolicyChangedEventType)
iam.LoginPolicyChangedEventType).
Builder()
}

func (wm *IAMLoginPolicyWriteModel) NewChangedEvent(
Expand Down
12 changes: 8 additions & 4 deletions internal/command/iam_policy_mail_template_model.go
Expand Up @@ -2,9 +2,10 @@ package command

import (
"context"
"github.com/caos/zitadel/internal/eventstore"
"reflect"

"github.com/caos/zitadel/internal/eventstore"

"github.com/caos/zitadel/internal/domain"
"github.com/caos/zitadel/internal/repository/iam"
"github.com/caos/zitadel/internal/repository/policy"
Expand Down Expand Up @@ -41,12 +42,15 @@ func (wm *IAMMailTemplateWriteModel) Reduce() error {
}

func (wm *IAMMailTemplateWriteModel) Query() *eventstore.SearchQueryBuilder {
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
AggregateIDs(wm.MailTemplateWriteModel.AggregateID).
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
ResourceOwner(wm.ResourceOwner).
AddQuery().
AggregateTypes(iam.AggregateType).
AggregateIDs(wm.MailTemplateWriteModel.AggregateID).
EventTypes(
iam.MailTemplateAddedEventType,
iam.MailTemplateChangedEventType)
iam.MailTemplateChangedEventType).
Builder()
}

func (wm *IAMMailTemplateWriteModel) NewChangedEvent(
Expand Down