mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 09:37:45 +00:00
chore: move the go code into a subfolder
This commit is contained in:
35
apps/api/internal/repository/org/aggregate.go
Normal file
35
apps/api/internal/repository/org/aggregate.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
)
|
||||
|
||||
const (
|
||||
orgEventTypePrefix = eventstore.EventType("org.")
|
||||
)
|
||||
|
||||
const (
|
||||
AggregateType = "org"
|
||||
AggregateVersion = "v1"
|
||||
)
|
||||
|
||||
type Aggregate struct {
|
||||
eventstore.Aggregate
|
||||
}
|
||||
|
||||
func NewAggregate(id string) *Aggregate {
|
||||
return &Aggregate{
|
||||
Aggregate: eventstore.Aggregate{
|
||||
Type: AggregateType,
|
||||
Version: AggregateVersion,
|
||||
ID: id,
|
||||
ResourceOwner: id,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func AggregateFromWriteModel(ctx context.Context, wm *eventstore.WriteModel) *eventstore.Aggregate {
|
||||
return eventstore.AggregateFromWriteModelCtx(ctx, wm, AggregateType, AggregateVersion)
|
||||
}
|
105
apps/api/internal/repository/org/custom_text.go
Normal file
105
apps/api/internal/repository/org/custom_text.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
CustomTextSetEventType = orgEventTypePrefix + policy.CustomTextSetEventType
|
||||
CustomTextRemovedEventType = orgEventTypePrefix + policy.CustomTextRemovedEventType
|
||||
CustomTextTemplateRemovedEventType = orgEventTypePrefix + policy.CustomTextTemplateRemovedEventType
|
||||
)
|
||||
|
||||
type CustomTextSetEvent struct {
|
||||
policy.CustomTextSetEvent
|
||||
}
|
||||
|
||||
func NewCustomTextSetEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
template,
|
||||
key,
|
||||
text string,
|
||||
language language.Tag,
|
||||
) *CustomTextSetEvent {
|
||||
return &CustomTextSetEvent{
|
||||
CustomTextSetEvent: *policy.NewCustomTextSetEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, CustomTextSetEventType),
|
||||
template,
|
||||
key,
|
||||
text,
|
||||
language),
|
||||
}
|
||||
}
|
||||
|
||||
func CustomTextSetEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.CustomTextSetEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &CustomTextSetEvent{CustomTextSetEvent: *e.(*policy.CustomTextSetEvent)}, nil
|
||||
}
|
||||
|
||||
type CustomTextRemovedEvent struct {
|
||||
policy.CustomTextRemovedEvent
|
||||
}
|
||||
|
||||
func NewCustomTextRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
template,
|
||||
key string,
|
||||
language language.Tag,
|
||||
) *CustomTextRemovedEvent {
|
||||
return &CustomTextRemovedEvent{
|
||||
CustomTextRemovedEvent: *policy.NewCustomTextRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, CustomTextRemovedEventType),
|
||||
template,
|
||||
key,
|
||||
language,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func CustomTextRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.CustomTextRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &CustomTextRemovedEvent{CustomTextRemovedEvent: *e.(*policy.CustomTextRemovedEvent)}, nil
|
||||
}
|
||||
|
||||
type CustomTextTemplateRemovedEvent struct {
|
||||
policy.CustomTextTemplateRemovedEvent
|
||||
}
|
||||
|
||||
func NewCustomTextTemplateRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
template string,
|
||||
language language.Tag,
|
||||
) *CustomTextTemplateRemovedEvent {
|
||||
return &CustomTextTemplateRemovedEvent{
|
||||
CustomTextTemplateRemovedEvent: *policy.NewCustomTextTemplateRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, CustomTextTemplateRemovedEventType),
|
||||
template,
|
||||
language,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func CustomTextTemplateRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.CustomTextTemplateRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &CustomTextTemplateRemovedEvent{CustomTextTemplateRemovedEvent: *e.(*policy.CustomTextTemplateRemovedEvent)}, nil
|
||||
}
|
348
apps/api/internal/repository/org/domain.go
Normal file
348
apps/api/internal/repository/org/domain.go
Normal file
@@ -0,0 +1,348 @@
|
||||
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/zerrors"
|
||||
)
|
||||
|
||||
const (
|
||||
UniqueOrgDomain = "org_domain"
|
||||
domainEventPrefix = orgEventTypePrefix + "domain."
|
||||
OrgDomainAddedEventType = domainEventPrefix + "added"
|
||||
OrgDomainVerificationAddedEventType = domainEventPrefix + "verification.added"
|
||||
OrgDomainVerificationFailedEventType = domainEventPrefix + "verification.failed"
|
||||
OrgDomainVerifiedEventType = domainEventPrefix + "verified"
|
||||
OrgDomainPrimarySetEventType = domainEventPrefix + "primary.set"
|
||||
OrgDomainRemovedEventType = domainEventPrefix + "removed"
|
||||
|
||||
OrgDomainSearchType = "org_domain"
|
||||
OrgDomainVerifiedSearchField = "verified"
|
||||
OrgDomainObjectRevision = uint8(1)
|
||||
)
|
||||
|
||||
func NewAddOrgDomainUniqueConstraint(orgDomain string) *eventstore.UniqueConstraint {
|
||||
return eventstore.NewAddEventUniqueConstraint(
|
||||
UniqueOrgDomain,
|
||||
orgDomain,
|
||||
"Errors.Org.Domain.AlreadyExists")
|
||||
}
|
||||
|
||||
func NewRemoveOrgDomainUniqueConstraint(orgDomain string) *eventstore.UniqueConstraint {
|
||||
return eventstore.NewRemoveUniqueConstraint(
|
||||
UniqueOrgDomain,
|
||||
orgDomain)
|
||||
}
|
||||
|
||||
type DomainAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Domain string `json:"domain,omitempty"`
|
||||
}
|
||||
|
||||
func (e *DomainAddedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *DomainAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *DomainAddedEvent) Fields() []*eventstore.FieldOperation {
|
||||
return []*eventstore.FieldOperation{
|
||||
eventstore.SetField(
|
||||
e.Aggregate(),
|
||||
domainSearchObject(e.Domain),
|
||||
OrgDomainVerifiedSearchField,
|
||||
&eventstore.Value{
|
||||
Value: false,
|
||||
ShouldIndex: false,
|
||||
},
|
||||
|
||||
eventstore.FieldTypeInstanceID,
|
||||
eventstore.FieldTypeResourceOwner,
|
||||
eventstore.FieldTypeAggregateType,
|
||||
eventstore.FieldTypeAggregateID,
|
||||
eventstore.FieldTypeObjectType,
|
||||
eventstore.FieldTypeObjectID,
|
||||
eventstore.FieldTypeFieldName,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewDomainAddedEvent(ctx context.Context, aggregate *eventstore.Aggregate, domain string) *DomainAddedEvent {
|
||||
return &DomainAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainAddedEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
}
|
||||
}
|
||||
|
||||
func DomainAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
orgDomainAdded := &DomainAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := event.Unmarshal(orgDomainAdded)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "ORG-GBr52", "unable to unmarshal org domain added")
|
||||
}
|
||||
|
||||
return orgDomainAdded, nil
|
||||
}
|
||||
|
||||
type DomainVerificationAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Domain string `json:"domain,omitempty"`
|
||||
ValidationType domain.OrgDomainValidationType `json:"validationType,omitempty"`
|
||||
ValidationCode *crypto.CryptoValue `json:"validationCode,omitempty"`
|
||||
}
|
||||
|
||||
func (e *DomainVerificationAddedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *DomainVerificationAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewDomainVerificationAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
domain string,
|
||||
validationType domain.OrgDomainValidationType,
|
||||
validationCode *crypto.CryptoValue) *DomainVerificationAddedEvent {
|
||||
return &DomainVerificationAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainVerificationAddedEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
ValidationType: validationType,
|
||||
ValidationCode: validationCode,
|
||||
}
|
||||
}
|
||||
|
||||
func DomainVerificationAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
orgDomainVerificationAdded := &DomainVerificationAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := event.Unmarshal(orgDomainVerificationAdded)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "ORG-NRN32", "unable to unmarshal org domain verification added")
|
||||
}
|
||||
|
||||
return orgDomainVerificationAdded, nil
|
||||
}
|
||||
|
||||
type DomainVerificationFailedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Domain string `json:"domain,omitempty"`
|
||||
}
|
||||
|
||||
func (e *DomainVerificationFailedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *DomainVerificationFailedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewDomainVerificationFailedEvent(ctx context.Context, aggregate *eventstore.Aggregate, domain string) *DomainVerificationFailedEvent {
|
||||
return &DomainVerificationFailedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainVerificationFailedEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
}
|
||||
}
|
||||
|
||||
func DomainVerificationFailedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
orgDomainVerificationFailed := &DomainVerificationFailedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := event.Unmarshal(orgDomainVerificationFailed)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "ORG-Bhm37", "unable to unmarshal org domain verification failed")
|
||||
}
|
||||
|
||||
return orgDomainVerificationFailed, nil
|
||||
}
|
||||
|
||||
type DomainVerifiedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Domain string `json:"domain,omitempty"`
|
||||
}
|
||||
|
||||
func (e *DomainVerifiedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *DomainVerifiedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return []*eventstore.UniqueConstraint{NewAddOrgDomainUniqueConstraint(e.Domain)}
|
||||
}
|
||||
|
||||
func (e *DomainVerifiedEvent) Fields() []*eventstore.FieldOperation {
|
||||
return []*eventstore.FieldOperation{
|
||||
eventstore.SetField(
|
||||
e.Aggregate(),
|
||||
domainSearchObject(e.Domain),
|
||||
OrgDomainVerifiedSearchField,
|
||||
&eventstore.Value{
|
||||
Value: true,
|
||||
ShouldIndex: false,
|
||||
},
|
||||
|
||||
eventstore.FieldTypeInstanceID,
|
||||
eventstore.FieldTypeResourceOwner,
|
||||
eventstore.FieldTypeAggregateType,
|
||||
eventstore.FieldTypeAggregateID,
|
||||
eventstore.FieldTypeObjectType,
|
||||
eventstore.FieldTypeObjectID,
|
||||
eventstore.FieldTypeFieldName,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewDomainVerifiedEvent(ctx context.Context, aggregate *eventstore.Aggregate, domain string) *DomainVerifiedEvent {
|
||||
return &DomainVerifiedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainVerifiedEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
}
|
||||
}
|
||||
|
||||
func DomainVerifiedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
orgDomainVerified := &DomainVerifiedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := event.Unmarshal(orgDomainVerified)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "ORG-BFSwt", "unable to unmarshal org domain verified")
|
||||
}
|
||||
|
||||
return orgDomainVerified, nil
|
||||
}
|
||||
|
||||
type DomainPrimarySetEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Domain string `json:"domain,omitempty"`
|
||||
}
|
||||
|
||||
func (e *DomainPrimarySetEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *DomainPrimarySetEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewDomainPrimarySetEvent(ctx context.Context, aggregate *eventstore.Aggregate, domain string) *DomainPrimarySetEvent {
|
||||
return &DomainPrimarySetEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainPrimarySetEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
}
|
||||
}
|
||||
|
||||
func DomainPrimarySetEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
orgDomainPrimarySet := &DomainPrimarySetEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := event.Unmarshal(orgDomainPrimarySet)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "ORG-N5787", "unable to unmarshal org domain primary set")
|
||||
}
|
||||
|
||||
return orgDomainPrimarySet, nil
|
||||
}
|
||||
|
||||
type DomainRemovedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Domain string `json:"domain,omitempty"`
|
||||
isVerified bool
|
||||
}
|
||||
|
||||
func (e *DomainRemovedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *DomainRemovedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
if !e.isVerified {
|
||||
return nil
|
||||
}
|
||||
return []*eventstore.UniqueConstraint{NewRemoveOrgDomainUniqueConstraint(e.Domain)}
|
||||
}
|
||||
|
||||
func (e *DomainRemovedEvent) Fields() []*eventstore.FieldOperation {
|
||||
return []*eventstore.FieldOperation{
|
||||
eventstore.SetField(
|
||||
e.Aggregate(),
|
||||
domainSearchObject(e.Domain),
|
||||
OrgDomainVerifiedSearchField,
|
||||
&eventstore.Value{
|
||||
Value: false,
|
||||
ShouldIndex: false,
|
||||
},
|
||||
|
||||
eventstore.FieldTypeInstanceID,
|
||||
eventstore.FieldTypeResourceOwner,
|
||||
eventstore.FieldTypeAggregateType,
|
||||
eventstore.FieldTypeAggregateID,
|
||||
eventstore.FieldTypeObjectType,
|
||||
eventstore.FieldTypeObjectID,
|
||||
eventstore.FieldTypeFieldName,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewDomainRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate, domain string, verified bool) *DomainRemovedEvent {
|
||||
return &DomainRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDomainRemovedEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
isVerified: verified,
|
||||
}
|
||||
}
|
||||
|
||||
func DomainRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
orgDomainRemoved := &DomainRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := event.Unmarshal(orgDomainRemoved)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "ORG-BngB2", "unable to unmarshal org domain removed")
|
||||
}
|
||||
|
||||
return orgDomainRemoved, nil
|
||||
}
|
||||
|
||||
func domainSearchObject(domain string) eventstore.Object {
|
||||
return eventstore.Object{
|
||||
Type: OrgDomainSearchType,
|
||||
ID: domain,
|
||||
Revision: OrgDomainObjectRevision,
|
||||
}
|
||||
}
|
118
apps/api/internal/repository/org/eventstore.go
Normal file
118
apps/api/internal/repository/org/eventstore.go
Normal file
@@ -0,0 +1,118 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
)
|
||||
|
||||
func init() {
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OrgAddedEventType, OrgAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OrgChangedEventType, OrgChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OrgDeactivatedEventType, OrgDeactivatedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OrgReactivatedEventType, OrgReactivatedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OrgRemovedEventType, OrgRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainAddedEventType, DomainAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainVerificationAddedEventType, DomainVerificationAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainVerificationFailedEventType, DomainVerificationFailedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainVerifiedEventType, DomainVerifiedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainPrimarySetEventType, DomainPrimarySetEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OrgDomainRemovedEventType, DomainRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MemberAddedEventType, MemberAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MemberChangedEventType, MemberChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MemberRemovedEventType, MemberRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MemberCascadeRemovedEventType, MemberCascadeRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyAddedEventType, LabelPolicyAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyChangedEventType, LabelPolicyChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyActivatedEventType, LabelPolicyActivatedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyRemovedEventType, LabelPolicyRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoAddedEventType, LabelPolicyLogoAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoRemovedEventType, LabelPolicyLogoRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconAddedEventType, LabelPolicyIconAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconRemovedEventType, LabelPolicyIconRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoDarkAddedEventType, LabelPolicyLogoDarkAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyLogoDarkRemovedEventType, LabelPolicyLogoDarkRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconDarkAddedEventType, LabelPolicyIconDarkAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyIconDarkRemovedEventType, LabelPolicyIconDarkRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyFontAddedEventType, LabelPolicyFontAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyFontRemovedEventType, LabelPolicyFontRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LabelPolicyAssetsRemovedEventType, LabelPolicyAssetsRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyAddedEventType, LoginPolicyAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyChangedEventType, LoginPolicyChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyRemovedEventType, LoginPolicyRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicySecondFactorAddedEventType, SecondFactorAddedEventEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicySecondFactorRemovedEventType, SecondFactorRemovedEventEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyMultiFactorAddedEventType, MultiFactorAddedEventEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyMultiFactorRemovedEventType, MultiFactorRemovedEventEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderAddedEventType, IdentityProviderAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderRemovedEventType, IdentityProviderRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderCascadeRemovedEventType, IdentityProviderCascadeRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, DomainPolicyAddedEventType, DomainPolicyAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, DomainPolicyChangedEventType, DomainPolicyChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, DomainPolicyRemovedEventType, DomainPolicyRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, PasswordAgePolicyAddedEventType, PasswordAgePolicyAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, PasswordAgePolicyChangedEventType, PasswordAgePolicyChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, PasswordAgePolicyRemovedEventType, PasswordAgePolicyRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyAddedEventType, PasswordComplexityPolicyAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyChangedEventType, PasswordComplexityPolicyChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, PasswordComplexityPolicyRemovedEventType, PasswordComplexityPolicyRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LockoutPolicyAddedEventType, LockoutPolicyAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LockoutPolicyChangedEventType, LockoutPolicyChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LockoutPolicyRemovedEventType, LockoutPolicyRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, PrivacyPolicyAddedEventType, PrivacyPolicyAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, PrivacyPolicyChangedEventType, PrivacyPolicyChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, PrivacyPolicyRemovedEventType, PrivacyPolicyRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MailTemplateAddedEventType, MailTemplateAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MailTemplateChangedEventType, MailTemplateChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MailTemplateRemovedEventType, MailTemplateRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MailTextAddedEventType, MailTextAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MailTextChangedEventType, MailTextChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MailTextRemovedEventType, MailTextRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, CustomTextSetEventType, CustomTextSetEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, CustomTextRemovedEventType, CustomTextRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, CustomTextTemplateRemovedEventType, CustomTextTemplateRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigAddedEventType, IDPConfigAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigChangedEventType, IDPConfigChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigRemovedEventType, IDPConfigRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigDeactivatedEventType, IDPConfigDeactivatedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, IDPConfigReactivatedEventType, IDPConfigReactivatedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, IDPOIDCConfigAddedEventType, IDPOIDCConfigAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, IDPOIDCConfigChangedEventType, IDPOIDCConfigChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, IDPJWTConfigAddedEventType, IDPJWTConfigAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, IDPJWTConfigChangedEventType, IDPJWTConfigChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OAuthIDPAddedEventType, OAuthIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OAuthIDPChangedEventType, OAuthIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPAddedEventType, OIDCIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPChangedEventType, OIDCIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPMigratedAzureADEventType, OIDCIDPMigratedAzureADEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, OIDCIDPMigratedGoogleEventType, OIDCIDPMigratedGoogleEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, JWTIDPAddedEventType, JWTIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, JWTIDPChangedEventType, JWTIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, AzureADIDPAddedEventType, AzureADIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, AzureADIDPChangedEventType, AzureADIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, GitHubIDPAddedEventType, GitHubIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, GitHubIDPChangedEventType, GitHubIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, GitHubEnterpriseIDPAddedEventType, GitHubEnterpriseIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, GitHubEnterpriseIDPChangedEventType, GitHubEnterpriseIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, GitLabIDPAddedEventType, GitLabIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, GitLabIDPChangedEventType, GitLabIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, GitLabSelfHostedIDPAddedEventType, GitLabSelfHostedIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, GitLabSelfHostedIDPChangedEventType, GitLabSelfHostedIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, GoogleIDPAddedEventType, GoogleIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, GoogleIDPChangedEventType, GoogleIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LDAPIDPAddedEventType, LDAPIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LDAPIDPChangedEventType, LDAPIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, AppleIDPAddedEventType, AppleIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, AppleIDPChangedEventType, AppleIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, SAMLIDPAddedEventType, SAMLIDPAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, SAMLIDPChangedEventType, SAMLIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, IDPRemovedEventType, IDPRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, TriggerActionsSetEventType, TriggerActionsSetEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, TriggerActionsCascadeRemovedEventType, TriggerActionsCascadeRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, FlowClearedEventType, FlowClearedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MetadataSetType, MetadataSetEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MetadataRemovedType, MetadataRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, MetadataRemovedAllType, MetadataRemovedAllEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, NotificationPolicyAddedEventType, NotificationPolicyAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, NotificationPolicyChangedEventType, NotificationPolicyChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, NotificationPolicyRemovedEventType, NotificationPolicyRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, HostedLoginTranslationSet, HostedLoginTranslationSetEventMapper)
|
||||
}
|
105
apps/api/internal/repository/org/flow.go
Normal file
105
apps/api/internal/repository/org/flow.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/flow"
|
||||
)
|
||||
|
||||
var (
|
||||
TriggerActionsSetEventType = orgEventTypePrefix + flow.TriggerActionsSetEventType
|
||||
TriggerActionsCascadeRemovedEventType = orgEventTypePrefix + flow.TriggerActionsCascadeRemovedEventType
|
||||
FlowClearedEventType = orgEventTypePrefix + flow.FlowClearedEventType
|
||||
)
|
||||
|
||||
type TriggerActionsSetEvent struct {
|
||||
flow.TriggerActionsSetEvent
|
||||
}
|
||||
|
||||
func NewTriggerActionsSetEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
flowType domain.FlowType,
|
||||
triggerType domain.TriggerType,
|
||||
actionIDs []string,
|
||||
) *TriggerActionsSetEvent {
|
||||
return &TriggerActionsSetEvent{
|
||||
TriggerActionsSetEvent: *flow.NewTriggerActionsSetEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
TriggerActionsSetEventType),
|
||||
flowType,
|
||||
triggerType,
|
||||
actionIDs),
|
||||
}
|
||||
}
|
||||
|
||||
func TriggerActionsSetEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := flow.TriggerActionsSetEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &TriggerActionsSetEvent{TriggerActionsSetEvent: *e.(*flow.TriggerActionsSetEvent)}, nil
|
||||
}
|
||||
|
||||
type TriggerActionsCascadeRemovedEvent struct {
|
||||
flow.TriggerActionsCascadeRemovedEvent
|
||||
}
|
||||
|
||||
func NewTriggerActionsCascadeRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
flowType domain.FlowType,
|
||||
actionID string,
|
||||
) *TriggerActionsCascadeRemovedEvent {
|
||||
return &TriggerActionsCascadeRemovedEvent{
|
||||
TriggerActionsCascadeRemovedEvent: *flow.NewTriggerActionsCascadeRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
TriggerActionsCascadeRemovedEventType),
|
||||
flowType,
|
||||
actionID),
|
||||
}
|
||||
}
|
||||
|
||||
func TriggerActionsCascadeRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := flow.TriggerActionsCascadeRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &TriggerActionsCascadeRemovedEvent{TriggerActionsCascadeRemovedEvent: *e.(*flow.TriggerActionsCascadeRemovedEvent)}, nil
|
||||
}
|
||||
|
||||
type FlowClearedEvent struct {
|
||||
flow.FlowClearedEvent
|
||||
}
|
||||
|
||||
func NewFlowClearedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
flowType domain.FlowType,
|
||||
) *FlowClearedEvent {
|
||||
return &FlowClearedEvent{
|
||||
FlowClearedEvent: *flow.NewFlowClearedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
FlowClearedEventType),
|
||||
flowType),
|
||||
}
|
||||
}
|
||||
|
||||
func FlowClearedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := flow.FlowClearedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &FlowClearedEvent{FlowClearedEvent: *e.(*flow.FlowClearedEvent)}, nil
|
||||
}
|
55
apps/api/internal/repository/org/hosted_login_translation.go
Normal file
55
apps/api/internal/repository/org/hosted_login_translation.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
const (
|
||||
HostedLoginTranslationSet = orgEventTypePrefix + "hosted_login_translation.set"
|
||||
)
|
||||
|
||||
type HostedLoginTranslationSetEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Translation map[string]any `json:"translation,omitempty"`
|
||||
Language language.Tag `json:"language,omitempty"`
|
||||
Level string `json:"level,omitempty"`
|
||||
}
|
||||
|
||||
func NewHostedLoginTranslationSetEvent(ctx context.Context, aggregate *eventstore.Aggregate, translation map[string]any, language language.Tag) *HostedLoginTranslationSetEvent {
|
||||
return &HostedLoginTranslationSetEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(ctx, aggregate, HostedLoginTranslationSet),
|
||||
Translation: translation,
|
||||
Language: language,
|
||||
Level: string(aggregate.Type),
|
||||
}
|
||||
}
|
||||
|
||||
func (e *HostedLoginTranslationSetEvent) Payload() any {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *HostedLoginTranslationSetEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *HostedLoginTranslationSetEvent) Fields() []*eventstore.FieldOperation {
|
||||
return nil
|
||||
}
|
||||
|
||||
func HostedLoginTranslationSetEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
translationSet := &HostedLoginTranslationSetEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := event.Unmarshal(translationSet)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "ORG-BH82Eb", "unable to unmarshal hosted login translation set event")
|
||||
}
|
||||
|
||||
return translationSet, nil
|
||||
}
|
1129
apps/api/internal/repository/org/idp.go
Normal file
1129
apps/api/internal/repository/org/idp.go
Normal file
File diff suppressed because it is too large
Load Diff
185
apps/api/internal/repository/org/idp_config.go
Normal file
185
apps/api/internal/repository/org/idp_config.go
Normal file
@@ -0,0 +1,185 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/idpconfig"
|
||||
)
|
||||
|
||||
const (
|
||||
IDPConfigAddedEventType eventstore.EventType = "org.idp.config.added"
|
||||
IDPConfigChangedEventType eventstore.EventType = "org.idp.config.changed"
|
||||
IDPConfigRemovedEventType eventstore.EventType = "org.idp.config.removed"
|
||||
IDPConfigDeactivatedEventType eventstore.EventType = "org.idp.config.deactivated"
|
||||
IDPConfigReactivatedEventType eventstore.EventType = "org.idp.config.reactivated"
|
||||
)
|
||||
|
||||
type IDPConfigAddedEvent struct {
|
||||
idpconfig.IDPConfigAddedEvent
|
||||
}
|
||||
|
||||
func NewIDPConfigAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID,
|
||||
name string,
|
||||
configType domain.IDPConfigType,
|
||||
stylingType domain.IDPConfigStylingType,
|
||||
autoRegister bool,
|
||||
) *IDPConfigAddedEvent {
|
||||
|
||||
return &IDPConfigAddedEvent{
|
||||
IDPConfigAddedEvent: *idpconfig.NewIDPConfigAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigAddedEventType,
|
||||
),
|
||||
configID,
|
||||
name,
|
||||
configType,
|
||||
stylingType,
|
||||
autoRegister,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func IDPConfigAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := idpconfig.IDPConfigAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IDPConfigAddedEvent{IDPConfigAddedEvent: *e.(*idpconfig.IDPConfigAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type IDPConfigChangedEvent struct {
|
||||
idpconfig.IDPConfigChangedEvent
|
||||
}
|
||||
|
||||
func NewIDPConfigChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID,
|
||||
oldName string,
|
||||
changes []idpconfig.IDPConfigChanges,
|
||||
) (*IDPConfigChangedEvent, error) {
|
||||
changeEvent, err := idpconfig.NewIDPConfigChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx,
|
||||
aggregate,
|
||||
IDPConfigChangedEventType),
|
||||
configID,
|
||||
oldName,
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &IDPConfigChangedEvent{IDPConfigChangedEvent: *changeEvent}, nil
|
||||
}
|
||||
|
||||
func IDPConfigChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := idpconfig.IDPConfigChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IDPConfigChangedEvent{IDPConfigChangedEvent: *e.(*idpconfig.IDPConfigChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type IDPConfigRemovedEvent struct {
|
||||
idpconfig.IDPConfigRemovedEvent
|
||||
}
|
||||
|
||||
func NewIDPConfigRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID,
|
||||
name string,
|
||||
) *IDPConfigRemovedEvent {
|
||||
|
||||
return &IDPConfigRemovedEvent{
|
||||
IDPConfigRemovedEvent: *idpconfig.NewIDPConfigRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigRemovedEventType,
|
||||
),
|
||||
configID,
|
||||
name,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func IDPConfigRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := idpconfig.IDPConfigRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IDPConfigRemovedEvent{IDPConfigRemovedEvent: *e.(*idpconfig.IDPConfigRemovedEvent)}, nil
|
||||
}
|
||||
|
||||
type IDPConfigDeactivatedEvent struct {
|
||||
idpconfig.IDPConfigDeactivatedEvent
|
||||
}
|
||||
|
||||
func NewIDPConfigDeactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID string,
|
||||
) *IDPConfigDeactivatedEvent {
|
||||
|
||||
return &IDPConfigDeactivatedEvent{
|
||||
IDPConfigDeactivatedEvent: *idpconfig.NewIDPConfigDeactivatedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigDeactivatedEventType,
|
||||
),
|
||||
configID,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func IDPConfigDeactivatedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := idpconfig.IDPConfigDeactivatedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IDPConfigDeactivatedEvent{IDPConfigDeactivatedEvent: *e.(*idpconfig.IDPConfigDeactivatedEvent)}, nil
|
||||
}
|
||||
|
||||
type IDPConfigReactivatedEvent struct {
|
||||
idpconfig.IDPConfigReactivatedEvent
|
||||
}
|
||||
|
||||
func NewIDPConfigReactivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
configID string,
|
||||
) *IDPConfigReactivatedEvent {
|
||||
|
||||
return &IDPConfigReactivatedEvent{
|
||||
IDPConfigReactivatedEvent: *idpconfig.NewIDPConfigReactivatedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPConfigReactivatedEventType,
|
||||
),
|
||||
configID,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func IDPConfigReactivatedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := idpconfig.IDPConfigReactivatedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IDPConfigReactivatedEvent{IDPConfigReactivatedEvent: *e.(*idpconfig.IDPConfigReactivatedEvent)}, nil
|
||||
}
|
85
apps/api/internal/repository/org/idp_jwt_config.go
Normal file
85
apps/api/internal/repository/org/idp_jwt_config.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/idpconfig"
|
||||
)
|
||||
|
||||
const (
|
||||
IDPJWTConfigAddedEventType eventstore.EventType = "org.idp." + idpconfig.JWTConfigAddedEventType
|
||||
IDPJWTConfigChangedEventType eventstore.EventType = "org.idp." + idpconfig.JWTConfigChangedEventType
|
||||
)
|
||||
|
||||
type IDPJWTConfigAddedEvent struct {
|
||||
idpconfig.JWTConfigAddedEvent
|
||||
}
|
||||
|
||||
func NewIDPJWTConfigAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID,
|
||||
jwtEndpoint,
|
||||
issuer,
|
||||
keysEndpoint,
|
||||
headerName string,
|
||||
) *IDPJWTConfigAddedEvent {
|
||||
|
||||
return &IDPJWTConfigAddedEvent{
|
||||
JWTConfigAddedEvent: *idpconfig.NewJWTConfigAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPJWTConfigAddedEventType,
|
||||
),
|
||||
idpConfigID,
|
||||
jwtEndpoint,
|
||||
issuer,
|
||||
keysEndpoint,
|
||||
headerName,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func IDPJWTConfigAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := idpconfig.JWTConfigAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IDPJWTConfigAddedEvent{JWTConfigAddedEvent: *e.(*idpconfig.JWTConfigAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type IDPJWTConfigChangedEvent struct {
|
||||
idpconfig.JWTConfigChangedEvent
|
||||
}
|
||||
|
||||
func NewIDPJWTConfigChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
changes []idpconfig.JWTConfigChanges,
|
||||
) (*IDPJWTConfigChangedEvent, error) {
|
||||
changeEvent, err := idpconfig.NewJWTConfigChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
IDPJWTConfigChangedEventType),
|
||||
idpConfigID,
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &IDPJWTConfigChangedEvent{JWTConfigChangedEvent: *changeEvent}, nil
|
||||
}
|
||||
|
||||
func IDPJWTConfigChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := idpconfig.JWTConfigChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IDPJWTConfigChangedEvent{JWTConfigChangedEvent: *e.(*idpconfig.JWTConfigChangedEvent)}, nil
|
||||
}
|
95
apps/api/internal/repository/org/idp_oidc_config.go
Normal file
95
apps/api/internal/repository/org/idp_oidc_config.go
Normal file
@@ -0,0 +1,95 @@
|
||||
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
|
||||
}
|
160
apps/api/internal/repository/org/member.go
Normal file
160
apps/api/internal/repository/org/member.go
Normal file
@@ -0,0 +1,160 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/member"
|
||||
)
|
||||
|
||||
const (
|
||||
MemberAddedEventType = orgEventTypePrefix + member.AddedEventType
|
||||
MemberChangedEventType = orgEventTypePrefix + member.ChangedEventType
|
||||
MemberRemovedEventType = orgEventTypePrefix + member.RemovedEventType
|
||||
MemberCascadeRemovedEventType = orgEventTypePrefix + member.CascadeRemovedEventType
|
||||
)
|
||||
|
||||
const (
|
||||
fieldPrefix = "org"
|
||||
)
|
||||
|
||||
type MemberAddedEvent struct {
|
||||
member.MemberAddedEvent
|
||||
}
|
||||
|
||||
func (e *MemberAddedEvent) Fields() []*eventstore.FieldOperation {
|
||||
return e.FieldOperations(fieldPrefix)
|
||||
}
|
||||
|
||||
func NewMemberAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
roles ...string,
|
||||
) *MemberAddedEvent {
|
||||
return &MemberAddedEvent{
|
||||
MemberAddedEvent: *member.NewMemberAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberAddedEventType,
|
||||
),
|
||||
userID,
|
||||
roles...,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func MemberAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := member.MemberAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MemberAddedEvent{MemberAddedEvent: *e.(*member.MemberAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type MemberChangedEvent struct {
|
||||
member.MemberChangedEvent
|
||||
}
|
||||
|
||||
func (e *MemberChangedEvent) Fields() []*eventstore.FieldOperation {
|
||||
return e.FieldOperations(fieldPrefix)
|
||||
}
|
||||
|
||||
func NewMemberChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
roles ...string,
|
||||
) *MemberChangedEvent {
|
||||
|
||||
return &MemberChangedEvent{
|
||||
MemberChangedEvent: *member.NewMemberChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberChangedEventType,
|
||||
),
|
||||
userID,
|
||||
roles...,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func MemberChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := member.ChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MemberChangedEvent{MemberChangedEvent: *e.(*member.MemberChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type MemberRemovedEvent struct {
|
||||
member.MemberRemovedEvent
|
||||
}
|
||||
|
||||
func (e *MemberRemovedEvent) Fields() []*eventstore.FieldOperation {
|
||||
return e.FieldOperations(fieldPrefix)
|
||||
}
|
||||
|
||||
func NewMemberRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
) *MemberRemovedEvent {
|
||||
return &MemberRemovedEvent{
|
||||
MemberRemovedEvent: *member.NewRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberRemovedEventType,
|
||||
),
|
||||
userID,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func MemberRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := member.RemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MemberRemovedEvent{MemberRemovedEvent: *e.(*member.MemberRemovedEvent)}, nil
|
||||
}
|
||||
|
||||
type MemberCascadeRemovedEvent struct {
|
||||
member.MemberCascadeRemovedEvent
|
||||
}
|
||||
|
||||
func (e *MemberCascadeRemovedEvent) Fields() []*eventstore.FieldOperation {
|
||||
return e.FieldOperations(fieldPrefix)
|
||||
}
|
||||
|
||||
func NewMemberCascadeRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userID string,
|
||||
) *MemberCascadeRemovedEvent {
|
||||
return &MemberCascadeRemovedEvent{
|
||||
MemberCascadeRemovedEvent: *member.NewCascadeRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MemberCascadeRemovedEventType,
|
||||
),
|
||||
userID,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func MemberCascadeRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := member.CascadeRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MemberCascadeRemovedEvent{MemberCascadeRemovedEvent: *e.(*member.MemberCascadeRemovedEvent)}, nil
|
||||
}
|
87
apps/api/internal/repository/org/metadata.go
Normal file
87
apps/api/internal/repository/org/metadata.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/metadata"
|
||||
)
|
||||
|
||||
const (
|
||||
MetadataSetType = orgEventTypePrefix + metadata.SetEventType
|
||||
MetadataRemovedType = orgEventTypePrefix + metadata.RemovedEventType
|
||||
MetadataRemovedAllType = orgEventTypePrefix + metadata.RemovedAllEventType
|
||||
)
|
||||
|
||||
type MetadataSetEvent struct {
|
||||
metadata.SetEvent
|
||||
}
|
||||
|
||||
func NewMetadataSetEvent(ctx context.Context, aggregate *eventstore.Aggregate, key string, value []byte) *MetadataSetEvent {
|
||||
return &MetadataSetEvent{
|
||||
SetEvent: *metadata.NewSetEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MetadataSetType),
|
||||
key,
|
||||
value),
|
||||
}
|
||||
}
|
||||
|
||||
func MetadataSetEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := metadata.SetEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MetadataSetEvent{SetEvent: *e.(*metadata.SetEvent)}, nil
|
||||
}
|
||||
|
||||
type MetadataRemovedEvent struct {
|
||||
metadata.RemovedEvent
|
||||
}
|
||||
|
||||
func NewMetadataRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate, key string) *MetadataRemovedEvent {
|
||||
return &MetadataRemovedEvent{
|
||||
RemovedEvent: *metadata.NewRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MetadataRemovedType),
|
||||
key),
|
||||
}
|
||||
}
|
||||
|
||||
func MetadataRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := metadata.RemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MetadataRemovedEvent{RemovedEvent: *e.(*metadata.RemovedEvent)}, nil
|
||||
}
|
||||
|
||||
type MetadataRemovedAllEvent struct {
|
||||
metadata.RemovedAllEvent
|
||||
}
|
||||
|
||||
func NewMetadataRemovedAllEvent(ctx context.Context, aggregate *eventstore.Aggregate) *MetadataRemovedAllEvent {
|
||||
return &MetadataRemovedAllEvent{
|
||||
RemovedAllEvent: *metadata.NewRemovedAllEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
MetadataRemovedAllType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func MetadataRemovedAllEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := metadata.RemovedAllEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MetadataRemovedAllEvent{RemovedAllEvent: *e.(*metadata.RemovedAllEvent)}, nil
|
||||
}
|
345
apps/api/internal/repository/org/org.go
Normal file
345
apps/api/internal/repository/org/org.go
Normal file
@@ -0,0 +1,345 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/project"
|
||||
"github.com/zitadel/zitadel/internal/repository/user"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
const (
|
||||
uniqueOrgname = "org_name"
|
||||
OrgAddedEventType = orgEventTypePrefix + "added"
|
||||
OrgChangedEventType = orgEventTypePrefix + "changed"
|
||||
OrgDeactivatedEventType = orgEventTypePrefix + "deactivated"
|
||||
OrgReactivatedEventType = orgEventTypePrefix + "reactivated"
|
||||
OrgRemovedEventType = orgEventTypePrefix + "removed"
|
||||
|
||||
OrgSearchType = "org"
|
||||
OrgNameSearchField = "name"
|
||||
OrgStateSearchField = "state"
|
||||
)
|
||||
|
||||
func NewAddOrgNameUniqueConstraint(orgName string) *eventstore.UniqueConstraint {
|
||||
return eventstore.NewAddEventUniqueConstraint(
|
||||
uniqueOrgname,
|
||||
orgName,
|
||||
"Errors.Org.AlreadyExists")
|
||||
}
|
||||
|
||||
func NewRemoveOrgNameUniqueConstraint(orgName string) *eventstore.UniqueConstraint {
|
||||
return eventstore.NewRemoveUniqueConstraint(
|
||||
uniqueOrgname,
|
||||
orgName)
|
||||
}
|
||||
|
||||
type OrgAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
func (e *OrgAddedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *OrgAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return []*eventstore.UniqueConstraint{NewAddOrgNameUniqueConstraint(e.Name)}
|
||||
}
|
||||
|
||||
func (e *OrgAddedEvent) Fields() []*eventstore.FieldOperation {
|
||||
return []*eventstore.FieldOperation{
|
||||
eventstore.SetField(
|
||||
e.Aggregate(),
|
||||
orgSearchObject(e.Aggregate().ID),
|
||||
OrgNameSearchField,
|
||||
&eventstore.Value{
|
||||
Value: e.Name,
|
||||
ShouldIndex: true,
|
||||
},
|
||||
eventstore.FieldTypeInstanceID,
|
||||
eventstore.FieldTypeResourceOwner,
|
||||
eventstore.FieldTypeAggregateType,
|
||||
eventstore.FieldTypeAggregateID,
|
||||
eventstore.FieldTypeObjectType,
|
||||
eventstore.FieldTypeObjectID,
|
||||
eventstore.FieldTypeFieldName,
|
||||
),
|
||||
eventstore.SetField(
|
||||
e.Aggregate(),
|
||||
orgSearchObject(e.Aggregate().ID),
|
||||
OrgStateSearchField,
|
||||
&eventstore.Value{
|
||||
Value: domain.OrgStateActive,
|
||||
ShouldIndex: true,
|
||||
},
|
||||
eventstore.FieldTypeInstanceID,
|
||||
eventstore.FieldTypeResourceOwner,
|
||||
eventstore.FieldTypeAggregateType,
|
||||
eventstore.FieldTypeAggregateID,
|
||||
eventstore.FieldTypeObjectType,
|
||||
eventstore.FieldTypeObjectID,
|
||||
eventstore.FieldTypeFieldName,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewOrgAddedEvent(ctx context.Context, aggregate *eventstore.Aggregate, name string) *OrgAddedEvent {
|
||||
return &OrgAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgAddedEventType,
|
||||
),
|
||||
Name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func OrgAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
orgAdded := &OrgAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := event.Unmarshal(orgAdded)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "ORG-Bren2", "unable to unmarshal org added")
|
||||
}
|
||||
|
||||
return orgAdded, nil
|
||||
}
|
||||
|
||||
type OrgChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
oldName string `json:"-"`
|
||||
}
|
||||
|
||||
func (e *OrgChangedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *OrgChangedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return []*eventstore.UniqueConstraint{
|
||||
NewRemoveOrgNameUniqueConstraint(e.oldName),
|
||||
NewAddOrgNameUniqueConstraint(e.Name),
|
||||
}
|
||||
}
|
||||
|
||||
func (e *OrgChangedEvent) Fields() []*eventstore.FieldOperation {
|
||||
return []*eventstore.FieldOperation{
|
||||
eventstore.SetField(
|
||||
e.Aggregate(),
|
||||
orgSearchObject(e.Aggregate().ID),
|
||||
OrgNameSearchField,
|
||||
&eventstore.Value{
|
||||
Value: e.Name,
|
||||
ShouldIndex: true,
|
||||
},
|
||||
|
||||
eventstore.FieldTypeInstanceID,
|
||||
eventstore.FieldTypeResourceOwner,
|
||||
eventstore.FieldTypeAggregateType,
|
||||
eventstore.FieldTypeAggregateID,
|
||||
eventstore.FieldTypeObjectType,
|
||||
eventstore.FieldTypeObjectID,
|
||||
eventstore.FieldTypeFieldName,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewOrgChangedEvent(ctx context.Context, aggregate *eventstore.Aggregate, oldName, newName string) *OrgChangedEvent {
|
||||
return &OrgChangedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgChangedEventType,
|
||||
),
|
||||
Name: newName,
|
||||
oldName: oldName,
|
||||
}
|
||||
}
|
||||
|
||||
func OrgChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
orgChanged := &OrgChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := event.Unmarshal(orgChanged)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "ORG-Bren2", "unable to unmarshal org added")
|
||||
}
|
||||
|
||||
return orgChanged, nil
|
||||
}
|
||||
|
||||
type OrgDeactivatedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
}
|
||||
|
||||
func (e *OrgDeactivatedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *OrgDeactivatedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *OrgDeactivatedEvent) Fields() []*eventstore.FieldOperation {
|
||||
return []*eventstore.FieldOperation{
|
||||
eventstore.SetField(
|
||||
e.Aggregate(),
|
||||
orgSearchObject(e.Aggregate().ID),
|
||||
OrgStateSearchField,
|
||||
&eventstore.Value{
|
||||
Value: domain.OrgStateInactive,
|
||||
ShouldIndex: true,
|
||||
},
|
||||
|
||||
eventstore.FieldTypeInstanceID,
|
||||
eventstore.FieldTypeResourceOwner,
|
||||
eventstore.FieldTypeAggregateType,
|
||||
eventstore.FieldTypeAggregateID,
|
||||
eventstore.FieldTypeObjectType,
|
||||
eventstore.FieldTypeObjectID,
|
||||
eventstore.FieldTypeFieldName,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewOrgDeactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *OrgDeactivatedEvent {
|
||||
return &OrgDeactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgDeactivatedEventType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func OrgDeactivatedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
return &OrgDeactivatedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type OrgReactivatedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
}
|
||||
|
||||
func (e *OrgReactivatedEvent) Fields() []*eventstore.FieldOperation {
|
||||
return []*eventstore.FieldOperation{
|
||||
eventstore.SetField(
|
||||
e.Aggregate(),
|
||||
orgSearchObject(e.Aggregate().ID),
|
||||
OrgStateSearchField,
|
||||
&eventstore.Value{
|
||||
Value: domain.OrgStateActive,
|
||||
ShouldIndex: true,
|
||||
},
|
||||
|
||||
eventstore.FieldTypeInstanceID,
|
||||
eventstore.FieldTypeResourceOwner,
|
||||
eventstore.FieldTypeAggregateType,
|
||||
eventstore.FieldTypeAggregateID,
|
||||
eventstore.FieldTypeObjectType,
|
||||
eventstore.FieldTypeObjectID,
|
||||
eventstore.FieldTypeFieldName,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func (e *OrgReactivatedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *OrgReactivatedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewOrgReactivatedEvent(ctx context.Context, aggregate *eventstore.Aggregate) *OrgReactivatedEvent {
|
||||
return &OrgReactivatedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgReactivatedEventType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func OrgReactivatedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
return &OrgReactivatedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type OrgRemovedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
name string
|
||||
usernames []string
|
||||
organizationScopedUsernames bool
|
||||
domains []string
|
||||
externalIDPs []*domain.UserIDPLink
|
||||
samlEntityIDs []string
|
||||
}
|
||||
|
||||
func (e *OrgRemovedEvent) Payload() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *OrgRemovedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
constraints := []*eventstore.UniqueConstraint{
|
||||
NewRemoveOrgNameUniqueConstraint(e.name),
|
||||
}
|
||||
for _, name := range e.usernames {
|
||||
constraints = append(constraints, user.NewRemoveUsernameUniqueConstraint(name, e.Aggregate().ID, e.organizationScopedUsernames))
|
||||
}
|
||||
for _, domain := range e.domains {
|
||||
constraints = append(constraints, NewRemoveOrgDomainUniqueConstraint(domain))
|
||||
}
|
||||
for _, idp := range e.externalIDPs {
|
||||
constraints = append(constraints, user.NewRemoveUserIDPLinkUniqueConstraint(idp.IDPConfigID, idp.ExternalUserID))
|
||||
}
|
||||
for _, entityID := range e.samlEntityIDs {
|
||||
constraints = append(constraints, project.NewRemoveSAMLConfigEntityIDUniqueConstraint(entityID))
|
||||
}
|
||||
return constraints
|
||||
}
|
||||
|
||||
func (e *OrgRemovedEvent) Fields() []*eventstore.FieldOperation {
|
||||
// TODO: project grants are currently not removed because we don't have the relationship between the granted org and the grant
|
||||
return []*eventstore.FieldOperation{
|
||||
eventstore.RemoveSearchFieldsByAggregate(e.Aggregate()),
|
||||
}
|
||||
}
|
||||
|
||||
func NewOrgRemovedEvent(ctx context.Context, aggregate *eventstore.Aggregate, name string, usernames []string, organizationScopedUsernames bool, domains []string, externalIDPs []*domain.UserIDPLink, samlEntityIDs []string) *OrgRemovedEvent {
|
||||
return &OrgRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
OrgRemovedEventType,
|
||||
),
|
||||
name: name,
|
||||
usernames: usernames,
|
||||
domains: domains,
|
||||
externalIDPs: externalIDPs,
|
||||
samlEntityIDs: samlEntityIDs,
|
||||
organizationScopedUsernames: organizationScopedUsernames,
|
||||
}
|
||||
}
|
||||
|
||||
func OrgRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
return &OrgRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func orgSearchObject(id string) eventstore.Object {
|
||||
return eventstore.Object{
|
||||
Type: OrgSearchType,
|
||||
Revision: 1,
|
||||
ID: id,
|
||||
}
|
||||
}
|
105
apps/api/internal/repository/org/policy_domain.go
Normal file
105
apps/api/internal/repository/org/policy_domain.go
Normal file
@@ -0,0 +1,105 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
DomainPolicyAddedEventType = orgEventTypePrefix + policy.DomainPolicyAddedEventType
|
||||
DomainPolicyChangedEventType = orgEventTypePrefix + policy.DomainPolicyChangedEventType
|
||||
DomainPolicyRemovedEventType = orgEventTypePrefix + policy.DomainPolicyRemovedEventType
|
||||
)
|
||||
|
||||
type DomainPolicyAddedEvent struct {
|
||||
policy.DomainPolicyAddedEvent
|
||||
}
|
||||
|
||||
func NewDomainPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
userLoginMustBeDomain,
|
||||
validateOrgDomains,
|
||||
smtpSenderAddressMatchesInstanceDomain bool,
|
||||
) *DomainPolicyAddedEvent {
|
||||
return &DomainPolicyAddedEvent{
|
||||
DomainPolicyAddedEvent: *policy.NewDomainPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
DomainPolicyAddedEventType),
|
||||
userLoginMustBeDomain,
|
||||
validateOrgDomains,
|
||||
smtpSenderAddressMatchesInstanceDomain,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func DomainPolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.DomainPolicyAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &DomainPolicyAddedEvent{DomainPolicyAddedEvent: *e.(*policy.DomainPolicyAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type DomainPolicyChangedEvent struct {
|
||||
policy.DomainPolicyChangedEvent
|
||||
}
|
||||
|
||||
func NewDomainPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.DomainPolicyChanges,
|
||||
) (*DomainPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewDomainPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
DomainPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &DomainPolicyChangedEvent{DomainPolicyChangedEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func DomainPolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.DomainPolicyChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &DomainPolicyChangedEvent{DomainPolicyChangedEvent: *e.(*policy.DomainPolicyChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type DomainPolicyRemovedEvent struct {
|
||||
policy.DomainPolicyRemovedEvent
|
||||
}
|
||||
|
||||
func NewDomainPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *DomainPolicyRemovedEvent {
|
||||
return &DomainPolicyRemovedEvent{
|
||||
DomainPolicyRemovedEvent: *policy.NewDomainPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
DomainPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func DomainPolicyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.DomainPolicyRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &DomainPolicyRemovedEvent{DomainPolicyRemovedEvent: *e.(*policy.DomainPolicyRemovedEvent)}, nil
|
||||
}
|
490
apps/api/internal/repository/org/policy_label.go
Normal file
490
apps/api/internal/repository/org/policy_label.go
Normal file
@@ -0,0 +1,490 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
LabelPolicyAddedEventType = orgEventTypePrefix + policy.LabelPolicyAddedEventType
|
||||
LabelPolicyChangedEventType = orgEventTypePrefix + policy.LabelPolicyChangedEventType
|
||||
LabelPolicyActivatedEventType = orgEventTypePrefix + policy.LabelPolicyActivatedEventType
|
||||
LabelPolicyRemovedEventType = orgEventTypePrefix + policy.LabelPolicyRemovedEventType
|
||||
|
||||
LabelPolicyLogoAddedEventType = orgEventTypePrefix + policy.LabelPolicyLogoAddedEventType
|
||||
LabelPolicyLogoRemovedEventType = orgEventTypePrefix + policy.LabelPolicyLogoRemovedEventType
|
||||
LabelPolicyIconAddedEventType = orgEventTypePrefix + policy.LabelPolicyIconAddedEventType
|
||||
LabelPolicyIconRemovedEventType = orgEventTypePrefix + policy.LabelPolicyIconRemovedEventType
|
||||
LabelPolicyLogoDarkAddedEventType = orgEventTypePrefix + policy.LabelPolicyLogoDarkAddedEventType
|
||||
LabelPolicyLogoDarkRemovedEventType = orgEventTypePrefix + policy.LabelPolicyLogoDarkRemovedEventType
|
||||
LabelPolicyIconDarkAddedEventType = orgEventTypePrefix + policy.LabelPolicyIconDarkAddedEventType
|
||||
LabelPolicyIconDarkRemovedEventType = orgEventTypePrefix + policy.LabelPolicyIconDarkRemovedEventType
|
||||
|
||||
LabelPolicyFontAddedEventType = orgEventTypePrefix + policy.LabelPolicyFontAddedEventType
|
||||
LabelPolicyFontRemovedEventType = orgEventTypePrefix + policy.LabelPolicyFontRemovedEventType
|
||||
|
||||
LabelPolicyAssetsRemovedEventType = orgEventTypePrefix + policy.LabelPolicyAssetsRemovedEventType
|
||||
)
|
||||
|
||||
type LabelPolicyAddedEvent struct {
|
||||
policy.LabelPolicyAddedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
primaryColor,
|
||||
backgroundColor,
|
||||
warnColor,
|
||||
fontColor,
|
||||
primaryColorDark,
|
||||
backgroundColorDark,
|
||||
warnColorDark,
|
||||
fontColorDark string,
|
||||
hideLoginNameSuffix,
|
||||
errorMsgPopup,
|
||||
disableWatermark bool,
|
||||
themeMode domain.LabelPolicyThemeMode,
|
||||
) *LabelPolicyAddedEvent {
|
||||
return &LabelPolicyAddedEvent{
|
||||
LabelPolicyAddedEvent: *policy.NewLabelPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyAddedEventType),
|
||||
primaryColor,
|
||||
backgroundColor,
|
||||
warnColor,
|
||||
fontColor,
|
||||
primaryColorDark,
|
||||
backgroundColorDark,
|
||||
warnColorDark,
|
||||
fontColorDark,
|
||||
hideLoginNameSuffix,
|
||||
errorMsgPopup,
|
||||
disableWatermark,
|
||||
themeMode),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyAddedEvent{LabelPolicyAddedEvent: *e.(*policy.LabelPolicyAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyChangedEvent struct {
|
||||
policy.LabelPolicyChangedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.LabelPolicyChanges,
|
||||
) (*LabelPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewLabelPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &LabelPolicyChangedEvent{LabelPolicyChangedEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func LabelPolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyChangedEvent{LabelPolicyChangedEvent: *e.(*policy.LabelPolicyChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyRemovedEvent struct {
|
||||
policy.LabelPolicyRemovedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *LabelPolicyRemovedEvent {
|
||||
return &LabelPolicyRemovedEvent{
|
||||
LabelPolicyRemovedEvent: *policy.NewLabelPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyRemovedEvent{LabelPolicyRemovedEvent: *e.(*policy.LabelPolicyRemovedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyActivatedEvent struct {
|
||||
policy.LabelPolicyActivatedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyActivatedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *LabelPolicyActivatedEvent {
|
||||
return &LabelPolicyActivatedEvent{
|
||||
LabelPolicyActivatedEvent: *policy.NewLabelPolicyActivatedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyActivatedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyActivatedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyActivatedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyActivatedEvent{LabelPolicyActivatedEvent: *e.(*policy.LabelPolicyActivatedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyLogoAddedEvent struct {
|
||||
policy.LabelPolicyLogoAddedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyLogoAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
storageKey string,
|
||||
) *LabelPolicyLogoAddedEvent {
|
||||
return &LabelPolicyLogoAddedEvent{
|
||||
LabelPolicyLogoAddedEvent: *policy.NewLabelPolicyLogoAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyLogoAddedEventType),
|
||||
storageKey,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyLogoAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyLogoAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyLogoAddedEvent{LabelPolicyLogoAddedEvent: *e.(*policy.LabelPolicyLogoAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyLogoRemovedEvent struct {
|
||||
policy.LabelPolicyLogoRemovedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyLogoRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
storageKey string,
|
||||
) *LabelPolicyLogoRemovedEvent {
|
||||
return &LabelPolicyLogoRemovedEvent{
|
||||
LabelPolicyLogoRemovedEvent: *policy.NewLabelPolicyLogoRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyLogoRemovedEventType),
|
||||
storageKey,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyLogoRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyLogoRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyLogoRemovedEvent{LabelPolicyLogoRemovedEvent: *e.(*policy.LabelPolicyLogoRemovedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyIconAddedEvent struct {
|
||||
policy.LabelPolicyIconAddedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyIconAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
storageKey string,
|
||||
) *LabelPolicyIconAddedEvent {
|
||||
return &LabelPolicyIconAddedEvent{
|
||||
LabelPolicyIconAddedEvent: *policy.NewLabelPolicyIconAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyIconAddedEventType),
|
||||
storageKey,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyIconAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyIconAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyIconAddedEvent{LabelPolicyIconAddedEvent: *e.(*policy.LabelPolicyIconAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyIconRemovedEvent struct {
|
||||
policy.LabelPolicyIconRemovedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyIconRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
storageKey string,
|
||||
) *LabelPolicyIconRemovedEvent {
|
||||
return &LabelPolicyIconRemovedEvent{
|
||||
LabelPolicyIconRemovedEvent: *policy.NewLabelPolicyIconRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyIconRemovedEventType),
|
||||
storageKey,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyIconRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyIconRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyIconRemovedEvent{LabelPolicyIconRemovedEvent: *e.(*policy.LabelPolicyIconRemovedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyLogoDarkAddedEvent struct {
|
||||
policy.LabelPolicyLogoDarkAddedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyLogoDarkAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
storageKey string,
|
||||
) *LabelPolicyLogoDarkAddedEvent {
|
||||
return &LabelPolicyLogoDarkAddedEvent{
|
||||
LabelPolicyLogoDarkAddedEvent: *policy.NewLabelPolicyLogoDarkAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyLogoDarkAddedEventType),
|
||||
storageKey,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyLogoDarkAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyLogoDarkAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyLogoDarkAddedEvent{LabelPolicyLogoDarkAddedEvent: *e.(*policy.LabelPolicyLogoDarkAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyLogoDarkRemovedEvent struct {
|
||||
policy.LabelPolicyLogoDarkRemovedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyLogoDarkRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
storageKey string,
|
||||
) *LabelPolicyLogoDarkRemovedEvent {
|
||||
return &LabelPolicyLogoDarkRemovedEvent{
|
||||
LabelPolicyLogoDarkRemovedEvent: *policy.NewLabelPolicyLogoDarkRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyLogoDarkRemovedEventType),
|
||||
storageKey,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyLogoDarkRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyLogoDarkRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyLogoDarkRemovedEvent{LabelPolicyLogoDarkRemovedEvent: *e.(*policy.LabelPolicyLogoDarkRemovedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyIconDarkAddedEvent struct {
|
||||
policy.LabelPolicyIconDarkAddedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyIconDarkAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
storageKey string,
|
||||
) *LabelPolicyIconDarkAddedEvent {
|
||||
return &LabelPolicyIconDarkAddedEvent{
|
||||
LabelPolicyIconDarkAddedEvent: *policy.NewLabelPolicyIconDarkAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyIconDarkAddedEventType),
|
||||
storageKey,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyIconDarkAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyIconDarkAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyIconDarkAddedEvent{LabelPolicyIconDarkAddedEvent: *e.(*policy.LabelPolicyIconDarkAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyIconDarkRemovedEvent struct {
|
||||
policy.LabelPolicyIconDarkRemovedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyIconDarkRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
storageKey string,
|
||||
) *LabelPolicyIconDarkRemovedEvent {
|
||||
return &LabelPolicyIconDarkRemovedEvent{
|
||||
LabelPolicyIconDarkRemovedEvent: *policy.NewLabelPolicyIconDarkRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyIconDarkRemovedEventType),
|
||||
storageKey,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyIconDarkRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyIconDarkRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyIconDarkRemovedEvent{LabelPolicyIconDarkRemovedEvent: *e.(*policy.LabelPolicyIconDarkRemovedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyFontAddedEvent struct {
|
||||
policy.LabelPolicyFontAddedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyFontAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
storageKey string,
|
||||
) *LabelPolicyFontAddedEvent {
|
||||
return &LabelPolicyFontAddedEvent{
|
||||
LabelPolicyFontAddedEvent: *policy.NewLabelPolicyFontAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyFontAddedEventType),
|
||||
storageKey,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyFontAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyFontAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyFontAddedEvent{LabelPolicyFontAddedEvent: *e.(*policy.LabelPolicyFontAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyFontRemovedEvent struct {
|
||||
policy.LabelPolicyFontRemovedEvent
|
||||
}
|
||||
|
||||
func NewLabelPolicyFontRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
storageKey string,
|
||||
) *LabelPolicyFontRemovedEvent {
|
||||
return &LabelPolicyFontRemovedEvent{
|
||||
LabelPolicyFontRemovedEvent: *policy.NewLabelPolicyFontRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyFontRemovedEventType),
|
||||
storageKey,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyFontRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyFontRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyFontRemovedEvent{LabelPolicyFontRemovedEvent: *e.(*policy.LabelPolicyFontRemovedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyAssetsRemovedEvent struct {
|
||||
policy.LabelPolicyAssetsRemovedEvent
|
||||
}
|
||||
|
||||
func (e *LabelPolicyAssetsRemovedEvent) Payload() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *LabelPolicyAssetsRemovedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewLabelPolicyAssetsRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *LabelPolicyAssetsRemovedEvent {
|
||||
return &LabelPolicyAssetsRemovedEvent{
|
||||
LabelPolicyAssetsRemovedEvent: *policy.NewLabelPolicyAssetsRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LabelPolicyAssetsRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyAssetsRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LabelPolicyAssetsRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyAssetsRemovedEvent{LabelPolicyAssetsRemovedEvent: *e.(*policy.LabelPolicyAssetsRemovedEvent)}, nil
|
||||
}
|
135
apps/api/internal/repository/org/policy_login.go
Normal file
135
apps/api/internal/repository/org/policy_login.go
Normal file
@@ -0,0 +1,135 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
LoginPolicyAddedEventType = orgEventTypePrefix + policy.LoginPolicyAddedEventType
|
||||
LoginPolicyChangedEventType = orgEventTypePrefix + policy.LoginPolicyChangedEventType
|
||||
LoginPolicyRemovedEventType = orgEventTypePrefix + policy.LoginPolicyRemovedEventType
|
||||
)
|
||||
|
||||
type LoginPolicyAddedEvent struct {
|
||||
policy.LoginPolicyAddedEvent
|
||||
}
|
||||
|
||||
func NewLoginPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
allowUsernamePassword,
|
||||
allowRegister,
|
||||
allowExternalIDP,
|
||||
forceMFA,
|
||||
forceMFALocalOnly,
|
||||
hidePasswordReset,
|
||||
ignoreUnknownUsernames,
|
||||
allowDomainDiscovery,
|
||||
disableLoginWithEmail,
|
||||
disableLoginWithPhone bool,
|
||||
passwordlessType domain.PasswordlessType,
|
||||
defaultRedirectURI string,
|
||||
passwordCheckLifetime,
|
||||
externalLoginCheckLifetime,
|
||||
mfaInitSkipLifetime,
|
||||
secondFactorCheckLifetime,
|
||||
multiFactorCheckLifetime time.Duration,
|
||||
) *LoginPolicyAddedEvent {
|
||||
return &LoginPolicyAddedEvent{
|
||||
LoginPolicyAddedEvent: *policy.NewLoginPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyAddedEventType),
|
||||
allowUsernamePassword,
|
||||
allowRegister,
|
||||
allowExternalIDP,
|
||||
forceMFA,
|
||||
forceMFALocalOnly,
|
||||
hidePasswordReset,
|
||||
ignoreUnknownUsernames,
|
||||
allowDomainDiscovery,
|
||||
disableLoginWithEmail,
|
||||
disableLoginWithPhone,
|
||||
passwordlessType,
|
||||
defaultRedirectURI,
|
||||
passwordCheckLifetime,
|
||||
externalLoginCheckLifetime,
|
||||
mfaInitSkipLifetime,
|
||||
secondFactorCheckLifetime,
|
||||
multiFactorCheckLifetime,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LoginPolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LoginPolicyAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LoginPolicyAddedEvent{LoginPolicyAddedEvent: *e.(*policy.LoginPolicyAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type LoginPolicyChangedEvent struct {
|
||||
policy.LoginPolicyChangedEvent
|
||||
}
|
||||
|
||||
func NewLoginPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.LoginPolicyChanges,
|
||||
) (*LoginPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewLoginPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &LoginPolicyChangedEvent{LoginPolicyChangedEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func LoginPolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LoginPolicyChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LoginPolicyChangedEvent{LoginPolicyChangedEvent: *e.(*policy.LoginPolicyChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type LoginPolicyRemovedEvent struct {
|
||||
policy.LoginPolicyRemovedEvent
|
||||
}
|
||||
|
||||
func NewLoginPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *LoginPolicyRemovedEvent {
|
||||
return &LoginPolicyRemovedEvent{
|
||||
LoginPolicyRemovedEvent: *policy.NewLoginPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LoginPolicyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LoginPolicyRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LoginPolicyRemovedEvent{LoginPolicyRemovedEvent: *e.(*policy.LoginPolicyRemovedEvent)}, nil
|
||||
}
|
139
apps/api/internal/repository/org/policy_login_factors.go
Normal file
139
apps/api/internal/repository/org/policy_login_factors.go
Normal file
@@ -0,0 +1,139 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
LoginPolicySecondFactorAddedEventType = orgEventTypePrefix + policy.LoginPolicySecondFactorAddedEventType
|
||||
LoginPolicySecondFactorRemovedEventType = orgEventTypePrefix + policy.LoginPolicySecondFactorRemovedEventType
|
||||
|
||||
LoginPolicyMultiFactorAddedEventType = orgEventTypePrefix + policy.LoginPolicyMultiFactorAddedEventType
|
||||
LoginPolicyMultiFactorRemovedEventType = orgEventTypePrefix + policy.LoginPolicyMultiFactorRemovedEventType
|
||||
)
|
||||
|
||||
type LoginPolicySecondFactorAddedEvent struct {
|
||||
policy.SecondFactorAddedEvent
|
||||
}
|
||||
|
||||
func NewLoginPolicySecondFactorAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.SecondFactorType,
|
||||
) *LoginPolicySecondFactorAddedEvent {
|
||||
return &LoginPolicySecondFactorAddedEvent{
|
||||
SecondFactorAddedEvent: *policy.NewSecondFactorAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicySecondFactorAddedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
|
||||
func SecondFactorAddedEventEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.SecondFactorAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LoginPolicySecondFactorAddedEvent{
|
||||
SecondFactorAddedEvent: *e.(*policy.SecondFactorAddedEvent),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type LoginPolicySecondFactorRemovedEvent struct {
|
||||
policy.SecondFactorRemovedEvent
|
||||
}
|
||||
|
||||
func NewLoginPolicySecondFactorRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.SecondFactorType,
|
||||
) *LoginPolicySecondFactorRemovedEvent {
|
||||
|
||||
return &LoginPolicySecondFactorRemovedEvent{
|
||||
SecondFactorRemovedEvent: *policy.NewSecondFactorRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicySecondFactorRemovedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
|
||||
func SecondFactorRemovedEventEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.SecondFactorRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LoginPolicySecondFactorRemovedEvent{
|
||||
SecondFactorRemovedEvent: *e.(*policy.SecondFactorRemovedEvent),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type LoginPolicyMultiFactorAddedEvent struct {
|
||||
policy.MultiFactorAddedEvent
|
||||
}
|
||||
|
||||
func NewLoginPolicyMultiFactorAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.MultiFactorType,
|
||||
) *LoginPolicyMultiFactorAddedEvent {
|
||||
return &LoginPolicyMultiFactorAddedEvent{
|
||||
MultiFactorAddedEvent: *policy.NewMultiFactorAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyMultiFactorAddedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
|
||||
func MultiFactorAddedEventEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.MultiFactorAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LoginPolicyMultiFactorAddedEvent{
|
||||
MultiFactorAddedEvent: *e.(*policy.MultiFactorAddedEvent),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type LoginPolicyMultiFactorRemovedEvent struct {
|
||||
policy.MultiFactorRemovedEvent
|
||||
}
|
||||
|
||||
func NewLoginPolicyMultiFactorRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mfaType domain.MultiFactorType,
|
||||
) *LoginPolicyMultiFactorRemovedEvent {
|
||||
|
||||
return &LoginPolicyMultiFactorRemovedEvent{
|
||||
MultiFactorRemovedEvent: *policy.NewMultiFactorRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyMultiFactorRemovedEventType),
|
||||
mfaType),
|
||||
}
|
||||
}
|
||||
|
||||
func MultiFactorRemovedEventEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.MultiFactorRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LoginPolicyMultiFactorRemovedEvent{
|
||||
MultiFactorRemovedEvent: *e.(*policy.MultiFactorRemovedEvent),
|
||||
}, nil
|
||||
}
|
@@ -0,0 +1,105 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
LoginPolicyIDPProviderAddedEventType = orgEventTypePrefix + policy.LoginPolicyIDPProviderAddedType
|
||||
LoginPolicyIDPProviderRemovedEventType = orgEventTypePrefix + policy.LoginPolicyIDPProviderRemovedType
|
||||
LoginPolicyIDPProviderCascadeRemovedEventType = orgEventTypePrefix + policy.LoginPolicyIDPProviderCascadeRemovedType
|
||||
)
|
||||
|
||||
type IdentityProviderAddedEvent struct {
|
||||
policy.IdentityProviderAddedEvent
|
||||
}
|
||||
|
||||
func NewIdentityProviderAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
idpProviderType domain.IdentityProviderType,
|
||||
) *IdentityProviderAddedEvent {
|
||||
|
||||
return &IdentityProviderAddedEvent{
|
||||
IdentityProviderAddedEvent: *policy.NewIdentityProviderAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyIDPProviderAddedEventType),
|
||||
idpConfigID,
|
||||
idpProviderType),
|
||||
}
|
||||
}
|
||||
|
||||
func IdentityProviderAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.IdentityProviderAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IdentityProviderAddedEvent{
|
||||
IdentityProviderAddedEvent: *e.(*policy.IdentityProviderAddedEvent),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type IdentityProviderRemovedEvent struct {
|
||||
policy.IdentityProviderRemovedEvent
|
||||
}
|
||||
|
||||
func NewIdentityProviderRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
) *IdentityProviderRemovedEvent {
|
||||
return &IdentityProviderRemovedEvent{
|
||||
IdentityProviderRemovedEvent: *policy.NewIdentityProviderRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LoginPolicyIDPProviderRemovedEventType),
|
||||
idpConfigID),
|
||||
}
|
||||
}
|
||||
|
||||
func IdentityProviderRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.IdentityProviderRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IdentityProviderRemovedEvent{
|
||||
IdentityProviderRemovedEvent: *e.(*policy.IdentityProviderRemovedEvent),
|
||||
}, nil
|
||||
}
|
||||
|
||||
type IdentityProviderCascadeRemovedEvent struct {
|
||||
policy.IdentityProviderCascadeRemovedEvent
|
||||
}
|
||||
|
||||
func NewIdentityProviderCascadeRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
idpConfigID string,
|
||||
) *IdentityProviderCascadeRemovedEvent {
|
||||
return &IdentityProviderCascadeRemovedEvent{
|
||||
IdentityProviderCascadeRemovedEvent: *policy.NewIdentityProviderCascadeRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, LoginPolicyIDPProviderRemovedEventType),
|
||||
idpConfigID),
|
||||
}
|
||||
}
|
||||
|
||||
func IdentityProviderCascadeRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.IdentityProviderCascadeRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &IdentityProviderCascadeRemovedEvent{
|
||||
IdentityProviderCascadeRemovedEvent: *e.(*policy.IdentityProviderCascadeRemovedEvent),
|
||||
}, nil
|
||||
}
|
91
apps/api/internal/repository/org/policy_mail_template.go
Normal file
91
apps/api/internal/repository/org/policy_mail_template.go
Normal file
@@ -0,0 +1,91 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
MailTemplateAddedEventType = orgEventTypePrefix + policy.MailTemplatePolicyAddedEventType
|
||||
MailTemplateChangedEventType = orgEventTypePrefix + policy.MailTemplatePolicyChangedEventType
|
||||
MailTemplateRemovedEventType = orgEventTypePrefix + policy.MailTemplatePolicyRemovedEventType
|
||||
)
|
||||
|
||||
type MailTemplateAddedEvent struct {
|
||||
policy.MailTemplateAddedEvent
|
||||
}
|
||||
|
||||
func NewMailTemplateAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
template []byte,
|
||||
) *MailTemplateAddedEvent {
|
||||
return &MailTemplateAddedEvent{
|
||||
MailTemplateAddedEvent: *policy.NewMailTemplateAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateAddedEventType),
|
||||
template),
|
||||
}
|
||||
}
|
||||
|
||||
func MailTemplateAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.MailTemplateAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MailTemplateAddedEvent{MailTemplateAddedEvent: *e.(*policy.MailTemplateAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type MailTemplateChangedEvent struct {
|
||||
policy.MailTemplateChangedEvent
|
||||
}
|
||||
|
||||
func NewMailTemplateChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.MailTemplateChanges,
|
||||
) (*MailTemplateChangedEvent, error) {
|
||||
changedEvent, err := policy.NewMailTemplateChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &MailTemplateChangedEvent{MailTemplateChangedEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func MailTemplateChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.MailTemplateChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MailTemplateChangedEvent{MailTemplateChangedEvent: *e.(*policy.MailTemplateChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type MailTemplateRemovedEvent struct {
|
||||
policy.MailTemplateRemovedEvent
|
||||
}
|
||||
|
||||
func NewMailTemplateRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *MailTemplateRemovedEvent {
|
||||
return &MailTemplateRemovedEvent{
|
||||
MailTemplateRemovedEvent: *policy.NewMailTemplateRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTemplateRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func MailTemplateRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.MailTemplateRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MailTemplateRemovedEvent{MailTemplateRemovedEvent: *e.(*policy.MailTemplateRemovedEvent)}, nil
|
||||
}
|
113
apps/api/internal/repository/org/policy_mail_text.go
Normal file
113
apps/api/internal/repository/org/policy_mail_text.go
Normal file
@@ -0,0 +1,113 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
MailTextAddedEventType = orgEventTypePrefix + policy.MailTextPolicyAddedEventType
|
||||
MailTextChangedEventType = orgEventTypePrefix + policy.MailTextPolicyChangedEventType
|
||||
MailTextRemovedEventType = orgEventTypePrefix + policy.MailTextPolicyRemovedEventType
|
||||
)
|
||||
|
||||
type MailTextAddedEvent struct {
|
||||
policy.MailTextAddedEvent
|
||||
}
|
||||
|
||||
func NewMailTextAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mailTextType,
|
||||
language,
|
||||
title,
|
||||
preHeader,
|
||||
subject,
|
||||
greeting,
|
||||
text,
|
||||
buttonText string,
|
||||
) *MailTextAddedEvent {
|
||||
return &MailTextAddedEvent{
|
||||
MailTextAddedEvent: *policy.NewMailTextAddedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextAddedEventType),
|
||||
mailTextType,
|
||||
language,
|
||||
title,
|
||||
preHeader,
|
||||
subject,
|
||||
greeting,
|
||||
text,
|
||||
buttonText),
|
||||
}
|
||||
}
|
||||
|
||||
func MailTextAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.MailTextAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MailTextAddedEvent{MailTextAddedEvent: *e.(*policy.MailTextAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type MailTextChangedEvent struct {
|
||||
policy.MailTextChangedEvent
|
||||
}
|
||||
|
||||
func NewMailTextChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mailTextType,
|
||||
language string,
|
||||
changes []policy.MailTextChanges,
|
||||
) (*MailTextChangedEvent, error) {
|
||||
changedEvent, err := policy.NewMailTextChangedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextChangedEventType),
|
||||
mailTextType,
|
||||
language,
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &MailTextChangedEvent{MailTextChangedEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func MailTextChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.MailTextChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MailTextChangedEvent{MailTextChangedEvent: *e.(*policy.MailTextChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type MailTextRemovedEvent struct {
|
||||
policy.MailTextRemovedEvent
|
||||
}
|
||||
|
||||
func NewMailTextRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
mailTextType,
|
||||
language string,
|
||||
) *MailTextRemovedEvent {
|
||||
return &MailTextRemovedEvent{
|
||||
MailTextRemovedEvent: *policy.NewMailTextRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(ctx, aggregate, MailTextRemovedEventType),
|
||||
mailTextType,
|
||||
language,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func MailTextRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.MailTextRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &MailTextRemovedEvent{MailTextRemovedEvent: *e.(*policy.MailTextRemovedEvent)}, nil
|
||||
}
|
101
apps/api/internal/repository/org/policy_notification.go
Normal file
101
apps/api/internal/repository/org/policy_notification.go
Normal file
@@ -0,0 +1,101 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
NotificationPolicyAddedEventType = orgEventTypePrefix + policy.NotificationPolicyAddedEventType
|
||||
NotificationPolicyChangedEventType = orgEventTypePrefix + policy.NotificationPolicyChangedEventType
|
||||
NotificationPolicyRemovedEventType = orgEventTypePrefix + policy.NotificationPolicyRemovedEventType
|
||||
)
|
||||
|
||||
type NotificationPolicyAddedEvent struct {
|
||||
policy.NotificationPolicyAddedEvent
|
||||
}
|
||||
|
||||
func NewNotificationPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
passwordChange bool,
|
||||
) *NotificationPolicyAddedEvent {
|
||||
return &NotificationPolicyAddedEvent{
|
||||
NotificationPolicyAddedEvent: *policy.NewNotificationPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
NotificationPolicyAddedEventType),
|
||||
passwordChange,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NotificationPolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.NotificationPolicyAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &NotificationPolicyAddedEvent{NotificationPolicyAddedEvent: *e.(*policy.NotificationPolicyAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type NotificationPolicyChangedEvent struct {
|
||||
policy.NotificationPolicyChangedEvent
|
||||
}
|
||||
|
||||
func NewNotificationPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.NotificationPolicyChanges,
|
||||
) (*NotificationPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewNotificationPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
NotificationPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &NotificationPolicyChangedEvent{NotificationPolicyChangedEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func NotificationPolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.NotificationPolicyChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &NotificationPolicyChangedEvent{NotificationPolicyChangedEvent: *e.(*policy.NotificationPolicyChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type NotificationPolicyRemovedEvent struct {
|
||||
policy.NotificationPolicyRemovedEvent
|
||||
}
|
||||
|
||||
func NewNotificationPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *NotificationPolicyRemovedEvent {
|
||||
return &NotificationPolicyRemovedEvent{
|
||||
NotificationPolicyRemovedEvent: *policy.NewNotificationPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
NotificationPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NotificationPolicyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.NotificationPolicyRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &NotificationPolicyRemovedEvent{NotificationPolicyRemovedEvent: *e.(*policy.NotificationPolicyRemovedEvent)}, nil
|
||||
}
|
102
apps/api/internal/repository/org/policy_password_age.go
Normal file
102
apps/api/internal/repository/org/policy_password_age.go
Normal file
@@ -0,0 +1,102 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
PasswordAgePolicyAddedEventType = orgEventTypePrefix + policy.PasswordAgePolicyAddedEventType
|
||||
PasswordAgePolicyChangedEventType = orgEventTypePrefix + policy.PasswordAgePolicyChangedEventType
|
||||
PasswordAgePolicyRemovedEventType = orgEventTypePrefix + policy.PasswordAgePolicyRemovedEventType
|
||||
)
|
||||
|
||||
type PasswordAgePolicyAddedEvent struct {
|
||||
policy.PasswordAgePolicyAddedEvent
|
||||
}
|
||||
|
||||
func NewPasswordAgePolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
expireWarnDays,
|
||||
maxAgeDays uint64,
|
||||
) *PasswordAgePolicyAddedEvent {
|
||||
return &PasswordAgePolicyAddedEvent{
|
||||
PasswordAgePolicyAddedEvent: *policy.NewPasswordAgePolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordAgePolicyAddedEventType),
|
||||
expireWarnDays,
|
||||
maxAgeDays),
|
||||
}
|
||||
}
|
||||
|
||||
func PasswordAgePolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.PasswordAgePolicyAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PasswordAgePolicyAddedEvent{PasswordAgePolicyAddedEvent: *e.(*policy.PasswordAgePolicyAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type PasswordAgePolicyChangedEvent struct {
|
||||
policy.PasswordAgePolicyChangedEvent
|
||||
}
|
||||
|
||||
func NewPasswordAgePolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.PasswordAgePolicyChanges,
|
||||
) (*PasswordAgePolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewPasswordAgePolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordAgePolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &PasswordAgePolicyChangedEvent{PasswordAgePolicyChangedEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func PasswordAgePolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.PasswordAgePolicyChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PasswordAgePolicyChangedEvent{PasswordAgePolicyChangedEvent: *e.(*policy.PasswordAgePolicyChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type PasswordAgePolicyRemovedEvent struct {
|
||||
policy.PasswordAgePolicyRemovedEvent
|
||||
}
|
||||
|
||||
func NewPasswordAgePolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *PasswordAgePolicyRemovedEvent {
|
||||
return &PasswordAgePolicyRemovedEvent{
|
||||
PasswordAgePolicyRemovedEvent: *policy.NewPasswordAgePolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordAgePolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func PasswordAgePolicyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.PasswordAgePolicyRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PasswordAgePolicyRemovedEvent{PasswordAgePolicyRemovedEvent: *e.(*policy.PasswordAgePolicyRemovedEvent)}, nil
|
||||
}
|
108
apps/api/internal/repository/org/policy_password_complexity.go
Normal file
108
apps/api/internal/repository/org/policy_password_complexity.go
Normal file
@@ -0,0 +1,108 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
PasswordComplexityPolicyAddedEventType = orgEventTypePrefix + policy.PasswordComplexityPolicyAddedEventType
|
||||
PasswordComplexityPolicyChangedEventType = orgEventTypePrefix + policy.PasswordComplexityPolicyChangedEventType
|
||||
PasswordComplexityPolicyRemovedEventType = orgEventTypePrefix + policy.PasswordComplexityPolicyRemovedEventType
|
||||
)
|
||||
|
||||
type PasswordComplexityPolicyAddedEvent struct {
|
||||
policy.PasswordComplexityPolicyAddedEvent
|
||||
}
|
||||
|
||||
func NewPasswordComplexityPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
minLength uint64,
|
||||
hasLowercase,
|
||||
hasUppercase,
|
||||
hasNumber,
|
||||
hasSymbol bool,
|
||||
) *PasswordComplexityPolicyAddedEvent {
|
||||
return &PasswordComplexityPolicyAddedEvent{
|
||||
PasswordComplexityPolicyAddedEvent: *policy.NewPasswordComplexityPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordComplexityPolicyAddedEventType),
|
||||
minLength,
|
||||
hasLowercase,
|
||||
hasUppercase,
|
||||
hasNumber,
|
||||
hasSymbol),
|
||||
}
|
||||
}
|
||||
|
||||
func PasswordComplexityPolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.PasswordComplexityPolicyAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PasswordComplexityPolicyAddedEvent{PasswordComplexityPolicyAddedEvent: *e.(*policy.PasswordComplexityPolicyAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type PasswordComplexityPolicyChangedEvent struct {
|
||||
policy.PasswordComplexityPolicyChangedEvent
|
||||
}
|
||||
|
||||
func NewPasswordComplexityPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.PasswordComplexityPolicyChanges,
|
||||
) (*PasswordComplexityPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewPasswordComplexityPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordComplexityPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &PasswordComplexityPolicyChangedEvent{PasswordComplexityPolicyChangedEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func PasswordComplexityPolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.PasswordComplexityPolicyChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PasswordComplexityPolicyChangedEvent{PasswordComplexityPolicyChangedEvent: *e.(*policy.PasswordComplexityPolicyChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type PasswordComplexityPolicyRemovedEvent struct {
|
||||
policy.PasswordComplexityPolicyRemovedEvent
|
||||
}
|
||||
|
||||
func NewPasswordComplexityPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *PasswordComplexityPolicyRemovedEvent {
|
||||
return &PasswordComplexityPolicyRemovedEvent{
|
||||
PasswordComplexityPolicyRemovedEvent: *policy.NewPasswordComplexityPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PasswordComplexityPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func PasswordComplexityPolicyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.PasswordComplexityPolicyRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PasswordComplexityPolicyRemovedEvent{PasswordComplexityPolicyRemovedEvent: *e.(*policy.PasswordComplexityPolicyRemovedEvent)}, nil
|
||||
}
|
104
apps/api/internal/repository/org/policy_password_lockout.go
Normal file
104
apps/api/internal/repository/org/policy_password_lockout.go
Normal file
@@ -0,0 +1,104 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
LockoutPolicyAddedEventType = orgEventTypePrefix + policy.LockoutPolicyAddedEventType
|
||||
LockoutPolicyChangedEventType = orgEventTypePrefix + policy.LockoutPolicyChangedEventType
|
||||
LockoutPolicyRemovedEventType = orgEventTypePrefix + policy.LockoutPolicyRemovedEventType
|
||||
)
|
||||
|
||||
type LockoutPolicyAddedEvent struct {
|
||||
policy.LockoutPolicyAddedEvent
|
||||
}
|
||||
|
||||
func NewLockoutPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
maxPasswordAttempts,
|
||||
maxOTPAttempts uint64,
|
||||
showLockoutFailure bool,
|
||||
) *LockoutPolicyAddedEvent {
|
||||
return &LockoutPolicyAddedEvent{
|
||||
LockoutPolicyAddedEvent: *policy.NewLockoutPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LockoutPolicyAddedEventType),
|
||||
maxPasswordAttempts,
|
||||
maxOTPAttempts,
|
||||
showLockoutFailure),
|
||||
}
|
||||
}
|
||||
|
||||
func LockoutPolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LockoutPolicyAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LockoutPolicyAddedEvent{LockoutPolicyAddedEvent: *e.(*policy.LockoutPolicyAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type LockoutPolicyChangedEvent struct {
|
||||
policy.LockoutPolicyChangedEvent
|
||||
}
|
||||
|
||||
func NewLockoutPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.LockoutPolicyChanges,
|
||||
) (*LockoutPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewLockoutPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LockoutPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &LockoutPolicyChangedEvent{LockoutPolicyChangedEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func LockoutPolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LockoutPolicyChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LockoutPolicyChangedEvent{LockoutPolicyChangedEvent: *e.(*policy.LockoutPolicyChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type LockoutPolicyRemovedEvent struct {
|
||||
policy.LockoutPolicyRemovedEvent
|
||||
}
|
||||
|
||||
func NewLockoutPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *LockoutPolicyRemovedEvent {
|
||||
return &LockoutPolicyRemovedEvent{
|
||||
LockoutPolicyRemovedEvent: *policy.NewLockoutPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
LockoutPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LockoutPolicyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.LockoutPolicyRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LockoutPolicyRemovedEvent{LockoutPolicyRemovedEvent: *e.(*policy.LockoutPolicyRemovedEvent)}, nil
|
||||
}
|
111
apps/api/internal/repository/org/policy_privacy.go
Normal file
111
apps/api/internal/repository/org/policy_privacy.go
Normal file
@@ -0,0 +1,111 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
PrivacyPolicyAddedEventType = orgEventTypePrefix + policy.PrivacyPolicyAddedEventType
|
||||
PrivacyPolicyChangedEventType = orgEventTypePrefix + policy.PrivacyPolicyChangedEventType
|
||||
PrivacyPolicyRemovedEventType = orgEventTypePrefix + policy.PrivacyPolicyRemovedEventType
|
||||
)
|
||||
|
||||
type PrivacyPolicyAddedEvent struct {
|
||||
policy.PrivacyPolicyAddedEvent
|
||||
}
|
||||
|
||||
func NewPrivacyPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
tosLink,
|
||||
privacyLink,
|
||||
helpLink string,
|
||||
supportEmail domain.EmailAddress,
|
||||
docsLink, customLink, customLinkText string,
|
||||
) *PrivacyPolicyAddedEvent {
|
||||
return &PrivacyPolicyAddedEvent{
|
||||
PrivacyPolicyAddedEvent: *policy.NewPrivacyPolicyAddedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PrivacyPolicyAddedEventType),
|
||||
tosLink,
|
||||
privacyLink,
|
||||
helpLink,
|
||||
supportEmail,
|
||||
docsLink,
|
||||
customLink,
|
||||
customLinkText),
|
||||
}
|
||||
}
|
||||
|
||||
func PrivacyPolicyAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.PrivacyPolicyAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PrivacyPolicyAddedEvent{PrivacyPolicyAddedEvent: *e.(*policy.PrivacyPolicyAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type PrivacyPolicyChangedEvent struct {
|
||||
policy.PrivacyPolicyChangedEvent
|
||||
}
|
||||
|
||||
func NewPrivacyPolicyChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []policy.PrivacyPolicyChanges,
|
||||
) (*PrivacyPolicyChangedEvent, error) {
|
||||
changedEvent, err := policy.NewPrivacyPolicyChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PrivacyPolicyChangedEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &PrivacyPolicyChangedEvent{PrivacyPolicyChangedEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func PrivacyPolicyChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.PrivacyPolicyChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PrivacyPolicyChangedEvent{PrivacyPolicyChangedEvent: *e.(*policy.PrivacyPolicyChangedEvent)}, nil
|
||||
}
|
||||
|
||||
type PrivacyPolicyRemovedEvent struct {
|
||||
policy.PrivacyPolicyRemovedEvent
|
||||
}
|
||||
|
||||
func NewPrivacyPolicyRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *PrivacyPolicyRemovedEvent {
|
||||
return &PrivacyPolicyRemovedEvent{
|
||||
PrivacyPolicyRemovedEvent: *policy.NewPrivacyPolicyRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
PrivacyPolicyRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func PrivacyPolicyRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e, err := policy.PrivacyPolicyRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &PrivacyPolicyRemovedEvent{PrivacyPolicyRemovedEvent: *e.(*policy.PrivacyPolicyRemovedEvent)}, nil
|
||||
}
|
Reference in New Issue
Block a user