This commit is contained in:
adlerhurst
2020-11-11 17:51:44 +01:00
parent 4e0577e74f
commit 720fea4bcc
19 changed files with 556 additions and 301 deletions

View File

@@ -19,6 +19,13 @@ type LabelPolicyAggregate struct {
SecondaryColor string
}
type LabelPolicyReadModel struct {
eventstore.ReadModel
PrimaryColor string
SecondaryColor string
}
type LabelPolicyAddedEvent struct {
eventstore.BaseEvent `json:"-"`
@@ -53,8 +60,8 @@ func NewLabelPolicyAddedEvent(
type LabelPolicyChangedEvent struct {
eventstore.BaseEvent `json:"-"`
current *LabelPolicyAggregate
changed *LabelPolicyAggregate
PrimaryColor string `json:"primaryColor,omitempty"`
SecondaryColor string `json:"secondaryColor,omitempty"`
}
func (e *LabelPolicyChangedEvent) CheckPrevious() bool {
@@ -62,15 +69,7 @@ func (e *LabelPolicyChangedEvent) CheckPrevious() bool {
}
func (e *LabelPolicyChangedEvent) Data() interface{} {
changes := map[string]interface{}{}
if e.current.PrimaryColor != e.changed.PrimaryColor {
changes["primaryColor"] = e.changed.PrimaryColor
}
if e.current.SecondaryColor != e.changed.SecondaryColor {
changes["secondaryColor"] = e.changed.SecondaryColor
}
return changes
return e
}
func NewLabelPolicyChangedEvent(
@@ -79,14 +78,20 @@ func NewLabelPolicyChangedEvent(
changed *LabelPolicyAggregate,
) *LabelPolicyChangedEvent {
return &LabelPolicyChangedEvent{
e := &LabelPolicyChangedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
LabelPolicyChangedEventType,
),
current: current,
changed: changed,
}
if current.PrimaryColor != changed.PrimaryColor {
e.PrimaryColor = changed.PrimaryColor
}
if current.SecondaryColor != changed.SecondaryColor {
e.SecondaryColor = changed.SecondaryColor
}
return e
}
type LabelPolicyRemovedEvent struct {
@@ -101,14 +106,11 @@ func (e *LabelPolicyRemovedEvent) Data() interface{} {
return nil
}
func NewLabelPolicyRemovedEvent(
ctx context.Context,
) *LabelPolicyRemovedEvent {
func NewLabelPolicyRemovedEvent(ctx context.Context) *LabelPolicyRemovedEvent {
return &LabelPolicyRemovedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
LabelPolicyChangedEventType,
LabelPolicyRemovedEventType,
),
}
}

View File

@@ -20,6 +20,14 @@ type LoginPolicyAggregate struct {
AllowExternalIDP bool
}
type LoginPolicyReadModel struct {
eventstore.ReadModel
AllowUserNamePassword bool
AllowRegister bool
AllowExternalIDP bool
}
type LoginPolicyAddedEvent struct {
eventstore.BaseEvent `json:"-"`
@@ -58,8 +66,9 @@ func NewLoginPolicyAddedEvent(
type LoginPolicyChangedEvent struct {
eventstore.BaseEvent `json:"-"`
current *LoginPolicyAggregate
changed *LoginPolicyAggregate
AllowUserNamePassword bool `json:"allowUsernamePassword,omitempty"`
AllowRegister bool `json:"allowRegister"`
AllowExternalIDP bool `json:"allowExternalIdp"`
}
func (e *LoginPolicyChangedEvent) CheckPrevious() bool {
@@ -67,18 +76,7 @@ func (e *LoginPolicyChangedEvent) CheckPrevious() bool {
}
func (e *LoginPolicyChangedEvent) Data() interface{} {
changes := map[string]interface{}{}
if e.current.AllowExternalIDP != e.changed.AllowExternalIDP {
changes["allowUsernamePassword"] = e.changed.AllowExternalIDP
}
if e.current.AllowRegister != e.changed.AllowRegister {
changes["allowRegister"] = e.changed.AllowExternalIDP
}
if e.current.AllowExternalIDP != e.changed.AllowExternalIDP {
changes["allowExternalIdp"] = e.changed.AllowExternalIDP
}
return changes
return e
}
func NewLoginPolicyChangedEvent(
@@ -87,12 +85,24 @@ func NewLoginPolicyChangedEvent(
changed *LoginPolicyAggregate,
) *LoginPolicyChangedEvent {
return &LoginPolicyChangedEvent{
e := &LoginPolicyChangedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
LoginPolicyChangedEventType,
),
}
if current.AllowUserNamePassword != changed.AllowUserNamePassword {
e.AllowUserNamePassword = changed.AllowUserNamePassword
}
if current.AllowRegister != changed.AllowRegister {
e.AllowRegister = changed.AllowRegister
}
if current.AllowExternalIDP != changed.AllowExternalIDP {
e.AllowExternalIDP = changed.AllowExternalIDP
}
return e
}
type LoginPolicyRemovedEvent struct {

View File

@@ -10,6 +10,18 @@ const (
OrgIAMPolicyAddedEventType = "policy.org.iam.added"
)
type OrgIAMPolicyAggregate struct {
eventstore.Aggregate
UserLoginMustBeDomain bool
}
type OrgIAMPolicyReadModel struct {
eventstore.ReadModel
UserLoginMustBeDomain bool
}
type OrgIAMPolicyAddedEvent struct {
eventstore.BaseEvent `json:"-"`

View File

@@ -19,6 +19,13 @@ type PasswordAgePolicyAggregate struct {
MaxAgeDays int
}
type PasswordAgePolicyReadModel struct {
eventstore.ReadModel
ExpireWarnDays int
MaxAgeDays int
}
type PasswordAgePolicyAddedEvent struct {
eventstore.BaseEvent `json:"-"`
@@ -53,8 +60,8 @@ func NewPasswordAgePolicyAddedEvent(
type PasswordAgePolicyChangedEvent struct {
eventstore.BaseEvent `json:"-"`
current *PasswordAgePolicyAggregate
changed *PasswordAgePolicyAggregate
ExpireWarnDays int `json:"expireWarnDays,omitempty"`
MaxAgeDays int `json:"maxAgeDays,omitempty"`
}
func (e *PasswordAgePolicyChangedEvent) CheckPrevious() bool {
@@ -62,16 +69,7 @@ func (e *PasswordAgePolicyChangedEvent) CheckPrevious() bool {
}
func (e *PasswordAgePolicyChangedEvent) Data() interface{} {
changes := map[string]interface{}{}
if e.current.ExpireWarnDays != e.changed.ExpireWarnDays {
changes["expireWarnDays"] = e.changed.ExpireWarnDays
}
if e.current.MaxAgeDays != e.changed.MaxAgeDays {
changes["maxAgeDays"] = e.changed.ExpireWarnDays
}
return changes
return e
}
func NewPasswordAgePolicyChangedEvent(
@@ -80,14 +78,21 @@ func NewPasswordAgePolicyChangedEvent(
changed *PasswordAgePolicyAggregate,
) *PasswordAgePolicyChangedEvent {
return &PasswordAgePolicyChangedEvent{
e := &PasswordAgePolicyChangedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
PasswordAgePolicyChangedEventType,
),
current: current,
changed: changed,
}
if current.ExpireWarnDays != changed.ExpireWarnDays {
e.ExpireWarnDays = changed.ExpireWarnDays
}
if current.MaxAgeDays != changed.MaxAgeDays {
e.MaxAgeDays = changed.ExpireWarnDays
}
return e
}
type PasswordAgePolicyRemovedEvent struct {
@@ -111,7 +116,7 @@ func NewPasswordAgePolicyRemovedEvent(
return &PasswordAgePolicyChangedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
PasswordAgePolicyChangedEventType,
PasswordAgePolicyRemovedEventType,
),
}
}

View File

@@ -13,6 +13,18 @@ const (
)
type PasswordComplexityPolicyAggregate struct {
eventstore.Aggregate
MinLength int
HasLowercase bool
HasUpperCase bool
HasNumber bool
HasSymbol bool
}
type PasswordComplexityPolicyReadModel struct {
eventstore.ReadModel
MinLength int
HasLowercase bool
HasUpperCase bool
@@ -63,8 +75,11 @@ func NewPasswordComplexityPolicyAddedEvent(
type PasswordComplexityPolicyChangedEvent struct {
eventstore.BaseEvent `json:"-"`
current *PasswordComplexityPolicyAggregate
changed *PasswordComplexityPolicyAggregate
MinLength int `json:"minLength"`
HasLowercase bool `json:"hasLowercase"`
HasUpperCase bool `json:"hasUppercase"`
HasNumber bool `json:"hasNumber"`
HasSymbol bool `json:"hasSymbol"`
}
func (e *PasswordComplexityPolicyChangedEvent) CheckPrevious() bool {
@@ -72,25 +87,7 @@ func (e *PasswordComplexityPolicyChangedEvent) CheckPrevious() bool {
}
func (e *PasswordComplexityPolicyChangedEvent) Data() interface{} {
changes := map[string]interface{}{}
if e.current.MinLength != e.changed.MinLength {
changes["minLength"] = e.changed.MinLength
}
if e.current.HasLowercase != e.changed.HasLowercase {
changes["hasLowercase"] = e.changed.HasLowercase
}
if e.current.HasUpperCase != e.changed.HasUpperCase {
changes["hasUppercase"] = e.changed.HasUpperCase
}
if e.current.HasNumber != e.changed.HasNumber {
changes["hasNumber"] = e.changed.HasNumber
}
if e.current.HasSymbol != e.changed.HasSymbol {
changes["hasSymbol"] = e.changed.HasSymbol
}
return changes
return e
}
func NewPasswordComplexityPolicyChangedEvent(
@@ -99,14 +96,30 @@ func NewPasswordComplexityPolicyChangedEvent(
changed *PasswordComplexityPolicyAggregate,
) *PasswordComplexityPolicyChangedEvent {
return &PasswordComplexityPolicyChangedEvent{
e := &PasswordComplexityPolicyChangedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
PasswordComplexityPolicyAddedEventType,
PasswordComplexityPolicyChangedEventType,
),
current: current,
changed: changed,
}
if current.MinLength != changed.MinLength {
e.MinLength = changed.MinLength
}
if current.HasLowercase != changed.HasLowercase {
e.HasLowercase = changed.HasLowercase
}
if current.HasUpperCase != changed.HasUpperCase {
e.HasUpperCase = changed.HasUpperCase
}
if current.HasNumber != changed.HasNumber {
e.HasNumber = changed.HasNumber
}
if current.HasSymbol != changed.HasSymbol {
e.HasSymbol = changed.HasSymbol
}
return e
}
type PasswordComplexityPolicyRemovedEvent struct {
@@ -128,7 +141,7 @@ func NewPasswordComplexityPolicyRemovedEvent(
return &PasswordComplexityPolicyRemovedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
PasswordComplexityPolicyChangedEventType,
PasswordComplexityPolicyRemovedEventType,
),
}
}

View File

@@ -7,16 +7,25 @@ import (
)
const (
PasswordLockoutPolicyAddedEventType = "policy.password.lockout.added"
PasswordLockoutPolicyAddedEventType = "policy.password.lockout.added"
PasswordLockoutPolicyChangedEventType = "policy.password.lockout.changed"
PasswordLockoutPolicyRemovedEventType = "policy.password.lockout.removed"
)
type PasswordLockoutAggregate struct {
type PasswordLockoutPolicyAggregate struct {
eventstore.Aggregate
MaxAttempts int
ShowLockOutFailures bool
}
type PasswordLockoutPolicyReadModel struct {
eventstore.ReadModel
MaxAttempts int
ShowLockOutFailures bool
}
type PasswordLockoutPolicyAddedEvent struct {
eventstore.BaseEvent `json:"-"`
@@ -41,7 +50,7 @@ func NewPasswordLockoutPolicyAddedEvent(
return &PasswordLockoutPolicyAddedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
LabelPolicyAddedEventType,
PasswordLockoutPolicyAddedEventType,
),
MaxAttempts: maxAttempts,
ShowLockOutFailures: showLockOutFailures,
@@ -51,8 +60,8 @@ func NewPasswordLockoutPolicyAddedEvent(
type PasswordLockoutPolicyChangedEvent struct {
eventstore.BaseEvent `json:"-"`
current *PasswordLockoutAggregate
changed *PasswordLockoutAggregate
MaxAttempts int `json:"maxAttempts,omitempty"`
ShowLockOutFailures bool `json:"showLockOutFailures,omitempty"`
}
func (e *PasswordLockoutPolicyChangedEvent) CheckPrevious() bool {
@@ -60,32 +69,30 @@ func (e *PasswordLockoutPolicyChangedEvent) CheckPrevious() bool {
}
func (e *PasswordLockoutPolicyChangedEvent) Data() interface{} {
changes := map[string]interface{}{}
if e.current.MaxAttempts != e.changed.MaxAttempts {
changes["maxAttempts"] = e.changed.MaxAttempts
}
if e.current.ShowLockOutFailures != e.changed.ShowLockOutFailures {
changes["showLockOutFailures"] = e.changed.ShowLockOutFailures
}
return changes
return e
}
func NewPasswordLockoutPolicyChangedEvent(
ctx context.Context,
current,
changed *PasswordLockoutAggregate,
changed *PasswordLockoutPolicyAggregate,
) *PasswordLockoutPolicyChangedEvent {
return &PasswordLockoutPolicyChangedEvent{
e := &PasswordLockoutPolicyChangedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
LabelPolicyAddedEventType,
PasswordLockoutPolicyChangedEventType,
),
current: current,
changed: changed,
}
if current.MaxAttempts != changed.MaxAttempts {
e.MaxAttempts = changed.MaxAttempts
}
if current.ShowLockOutFailures != changed.ShowLockOutFailures {
e.ShowLockOutFailures = changed.ShowLockOutFailures
}
return e
}
type PasswordLockoutPolicyRemovedEvent struct {
@@ -107,7 +114,7 @@ func NewPasswordLockoutPolicyRemovedEvent(
return &PasswordLockoutPolicyRemovedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
LabelPolicyAddedEventType,
PasswordLockoutPolicyRemovedEventType,
),
}
}