feat: New event user (#1156)

* feat: change user command side

* feat: change user command side

* feat: use states on write model

* feat: command and query side in auth api

* feat: auth commands

* feat: check external idp id

* feat: user state check

* fix: error messages

* fix: is active state
This commit is contained in:
Fabi
2021-01-07 16:06:45 +01:00
committed by GitHub
parent 65a8efeb0e
commit 26c8113930
71 changed files with 1242 additions and 442 deletions
@@ -61,6 +61,7 @@ type HumanExternalIDPAddedEvent struct {
eventstore.BaseEvent `json:"-"`
IDPConfigID string `json:"idpConfigId,omitempty"`
UserID string `json:"userId,omitempty"`
DisplayName string `json:"displayName,omitempty"`
}
@@ -96,19 +97,21 @@ type HumanExternalIDPRemovedEvent struct {
eventstore.BaseEvent `json:"-"`
IDPConfigID string `json:"idpConfigId"`
UserID string `json:"userId,omitempty"`
}
func (e *HumanExternalIDPRemovedEvent) Data() interface{} {
return e
}
func NewHumanExternalIDPRemovedEvent(ctx context.Context, idpConfigID string) *HumanExternalIDPRemovedEvent {
func NewHumanExternalIDPRemovedEvent(ctx context.Context, idpConfigID, externalUserID string) *HumanExternalIDPRemovedEvent {
return &HumanExternalIDPRemovedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
HumanExternalIDPRemovedType,
),
IDPConfigID: idpConfigID,
UserID: externalUserID,
}
}
@@ -129,19 +132,21 @@ type HumanExternalIDPCascadeRemovedEvent struct {
eventstore.BaseEvent `json:"-"`
IDPConfigID string `json:"idpConfigId"`
UserID string `json:"userId,omitempty"`
}
func (e *HumanExternalIDPCascadeRemovedEvent) Data() interface{} {
return e
}
func NewHumanExternalIDPCascadeRemovedEvent(ctx context.Context, idpConfigID string) *HumanExternalIDPCascadeRemovedEvent {
func NewHumanExternalIDPCascadeRemovedEvent(ctx context.Context, idpConfigID, externalUserID string) *HumanExternalIDPCascadeRemovedEvent {
return &HumanExternalIDPCascadeRemovedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
HumanExternalIDPCascadeRemovedType,
),
IDPConfigID: idpConfigID,
UserID: externalUserID,
}
}
@@ -7,7 +7,6 @@ import (
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/v2"
"github.com/caos/zitadel/internal/eventstore/v2/repository"
"github.com/caos/zitadel/internal/v2/domain"
)
const (
@@ -23,7 +22,6 @@ type HumanOTPAddedEvent struct {
eventstore.BaseEvent `json:"-"`
Secret *crypto.CryptoValue `json:"otpSecret,omitempty"`
State domain.MFAState `json:"-"`
}
func (e *HumanOTPAddedEvent) Data() interface{} {
@@ -44,7 +42,6 @@ func NewHumanOTPAddedEvent(ctx context.Context,
func HumanOTPAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
otpAdded := &HumanOTPAddedEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
State: domain.MFAStateNotReady,
}
err := json.Unmarshal(event.Data, otpAdded)
if err != nil {
@@ -55,7 +52,6 @@ func HumanOTPAddedEventMapper(event *repository.Event) (eventstore.EventReader,
type HumanOTPVerifiedEvent struct {
eventstore.BaseEvent `json:"-"`
State domain.MFAState `json:"-"`
}
func (e *HumanOTPVerifiedEvent) Data() interface{} {
@@ -74,7 +70,6 @@ func NewHumanOTPVerifiedEvent(ctx context.Context) *HumanOTPVerifiedEvent {
func HumanOTPVerifiedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
return &HumanOTPVerifiedEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
State: domain.MFAStateReady,
}, nil
}
@@ -25,6 +25,7 @@ type HumanPasswordChangedEvent struct {
Secret *crypto.CryptoValue `json:"secret,omitempty"`
ChangeRequired bool `json:"changeRequired"`
UserAgentID string `json:"userAgentID,omitempty"`
}
func (e *HumanPasswordChangedEvent) Data() interface{} {
@@ -35,6 +36,7 @@ func NewHumanPasswordChangedEvent(
ctx context.Context,
secret *crypto.CryptoValue,
changeRequired bool,
userAgentID string,
) *HumanPasswordChangedEvent {
return &HumanPasswordChangedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
@@ -43,6 +45,7 @@ func NewHumanPasswordChangedEvent(
),
Secret: secret,
ChangeRequired: changeRequired,
UserAgentID: userAgentID,
}
}
+1 -2
View File
@@ -30,13 +30,12 @@ func (e *HumanPhoneChangedEvent) Data() interface{} {
return e
}
func NewHumanPhoneChangedEvent(ctx context.Context, phone string) *HumanPhoneChangedEvent {
func NewHumanPhoneChangedEvent(ctx context.Context) *HumanPhoneChangedEvent {
return &HumanPhoneChangedEvent{
BaseEvent: *eventstore.NewBaseEventForPush(
ctx,
HumanPhoneChangedType,
),
PhoneNumber: phone,
}
}