mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:17:32 +00:00
iam events
This commit is contained in:
@@ -5,32 +5,3 @@ import "github.com/caos/zitadel/internal/eventstore/v2"
|
||||
type Aggregate struct {
|
||||
eventstore.Aggregate
|
||||
}
|
||||
|
||||
type Step int8
|
||||
|
||||
type SetupStepEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Step Step
|
||||
//Done if the setup is started earlier
|
||||
Done bool `json:"-"`
|
||||
}
|
||||
|
||||
func (e *SetupStepEvent) CheckPrevious() bool {
|
||||
return e.Type() == "iam.setup.started"
|
||||
}
|
||||
|
||||
//Type implements event
|
||||
func (e *SetupStepEvent) Type() eventstore.EventType {
|
||||
if e.Done {
|
||||
return "iam.setup.done"
|
||||
}
|
||||
return "iam.setup.started"
|
||||
}
|
||||
|
||||
func (e *SetupStepEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
type MemberAddedEvent struct {
|
||||
}
|
||||
|
36
internal/v2/repository/iam/event_iam_added.go
Normal file
36
internal/v2/repository/iam/event_iam_added.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package iam
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
GlobalOrgSetEventType eventstore.EventType = "iam.global.org.set"
|
||||
)
|
||||
|
||||
type GlobalOrgSetEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
OrgID string `json:"globalOrgId"`
|
||||
}
|
||||
|
||||
func (e *GlobalOrgSetEvent) CheckPrevious() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *GlobalOrgSetEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func NewGlobalOrgSetEventEvent(ctx context.Context, service, orgID string) *GlobalOrgSetEvent {
|
||||
return &GlobalOrgSetEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
service,
|
||||
GlobalOrgSetEventType,
|
||||
),
|
||||
OrgID: orgID,
|
||||
}
|
||||
}
|
36
internal/v2/repository/iam/event_iam_project_set.go
Normal file
36
internal/v2/repository/iam/event_iam_project_set.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package iam
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
IAMProjectSetEventType eventstore.EventType = "iam.project.iam.set"
|
||||
)
|
||||
|
||||
type IAMProjectSetEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
ProjectID string `json:"iamProjectId"`
|
||||
}
|
||||
|
||||
func (e *IAMProjectSetEvent) CheckPrevious() bool {
|
||||
return e.Type() == SetupStartedEventType
|
||||
}
|
||||
|
||||
func (e *IAMProjectSetEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func NewIAMProjectSetEvent(ctx context.Context, service, projectID string) *IAMProjectSetEvent {
|
||||
return &IAMProjectSetEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
service,
|
||||
SetupDoneEventType,
|
||||
),
|
||||
ProjectID: projectID,
|
||||
}
|
||||
}
|
48
internal/v2/repository/iam/events_step.go
Normal file
48
internal/v2/repository/iam/events_step.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package iam
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
SetupDoneEventType eventstore.EventType = "iam.setup.done"
|
||||
SetupStartedEventType eventstore.EventType = "iam.setup.started"
|
||||
)
|
||||
|
||||
type Step int8
|
||||
|
||||
type SetupStepEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Step Step `json:"Step"`
|
||||
}
|
||||
|
||||
func (e *SetupStepEvent) CheckPrevious() bool {
|
||||
return e.Type() == SetupStartedEventType
|
||||
}
|
||||
|
||||
func (e *SetupStepEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func NewSetupStepDoneEvent(ctx context.Context, service string) *SetupStepEvent {
|
||||
return &SetupStepEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
service,
|
||||
SetupDoneEventType,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func NewSetupStepStartedEvent(ctx context.Context, service string) *SetupStepEvent {
|
||||
return &SetupStepEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
service,
|
||||
SetupStartedEventType,
|
||||
),
|
||||
}
|
||||
}
|
@@ -6,14 +6,6 @@ import (
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
)
|
||||
|
||||
func NewMemberAddedEvent(ctx context.Context, userID string, roles ...string) *MemberAddedEvent {
|
||||
return &MemberAddedEvent{
|
||||
BaseEvent: eventstore.BaseEvent{},
|
||||
Roles: roles,
|
||||
UserID: userID,
|
||||
}
|
||||
}
|
||||
|
||||
type MemberAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
@@ -28,3 +20,15 @@ func (e *MemberAddedEvent) CheckPrevious() bool {
|
||||
func (e *MemberAddedEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func NewMemberAddedEvent(ctx context.Context, eventType eventstore.EventType, service, userID string, roles ...string) *MemberAddedEvent {
|
||||
return &MemberAddedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
service,
|
||||
eventType,
|
||||
),
|
||||
Roles: roles,
|
||||
UserID: userID,
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package member
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
)
|
||||
|
||||
@@ -17,3 +19,14 @@ func (e *MemberRemovedEvent) CheckPrevious() bool {
|
||||
func (e *MemberRemovedEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func NewMemberRemovedEvent(ctx context.Context, eventType eventstore.EventType, service, userID string) *MemberRemovedEvent {
|
||||
return &MemberRemovedEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
service,
|
||||
eventType,
|
||||
),
|
||||
UserID: userID,
|
||||
}
|
||||
}
|
||||
|
44
internal/v2/repository/policy/events_label.go
Normal file
44
internal/v2/repository/policy/events_label.go
Normal 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,
|
||||
}
|
||||
}
|
48
internal/v2/repository/policy/events_login.go
Normal file
48
internal/v2/repository/policy/events_login.go
Normal 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,
|
||||
}
|
||||
}
|
41
internal/v2/repository/policy/events_org_iam.go
Normal file
41
internal/v2/repository/policy/events_org_iam.go
Normal 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,
|
||||
}
|
||||
}
|
43
internal/v2/repository/policy/events_password_age.go
Normal file
43
internal/v2/repository/policy/events_password_age.go
Normal 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,
|
||||
}
|
||||
}
|
53
internal/v2/repository/policy/events_password_complexity.go
Normal file
53
internal/v2/repository/policy/events_password_complexity.go
Normal 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,
|
||||
}
|
||||
}
|
44
internal/v2/repository/policy/events_password_lockout.go
Normal file
44
internal/v2/repository/policy/events_password_lockout.go
Normal 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,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user