mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-03 01:18:51 +00:00
policy, idp, member.
member not working atm
This commit is contained in:
@@ -47,16 +47,3 @@ const (
|
||||
func (f StylingType) Valid() bool {
|
||||
return f >= 0 && f < stylingTypeCount
|
||||
}
|
||||
|
||||
type ProviderType int8
|
||||
|
||||
const (
|
||||
ProviderTypeSystem ProviderType = iota
|
||||
ProviderTypeOrg
|
||||
|
||||
providerTypeCount
|
||||
)
|
||||
|
||||
func (f ProviderType) Valid() bool {
|
||||
return f >= 0 && f < providerTypeCount
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package idp
|
||||
import (
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/v2/repository/idp/oidc"
|
||||
"github.com/caos/zitadel/internal/v2/repository/idp/provider"
|
||||
)
|
||||
|
||||
type ConfigReadModel struct {
|
||||
@@ -12,7 +13,7 @@ type ConfigReadModel struct {
|
||||
ConfigID string
|
||||
Name string
|
||||
StylingType StylingType
|
||||
ProviderType ProviderType
|
||||
ProviderType provider.Type
|
||||
|
||||
OIDCConfig *oidc.ConfigReadModel
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func (e *ConfigAddedEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func ConfigAddedEventMapper(event *repository.Event) (*ConfigAddedEvent, error) {
|
||||
func ConfigAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &ConfigAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func (e *ConfigChangedEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func ConfigChangedEventMapper(event *repository.Event) (*ConfigChangedEvent, error) {
|
||||
func ConfigChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &ConfigChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func (e *ConfigDeactivatedEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func ConfigDeactivatedEventMapper(event *repository.Event) (*ConfigDeactivatedEvent, error) {
|
||||
func ConfigDeactivatedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &ConfigDeactivatedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func (e *ConfigReactivatedEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func ConfigReactivatedEventMapper(event *repository.Event) (*ConfigReactivatedEvent, error) {
|
||||
func ConfigReactivatedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &ConfigReactivatedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func (e *ConfigRemovedEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func ConfigRemovedEventMapper(event *repository.Event) (*ConfigRemovedEvent, error) {
|
||||
func ConfigRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &ConfigRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func NewConfigAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func ConfigAddedEventMapper(event *repository.Event) (*ConfigAddedEvent, error) {
|
||||
func ConfigAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &ConfigAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ func NewConfigChangedEvent(
|
||||
return event, nil
|
||||
}
|
||||
|
||||
func ConfigChangedEventMapper(event *repository.Event) (*ConfigChangedEvent, error) {
|
||||
func ConfigChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &ConfigChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
AddedEventType = "idpprovider.added"
|
||||
)
|
||||
|
||||
type AddedEvent struct {
|
||||
eventstore.BaseEvent
|
||||
|
||||
IDPConfigID string `json:"idpConfigId"`
|
||||
IDPProviderType Type `json:"idpProviderType"`
|
||||
}
|
||||
|
||||
func (e *AddedEvent) CheckPrevious() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *AddedEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func NewAddedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
idpConfigID string,
|
||||
idpProviderType Type,
|
||||
) *AddedEvent {
|
||||
|
||||
return &AddedEvent{
|
||||
BaseEvent: *base,
|
||||
IDPConfigID: idpConfigID,
|
||||
IDPProviderType: idpProviderType,
|
||||
}
|
||||
}
|
||||
|
||||
func AddedEventEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &AddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "PROVI-bfNnp", "Errors.Internal")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package provider
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
RemovedEventType = "idpprovider.removed"
|
||||
)
|
||||
|
||||
type RemovedEvent struct {
|
||||
eventstore.BaseEvent
|
||||
|
||||
IDPConfigID string `json:"idpConfigId"`
|
||||
}
|
||||
|
||||
func (e *RemovedEvent) CheckPrevious() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *RemovedEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func NewRemovedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
idpConfigID string,
|
||||
) *RemovedEvent {
|
||||
|
||||
return &RemovedEvent{
|
||||
BaseEvent: *base,
|
||||
IDPConfigID: idpConfigID,
|
||||
}
|
||||
}
|
||||
|
||||
func RemovedEventEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &RemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "PROVI-6H0KQ", "Errors.Internal")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package provider
|
||||
|
||||
type Type int8
|
||||
|
||||
const (
|
||||
TypeSystem Type = iota
|
||||
TypeOrg
|
||||
|
||||
typeCount
|
||||
)
|
||||
|
||||
func (f Type) Valid() bool {
|
||||
return f >= 0 && f < typeCount
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package provider
|
||||
|
||||
import "github.com/caos/zitadel/internal/eventstore/v2"
|
||||
|
||||
type WriteModel struct {
|
||||
eventstore.WriteModel
|
||||
|
||||
IDPConfigID string
|
||||
IDPProviderType Type
|
||||
}
|
||||
|
||||
func (wm *WriteModel) Reduce() error {
|
||||
for _, event := range wm.Events {
|
||||
switch e := event.(type) {
|
||||
case *AddedEvent:
|
||||
wm.IDPConfigID = e.IDPConfigID
|
||||
wm.IDPProviderType = e.IDPProviderType
|
||||
}
|
||||
}
|
||||
return wm.WriteModel.Reduce()
|
||||
}
|
||||
Reference in New Issue
Block a user