feat: uniqueness (#1190)

* feat: uniqueness on events

* fix: some tests

* fix: add unique username

* fix: nice error message

* fix: add unique test

* fix: add unique test

* fix: add unique constraint to events

* fix: correct unique constraint on user events

* fix: remove user constraint

* fix: add unique constraints

* fix: add unique constraints

* fix: add unique constraints

* fix: unnique constraints without interface

* fix: unique idp config

* fix: unique constraint comments

* fix: unique constraints in one table

* fix: unique constraints error

* fix: fix unique constraint on create user

* fix: fix unique constraint on create project

* fix: fix unique constraint on idp configs
This commit is contained in:
Fabi
2021-01-21 10:49:38 +01:00
committed by GitHub
parent c2e6e782a8
commit 28bfe72930
62 changed files with 1046 additions and 313 deletions

View File

@@ -24,6 +24,10 @@ func (e *LabelPolicyAddedEvent) Data() interface{} {
return e
}
func (e *LabelPolicyAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewLabelPolicyAddedEvent(
base *eventstore.BaseEvent,
primaryColor,
@@ -61,6 +65,10 @@ func (e *LabelPolicyChangedEvent) Data() interface{} {
return e
}
func (e *LabelPolicyChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewLabelPolicyChangedEvent(
base *eventstore.BaseEvent,
changes []LabelPolicyChanges,
@@ -112,6 +120,10 @@ func (e *LabelPolicyRemovedEvent) Data() interface{} {
return nil
}
func (e *LabelPolicyRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewLabelPolicyRemovedEvent(base *eventstore.BaseEvent) *LabelPolicyRemovedEvent {
return &LabelPolicyRemovedEvent{
BaseEvent: *base,

View File

@@ -29,6 +29,10 @@ func (e *LoginPolicyAddedEvent) Data() interface{} {
return e
}
func (e *LoginPolicyAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewLoginPolicyAddedEvent(
base *eventstore.BaseEvent,
allowUserNamePassword,
@@ -77,6 +81,10 @@ func (e *LoginPolicyChangedEvent) Data() interface{} {
return e
}
func (e *LoginPolicyChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewLoginPolicyChangedEvent(
base *eventstore.BaseEvent,
changes []LoginPolicyChanges,
@@ -146,6 +154,10 @@ func (e *LoginPolicyRemovedEvent) Data() interface{} {
return nil
}
func (e *LoginPolicyRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewLoginPolicyRemovedEvent(base *eventstore.BaseEvent) *LoginPolicyRemovedEvent {
return &LoginPolicyRemovedEvent{
BaseEvent: *base,

View File

@@ -51,6 +51,10 @@ func (e *SecondFactorAddedEvent) Data() interface{} {
return e
}
func (e *SecondFactorAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
type SecondFactorRemovedEvent struct {
eventstore.BaseEvent `json:"-"`
MFAType domain.SecondFactorType `json:"mfaType"`
@@ -83,6 +87,10 @@ func (e *SecondFactorRemovedEvent) Data() interface{} {
return e
}
func (e *SecondFactorRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
type MultiFactorAddedEvent struct {
eventstore.BaseEvent `json:"-"`
@@ -116,6 +124,10 @@ func (e *MultiFactorAddedEvent) Data() interface{} {
return e
}
func (e *MultiFactorAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
type MultiFactorRemovedEvent struct {
eventstore.BaseEvent `json:"-"`
MFAType domain.MultiFactorType `json:"mfaType"`
@@ -147,3 +159,7 @@ func MultiFactorRemovedEventMapper(event *repository.Event) (eventstore.EventRea
func (e *MultiFactorRemovedEvent) Data() interface{} {
return e
}
func (e *MultiFactorRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}

View File

@@ -25,6 +25,10 @@ func (e *IdentityProviderAddedEvent) Data() interface{} {
return e
}
func (e *IdentityProviderAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewIdentityProviderAddedEvent(
base *eventstore.BaseEvent,
idpConfigID string,
@@ -61,6 +65,10 @@ func (e *IdentityProviderRemovedEvent) Data() interface{} {
return e
}
func (e *IdentityProviderRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewIdentityProviderRemovedEvent(
base *eventstore.BaseEvent,
idpConfigID string,

View File

@@ -24,6 +24,10 @@ func (e *OrgIAMPolicyAddedEvent) Data() interface{} {
return e
}
func (e *OrgIAMPolicyAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewOrgIAMPolicyAddedEvent(
base *eventstore.BaseEvent,
userLoginMustBeDomain bool,
@@ -58,6 +62,10 @@ func (e *OrgIAMPolicyChangedEvent) Data() interface{} {
return e
}
func (e *OrgIAMPolicyChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewOrgIAMPolicyChangedEvent(
base *eventstore.BaseEvent,
changes []OrgIAMPolicyChanges,
@@ -103,6 +111,10 @@ func (e *OrgIAMPolicyRemovedEvent) Data() interface{} {
return nil
}
func (e *OrgIAMPolicyRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewOrgIAMPolicyRemovedEvent(base *eventstore.BaseEvent) *OrgIAMPolicyRemovedEvent {
return &OrgIAMPolicyRemovedEvent{
BaseEvent: *base,

View File

@@ -24,6 +24,10 @@ func (e *PasswordAgePolicyAddedEvent) Data() interface{} {
return e
}
func (e *PasswordAgePolicyAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewPasswordAgePolicyAddedEvent(
base *eventstore.BaseEvent,
expireWarnDays,
@@ -61,6 +65,10 @@ func (e *PasswordAgePolicyChangedEvent) Data() interface{} {
return e
}
func (e *PasswordAgePolicyChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewPasswordAgePolicyChangedEvent(
base *eventstore.BaseEvent,
changes []PasswordAgePolicyChanges,
@@ -112,6 +120,10 @@ func (e *PasswordAgePolicyRemovedEvent) Data() interface{} {
return nil
}
func (e *PasswordAgePolicyRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewPasswordAgePolicyRemovedEvent(base *eventstore.BaseEvent) *PasswordAgePolicyRemovedEvent {
return &PasswordAgePolicyRemovedEvent{
BaseEvent: *base,

View File

@@ -28,6 +28,10 @@ func (e *PasswordComplexityPolicyAddedEvent) Data() interface{} {
return e
}
func (e *PasswordComplexityPolicyAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewPasswordComplexityPolicyAddedEvent(
base *eventstore.BaseEvent,
minLength uint64,
@@ -73,6 +77,10 @@ func (e *PasswordComplexityPolicyChangedEvent) Data() interface{} {
return e
}
func (e *PasswordComplexityPolicyChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewPasswordComplexityPolicyChangedEvent(
base *eventstore.BaseEvent,
changes []PasswordComplexityPolicyChanges,
@@ -142,6 +150,10 @@ func (e *PasswordComplexityPolicyRemovedEvent) Data() interface{} {
return nil
}
func (e *PasswordComplexityPolicyRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewPasswordComplexityPolicyRemovedEvent(base *eventstore.BaseEvent) *PasswordComplexityPolicyRemovedEvent {
return &PasswordComplexityPolicyRemovedEvent{
BaseEvent: *base,

View File

@@ -25,6 +25,10 @@ func (e *PasswordLockoutPolicyAddedEvent) Data() interface{} {
return e
}
func (e *PasswordLockoutPolicyAddedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewPasswordLockoutPolicyAddedEvent(
base *eventstore.BaseEvent,
maxAttempts uint64,
@@ -62,6 +66,10 @@ func (e *PasswordLockoutPolicyChangedEvent) Data() interface{} {
return e
}
func (e *PasswordLockoutPolicyChangedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewPasswordLockoutPolicyChangedEvent(
base *eventstore.BaseEvent,
changes []PasswordLockoutPolicyChanges,
@@ -113,6 +121,10 @@ func (e *PasswordLockoutPolicyRemovedEvent) Data() interface{} {
return nil
}
func (e *PasswordLockoutPolicyRemovedEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
return nil
}
func NewPasswordLockoutPolicyRemovedEvent(base *eventstore.BaseEvent) *PasswordLockoutPolicyRemovedEvent {
return &PasswordLockoutPolicyRemovedEvent{
BaseEvent: *base,