mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:17:32 +00:00
feat: permit all features to every instance and organisation (#3566)
This commit is contained in:
@@ -1,245 +0,0 @@
|
||||
package features
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
featuresPrefix = "features."
|
||||
FeaturesSetEventType = featuresPrefix + "set"
|
||||
FeaturesRemovedEventType = featuresPrefix + "removed"
|
||||
)
|
||||
|
||||
type FeaturesSetEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
TierName *string `json:"tierName,omitempty"`
|
||||
TierDescription *string `json:"tierDescription,omitempty"`
|
||||
State *domain.FeaturesState `json:"state,omitempty"`
|
||||
StateDescription *string `json:"stateDescription,omitempty"`
|
||||
AuditLogRetention *time.Duration `json:"auditLogRetention,omitempty"`
|
||||
LoginPolicyFactors *bool `json:"loginPolicyFactors,omitempty"`
|
||||
LoginPolicyIDP *bool `json:"loginPolicyIDP,omitempty"`
|
||||
LoginPolicyPasswordless *bool `json:"loginPolicyPasswordless,omitempty"`
|
||||
LoginPolicyRegistration *bool `json:"loginPolicyRegistration,omitempty"`
|
||||
LoginPolicyUsernameLogin *bool `json:"loginPolicyUsernameLogin,omitempty"`
|
||||
LoginPolicyPasswordReset *bool `json:"loginPolicyPasswordReset,omitempty"`
|
||||
PasswordComplexityPolicy *bool `json:"passwordComplexityPolicy,omitempty"`
|
||||
LabelPolicy *bool `json:"labelPolicy,omitempty"`
|
||||
LabelPolicyPrivateLabel *bool `json:"labelPolicyPrivateLabel,omitempty"`
|
||||
LabelPolicyWatermark *bool `json:"labelPolicyWatermark,omitempty"`
|
||||
CustomDomain *bool `json:"customDomain,omitempty"`
|
||||
PrivacyPolicy *bool `json:"privacyPolicy,omitempty"`
|
||||
MetadataUser *bool `json:"metadataUser,omitempty"`
|
||||
CustomTextMessage *bool `json:"customTextMessage,omitempty"`
|
||||
CustomTextLogin *bool `json:"customTextLogin,omitempty"`
|
||||
LockoutPolicy *bool `json:"lockoutPolicy,omitempty"`
|
||||
Actions *bool `json:"actions,omitempty"`
|
||||
ActionsAllowed *domain.ActionsAllowed `json:"actionsAllowed,omitempty"`
|
||||
MaxActions *int `json:"maxActions,omitempty"`
|
||||
}
|
||||
|
||||
func (e *FeaturesSetEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *FeaturesSetEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewFeaturesSetEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
changes []FeaturesChanges,
|
||||
) (*FeaturesSetEvent, error) {
|
||||
if len(changes) == 0 {
|
||||
return nil, errors.ThrowPreconditionFailed(nil, "FEATURES-d34F4", "Errors.NoChangesFound")
|
||||
}
|
||||
changeEvent := &FeaturesSetEvent{
|
||||
BaseEvent: *base,
|
||||
}
|
||||
for _, change := range changes {
|
||||
change(changeEvent)
|
||||
}
|
||||
return changeEvent, nil
|
||||
}
|
||||
|
||||
type FeaturesChanges func(*FeaturesSetEvent)
|
||||
|
||||
func ChangeTierName(tierName string) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.TierName = &tierName
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeTierDescription(tierDescription string) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.TierDescription = &tierDescription
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeState(State domain.FeaturesState) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.State = &State
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeStateDescription(statusDescription string) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.StateDescription = &statusDescription
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeAuditLogRetention(retention time.Duration) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.AuditLogRetention = &retention
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeLoginPolicyFactors(loginPolicyFactors bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.LoginPolicyFactors = &loginPolicyFactors
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeLoginPolicyIDP(loginPolicyIDP bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.LoginPolicyIDP = &loginPolicyIDP
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeLoginPolicyPasswordless(loginPolicyPasswordless bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.LoginPolicyPasswordless = &loginPolicyPasswordless
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeLoginPolicyRegistration(loginPolicyRegistration bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.LoginPolicyRegistration = &loginPolicyRegistration
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeLoginPolicyUsernameLogin(loginPolicyUsernameLogin bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.LoginPolicyUsernameLogin = &loginPolicyUsernameLogin
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeLoginPolicyPasswordReset(loginPolicyPasswordReset bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.LoginPolicyPasswordReset = &loginPolicyPasswordReset
|
||||
}
|
||||
}
|
||||
|
||||
func ChangePasswordComplexityPolicy(passwordComplexityPolicy bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.PasswordComplexityPolicy = &passwordComplexityPolicy
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeLabelPolicyPrivateLabel(labelPolicyPrivateLabel bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.LabelPolicyPrivateLabel = &labelPolicyPrivateLabel
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeLabelPolicyWatermark(labelPolicyWatermark bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.LabelPolicyWatermark = &labelPolicyWatermark
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeCustomDomain(customDomain bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.CustomDomain = &customDomain
|
||||
}
|
||||
}
|
||||
|
||||
func ChangePrivacyPolicy(privacyPolicy bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.PrivacyPolicy = &privacyPolicy
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeMetadataUser(metadataUser bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.MetadataUser = &metadataUser
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeCustomTextMessage(customTextMessage bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.CustomTextMessage = &customTextMessage
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeCustomTextLogin(customTextLogin bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.CustomTextLogin = &customTextLogin
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeLockoutPolicy(lockoutPolicy bool) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.LockoutPolicy = &lockoutPolicy
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeActionsAllowed(allowedType domain.ActionsAllowed) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.ActionsAllowed = &allowedType
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeMaxActions(maxActions int) func(event *FeaturesSetEvent) {
|
||||
return func(e *FeaturesSetEvent) {
|
||||
e.MaxActions = &maxActions
|
||||
}
|
||||
}
|
||||
|
||||
func FeaturesSetEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
e := &FeaturesSetEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "FEATURES-fdgDg", "unable to unmarshal features")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type FeaturesRemovedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
}
|
||||
|
||||
func (e *FeaturesRemovedEvent) Data() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *FeaturesRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *FeaturesRemovedEvent) Assets() []*eventstore.Asset {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewFeaturesRemovedEvent(base *eventstore.BaseEvent) *FeaturesRemovedEvent {
|
||||
return &FeaturesRemovedEvent{
|
||||
BaseEvent: *base,
|
||||
}
|
||||
}
|
||||
|
||||
func FeaturesRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
return &FeaturesRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}, nil
|
||||
}
|
@@ -85,7 +85,6 @@ func RegisterEventMappers(es *eventstore.Eventstore) {
|
||||
RegisterFilterEventMapper(CustomTextSetEventType, CustomTextSetEventMapper).
|
||||
RegisterFilterEventMapper(CustomTextRemovedEventType, CustomTextRemovedEventMapper).
|
||||
RegisterFilterEventMapper(CustomTextTemplateRemovedEventType, CustomTextTemplateRemovedEventMapper).
|
||||
RegisterFilterEventMapper(FeaturesSetEventType, FeaturesSetEventMapper).
|
||||
RegisterFilterEventMapper(InstanceDomainAddedEventType, DomainAddedEventMapper).
|
||||
RegisterFilterEventMapper(InstanceDomainPrimarySetEventType, DomainPrimarySetEventMapper).
|
||||
RegisterFilterEventMapper(InstanceDomainRemovedEventType, DomainRemovedEventMapper).
|
||||
|
@@ -1,44 +0,0 @@
|
||||
package instance
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
||||
"github.com/zitadel/zitadel/internal/repository/features"
|
||||
)
|
||||
|
||||
var (
|
||||
FeaturesSetEventType = instanceEventTypePrefix + features.FeaturesSetEventType
|
||||
)
|
||||
|
||||
type FeaturesSetEvent struct {
|
||||
features.FeaturesSetEvent
|
||||
}
|
||||
|
||||
func NewFeaturesSetEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []features.FeaturesChanges,
|
||||
) (*FeaturesSetEvent, error) {
|
||||
changedEvent, err := features.NewFeaturesSetEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
FeaturesSetEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &FeaturesSetEvent{FeaturesSetEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func FeaturesSetEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
e, err := features.FeaturesSetEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &FeaturesSetEvent{FeaturesSetEvent: *e.(*features.FeaturesSetEvent)}, nil
|
||||
}
|
@@ -77,8 +77,6 @@ func RegisterEventMappers(es *eventstore.Eventstore) {
|
||||
RegisterFilterEventMapper(IDPOIDCConfigChangedEventType, IDPOIDCConfigChangedEventMapper).
|
||||
RegisterFilterEventMapper(IDPJWTConfigAddedEventType, IDPJWTConfigAddedEventMapper).
|
||||
RegisterFilterEventMapper(IDPJWTConfigChangedEventType, IDPJWTConfigChangedEventMapper).
|
||||
RegisterFilterEventMapper(FeaturesSetEventType, FeaturesSetEventMapper).
|
||||
RegisterFilterEventMapper(FeaturesRemovedEventType, FeaturesRemovedEventMapper).
|
||||
RegisterFilterEventMapper(TriggerActionsSetEventType, TriggerActionsSetEventMapper).
|
||||
RegisterFilterEventMapper(TriggerActionsCascadeRemovedEventType, TriggerActionsCascadeRemovedEventMapper).
|
||||
RegisterFilterEventMapper(FlowClearedEventType, FlowClearedEventMapper)
|
||||
|
@@ -1,72 +0,0 @@
|
||||
package org
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/eventstore/repository"
|
||||
"github.com/zitadel/zitadel/internal/repository/features"
|
||||
)
|
||||
|
||||
var (
|
||||
FeaturesSetEventType = orgEventTypePrefix + features.FeaturesSetEventType
|
||||
FeaturesRemovedEventType = orgEventTypePrefix + features.FeaturesRemovedEventType
|
||||
)
|
||||
|
||||
type FeaturesSetEvent struct {
|
||||
features.FeaturesSetEvent
|
||||
}
|
||||
|
||||
func NewFeaturesSetEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
changes []features.FeaturesChanges,
|
||||
) (*FeaturesSetEvent, error) {
|
||||
changedEvent, err := features.NewFeaturesSetEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
FeaturesSetEventType),
|
||||
changes,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &FeaturesSetEvent{FeaturesSetEvent: *changedEvent}, nil
|
||||
}
|
||||
|
||||
func FeaturesSetEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
e, err := features.FeaturesSetEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &FeaturesSetEvent{FeaturesSetEvent: *e.(*features.FeaturesSetEvent)}, nil
|
||||
}
|
||||
|
||||
type FeaturesRemovedEvent struct {
|
||||
features.FeaturesRemovedEvent
|
||||
}
|
||||
|
||||
func NewFeaturesRemovedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
) *FeaturesRemovedEvent {
|
||||
return &FeaturesRemovedEvent{
|
||||
FeaturesRemovedEvent: *features.NewFeaturesRemovedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
FeaturesRemovedEventType),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func FeaturesRemovedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
e, err := features.FeaturesRemovedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &FeaturesRemovedEvent{FeaturesRemovedEvent: *e.(*features.FeaturesRemovedEvent)}, nil
|
||||
}
|
Reference in New Issue
Block a user