mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 08:57:35 +00:00
chore: move the go code into a subfolder
This commit is contained in:
26
apps/api/internal/repository/sessionlogout/aggregate.go
Normal file
26
apps/api/internal/repository/sessionlogout/aggregate.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package sessionlogout
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
)
|
||||
|
||||
const (
|
||||
AggregateType = "session_logout"
|
||||
AggregateVersion = "v1"
|
||||
)
|
||||
|
||||
type Aggregate struct {
|
||||
eventstore.Aggregate
|
||||
}
|
||||
|
||||
func NewAggregate(id, instanceID string) *Aggregate {
|
||||
return &Aggregate{
|
||||
Aggregate: eventstore.Aggregate{
|
||||
Type: AggregateType,
|
||||
Version: AggregateVersion,
|
||||
ID: id,
|
||||
ResourceOwner: instanceID,
|
||||
InstanceID: instanceID,
|
||||
},
|
||||
}
|
||||
}
|
79
apps/api/internal/repository/sessionlogout/events.go
Normal file
79
apps/api/internal/repository/sessionlogout/events.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package sessionlogout
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
)
|
||||
|
||||
const (
|
||||
eventTypePrefix = "session_logout."
|
||||
backChannelEventTypePrefix = eventTypePrefix + "back_channel."
|
||||
BackChannelLogoutRegisteredType = backChannelEventTypePrefix + "registered"
|
||||
BackChannelLogoutSentType = backChannelEventTypePrefix + "sent"
|
||||
)
|
||||
|
||||
type BackChannelLogoutRegisteredEvent struct {
|
||||
*eventstore.BaseEvent `json:"-"`
|
||||
|
||||
OIDCSessionID string `json:"oidc_session_id"`
|
||||
UserID string `json:"user_id"`
|
||||
ClientID string `json:"client_id"`
|
||||
BackChannelLogoutURI string `json:"back_channel_logout_uri"`
|
||||
}
|
||||
|
||||
// Payload implements eventstore.Command.
|
||||
func (e *BackChannelLogoutRegisteredEvent) Payload() any {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *BackChannelLogoutRegisteredEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *BackChannelLogoutRegisteredEvent) SetBaseEvent(b *eventstore.BaseEvent) {
|
||||
e.BaseEvent = b
|
||||
}
|
||||
|
||||
func NewBackChannelLogoutRegisteredEvent(ctx context.Context, aggregate *eventstore.Aggregate, oidcSessionID, userID, clientID, backChannelLogoutURI string) *BackChannelLogoutRegisteredEvent {
|
||||
return &BackChannelLogoutRegisteredEvent{
|
||||
BaseEvent: eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
BackChannelLogoutRegisteredType,
|
||||
),
|
||||
OIDCSessionID: oidcSessionID,
|
||||
UserID: userID,
|
||||
ClientID: clientID,
|
||||
BackChannelLogoutURI: backChannelLogoutURI,
|
||||
}
|
||||
}
|
||||
|
||||
type BackChannelLogoutSentEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
OIDCSessionID string `json:"oidc_session_id"`
|
||||
}
|
||||
|
||||
func (e *BackChannelLogoutSentEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *BackChannelLogoutSentEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *BackChannelLogoutSentEvent) SetBaseEvent(event *eventstore.BaseEvent) {
|
||||
e.BaseEvent = *event
|
||||
}
|
||||
|
||||
func NewBackChannelLogoutSentEvent(ctx context.Context, aggregate *eventstore.Aggregate, oidcSessionID string) *BackChannelLogoutSentEvent {
|
||||
return &BackChannelLogoutSentEvent{
|
||||
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
BackChannelLogoutSentType,
|
||||
),
|
||||
OIDCSessionID: oidcSessionID,
|
||||
}
|
||||
}
|
15
apps/api/internal/repository/sessionlogout/eventstore.go
Normal file
15
apps/api/internal/repository/sessionlogout/eventstore.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package sessionlogout
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
)
|
||||
|
||||
var (
|
||||
BackChannelLogoutRegisteredEventMapper = eventstore.GenericEventMapper[BackChannelLogoutRegisteredEvent]
|
||||
BackChannelLogoutSentEventMapper = eventstore.GenericEventMapper[BackChannelLogoutSentEvent]
|
||||
)
|
||||
|
||||
func init() {
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, BackChannelLogoutRegisteredType, BackChannelLogoutRegisteredEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, BackChannelLogoutSentType, BackChannelLogoutSentEventMapper)
|
||||
}
|
Reference in New Issue
Block a user