mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:17:32 +00:00
feat: Instance domains (#3444)
* feat: add domain list * feat: domain tests * feat: add redirect url on adding instance domain * Update internal/command/instance_domain.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * feat: remove unused code * fix Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -11,10 +11,11 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
UniqueInstanceDomain = "instance_domain"
|
||||
domainEventPrefix = instanceEventTypePrefix + "domain."
|
||||
InstanceDomainAddedEventType = domainEventPrefix + "added"
|
||||
InstanceDomainRemovedEventType = domainEventPrefix + "removed"
|
||||
UniqueInstanceDomain = "instance_domain"
|
||||
domainEventPrefix = instanceEventTypePrefix + "domain."
|
||||
InstanceDomainAddedEventType = domainEventPrefix + "added"
|
||||
InstanceDomainPrimarySetEventType = domainEventPrefix + "primary.set"
|
||||
InstanceDomainRemovedEventType = domainEventPrefix + "removed"
|
||||
)
|
||||
|
||||
func NewAddInstanceDomainUniqueConstraint(orgDomain string) *eventstore.EventUniqueConstraint {
|
||||
@@ -69,6 +70,43 @@ func DomainAddedEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
return orgDomainAdded, nil
|
||||
}
|
||||
|
||||
type DomainPrimarySetEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Domain string `json:"domain,omitempty"`
|
||||
}
|
||||
|
||||
func (e *DomainPrimarySetEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *DomainPrimarySetEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewDomainPrimarySetEvent(ctx context.Context, aggregate *eventstore.Aggregate, domain string) *DomainPrimarySetEvent {
|
||||
return &DomainPrimarySetEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
InstanceDomainPrimarySetEventType,
|
||||
),
|
||||
Domain: domain,
|
||||
}
|
||||
}
|
||||
|
||||
func DomainPrimarySetEventMapper(event *repository.Event) (eventstore.Event, error) {
|
||||
orgDomainAdded := &DomainAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
err := json.Unmarshal(event.Data, orgDomainAdded)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "INSTANCE-29jöF", "unable to unmarshal instance domain added")
|
||||
}
|
||||
|
||||
return orgDomainAdded, nil
|
||||
}
|
||||
|
||||
type DomainRemovedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
|
@@ -60,6 +60,7 @@ type ConsoleSetEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
ClientID string `json:"clientId"`
|
||||
AppID string `json:"appId"`
|
||||
}
|
||||
|
||||
func (e *ConsoleSetEvent) Data() interface{} {
|
||||
@@ -73,7 +74,8 @@ func (e *ConsoleSetEvent) UniqueConstraints() []*eventstore.EventUniqueConstrain
|
||||
func NewIAMConsoleSetEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
clientID *string,
|
||||
clientID,
|
||||
appID *string,
|
||||
) *ConsoleSetEvent {
|
||||
return &ConsoleSetEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
@@ -82,6 +84,7 @@ func NewIAMConsoleSetEvent(
|
||||
ConsoleSetEventType,
|
||||
),
|
||||
ClientID: *clientID,
|
||||
AppID: *appID,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -87,6 +87,7 @@ func RegisterEventMappers(es *eventstore.Eventstore) {
|
||||
RegisterFilterEventMapper(CustomTextTemplateRemovedEventType, CustomTextTemplateRemovedEventMapper).
|
||||
RegisterFilterEventMapper(FeaturesSetEventType, FeaturesSetEventMapper).
|
||||
RegisterFilterEventMapper(InstanceDomainAddedEventType, DomainAddedEventMapper).
|
||||
RegisterFilterEventMapper(InstanceDomainPrimarySetEventType, DomainPrimarySetEventMapper).
|
||||
RegisterFilterEventMapper(InstanceDomainRemovedEventType, DomainRemovedEventMapper).
|
||||
RegisterFilterEventMapper(InstanceAddedEventType, InstanceAddedEventMapper).
|
||||
RegisterFilterEventMapper(InstanceChangedEventType, InstanceChangedEventMapper).
|
||||
|
Reference in New Issue
Block a user