iam events

This commit is contained in:
adlerhurst
2020-11-06 17:25:07 +01:00
parent f4bd5ddcbc
commit f7f810caa5
17 changed files with 496 additions and 107 deletions

View File

@@ -0,0 +1,44 @@
package policy
import (
"context"
"github.com/caos/zitadel/internal/eventstore/v2"
)
const (
LabelPolicyAddedEventType = "policy.label.added"
)
type LabelPolicyAddedEvent struct {
eventstore.BaseEvent `json:"-"`
PrimaryColor string `json:"primaryColor"`
SecondaryColor string `json:"secondaryColor"`
}
func (e *LabelPolicyAddedEvent) CheckPrevious() bool {
return true
}
func (e *LabelPolicyAddedEvent) Data() interface{} {
return e
}
func NewLabelPolicyAddedEvent(
ctx context.Context,
service string,
primaryColor,
secondaryColor string,
) *LabelPolicyAddedEvent {
return &LabelPolicyAddedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
service,
LabelPolicyAddedEventType,
),
PrimaryColor: primaryColor,
SecondaryColor: secondaryColor,
}
}

View File

@@ -0,0 +1,48 @@
package policy
import (
"context"
"github.com/caos/zitadel/internal/eventstore/v2"
)
const (
LoginPolicyAddedEventType = "policy.login.added"
)
type LoginPolicyAddedEvent struct {
eventstore.BaseEvent `json:"-"`
AllowUserNamePassword bool `json:"allowUsernamePassword"`
AllowRegister bool `json:"allowRegister"`
AllowExternalIDP bool `json:"allowExternalIdp"`
// TODO: IDPProviders
}
func (e *LoginPolicyAddedEvent) CheckPrevious() bool {
return true
}
func (e *LoginPolicyAddedEvent) Data() interface{} {
return e
}
func NewLoginPolicyAddedEvent(
ctx context.Context,
service string,
allowUserNamePassword,
allowRegister,
allowExternalIDP bool,
) *LoginPolicyAddedEvent {
return &LoginPolicyAddedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
service,
LoginPolicyAddedEventType,
),
AllowExternalIDP: allowExternalIDP,
AllowRegister: allowRegister,
AllowUserNamePassword: allowUserNamePassword,
}
}

View File

@@ -0,0 +1,41 @@
package policy
import (
"context"
"github.com/caos/zitadel/internal/eventstore/v2"
)
const (
OrgIAMPolicyAddedEventType = "policy.org.iam.added"
)
type OrgIAMPolicyAddedEvent struct {
eventstore.BaseEvent `json:"-"`
UserLoginMustBeDomain bool `json:"allowUsernamePassword"`
}
func (e *OrgIAMPolicyAddedEvent) CheckPrevious() bool {
return true
}
func (e *OrgIAMPolicyAddedEvent) Data() interface{} {
return e
}
func NewOrgIAMPolicyAddedEvent(
ctx context.Context,
service string,
userLoginMustBeDomain bool,
) *OrgIAMPolicyAddedEvent {
return &OrgIAMPolicyAddedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
service,
OrgIAMPolicyAddedEventType,
),
UserLoginMustBeDomain: userLoginMustBeDomain,
}
}

View File

@@ -0,0 +1,43 @@
package policy
import (
"context"
"github.com/caos/zitadel/internal/eventstore/v2"
)
const (
PasswordAgePolicyAddedEventType = "policy.password.age.added"
)
type PasswordAgePolicyAddedEvent struct {
eventstore.BaseEvent `json:"-"`
ExpireWarnDays int `json:"expireWarnDays"`
MaxAgeDays int `json:"maxAgeDays"`
}
func (e *PasswordAgePolicyAddedEvent) CheckPrevious() bool {
return true
}
func (e *PasswordAgePolicyAddedEvent) Data() interface{} {
return e
}
func NewPasswordAgePolicyAddedEvent(
ctx context.Context,
service string,
expireWarnDays,
maxAgeDays int,
) *PasswordAgePolicyAddedEvent {
return &PasswordAgePolicyAddedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
service,
PasswordAgePolicyAddedEventType,
),
ExpireWarnDays: expireWarnDays,
MaxAgeDays: maxAgeDays,
}
}

View File

@@ -0,0 +1,53 @@
package policy
import (
"context"
"github.com/caos/zitadel/internal/eventstore/v2"
)
const (
PasswordComplexityPolicyAddedEventType = "policy.password.complexity.added"
)
type PasswordComplexityPolicyAddedEvent struct {
eventstore.BaseEvent `json:"-"`
MinLength int `json:"minLength"`
HasLowercase bool `json:"hasLowercase"`
HasUpperCase bool `json:"hasUppercase"`
HasNumber bool `json:"hasNumber"`
HasSymbol bool `json:"hasSymbol"`
}
func (e *PasswordComplexityPolicyAddedEvent) CheckPrevious() bool {
return true
}
func (e *PasswordComplexityPolicyAddedEvent) Data() interface{} {
return e
}
func NewPasswordComplexityPolicyAddedEvent(
ctx context.Context,
service string,
hasLowerCase,
hasUpperCase,
hasNumber,
hasSymbol bool,
minLength int,
) *PasswordComplexityPolicyAddedEvent {
return &PasswordComplexityPolicyAddedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
service,
PasswordComplexityPolicyAddedEventType,
),
HasLowercase: hasLowerCase,
HasNumber: hasNumber,
HasSymbol: hasSymbol,
HasUpperCase: hasUpperCase,
MinLength: minLength,
}
}

View File

@@ -0,0 +1,44 @@
package policy
import (
"context"
"github.com/caos/zitadel/internal/eventstore/v2"
)
const (
PasswordLockoutPolicyAddedEventType = "policy.password.lockout.added"
)
type PasswordLockoutPolicyAddedEvent struct {
eventstore.BaseEvent `json:"-"`
MaxAttempts int `json:"maxAttempts"`
ShowLockOutFailures bool `json:"showLockOutFailures"`
}
func (e *PasswordLockoutPolicyAddedEvent) CheckPrevious() bool {
return true
}
func (e *PasswordLockoutPolicyAddedEvent) Data() interface{} {
return e
}
func NewPasswordLockoutPolicyAddedEvent(
ctx context.Context,
service string,
maxAttempts int,
showLockOutFailures bool,
) *PasswordLockoutPolicyAddedEvent {
return &PasswordLockoutPolicyAddedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
service,
LabelPolicyAddedEventType,
),
MaxAttempts: maxAttempts,
ShowLockOutFailures: showLockOutFailures,
}
}