mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 14:37:32 +00:00
chore: move the go code into a subfolder
This commit is contained in:
267
apps/api/internal/repository/idpconfig/idp_config.go
Normal file
267
apps/api/internal/repository/idpconfig/idp_config.go
Normal file
@@ -0,0 +1,267 @@
|
||||
package idpconfig
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
const (
|
||||
UniqueIDPConfigNameType = "idp_config_names"
|
||||
)
|
||||
|
||||
func NewAddIDPConfigNameUniqueConstraint(idpConfigName, resourceOwner string) *eventstore.UniqueConstraint {
|
||||
return eventstore.NewAddEventUniqueConstraint(
|
||||
UniqueIDPConfigNameType,
|
||||
idpConfigName+resourceOwner,
|
||||
"Errors.IDPConfig.AlreadyExists")
|
||||
}
|
||||
|
||||
func NewRemoveIDPConfigNameUniqueConstraint(idpConfigName, resourceOwner string) *eventstore.UniqueConstraint {
|
||||
return eventstore.NewRemoveUniqueConstraint(
|
||||
UniqueIDPConfigNameType,
|
||||
idpConfigName+resourceOwner)
|
||||
}
|
||||
|
||||
type IDPConfigAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
ConfigID string `json:"idpConfigId"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Typ domain.IDPConfigType `json:"idpType,omitempty"`
|
||||
StylingType domain.IDPConfigStylingType `json:"stylingType,omitempty"`
|
||||
AutoRegister bool `json:"autoRegister,omitempty"`
|
||||
}
|
||||
|
||||
func NewIDPConfigAddedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
configID,
|
||||
name string,
|
||||
configType domain.IDPConfigType,
|
||||
stylingType domain.IDPConfigStylingType,
|
||||
autoRegister bool,
|
||||
) *IDPConfigAddedEvent {
|
||||
return &IDPConfigAddedEvent{
|
||||
BaseEvent: *base,
|
||||
ConfigID: configID,
|
||||
Name: name,
|
||||
StylingType: stylingType,
|
||||
Typ: configType,
|
||||
AutoRegister: autoRegister,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *IDPConfigAddedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *IDPConfigAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return []*eventstore.UniqueConstraint{NewAddIDPConfigNameUniqueConstraint(e.Name, e.Aggregate().ResourceOwner)}
|
||||
}
|
||||
|
||||
func IDPConfigAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e := &IDPConfigAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := event.Unmarshal(e)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type IDPConfigChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
ConfigID string `json:"idpConfigId"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
StylingType *domain.IDPConfigStylingType `json:"stylingType,omitempty"`
|
||||
AutoRegister *bool `json:"autoRegister,omitempty"`
|
||||
oldName string `json:"-"`
|
||||
}
|
||||
|
||||
func (e *IDPConfigChangedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *IDPConfigChangedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
if e.oldName == "" {
|
||||
return nil
|
||||
}
|
||||
return []*eventstore.UniqueConstraint{
|
||||
NewRemoveIDPConfigNameUniqueConstraint(e.oldName, e.Aggregate().ResourceOwner),
|
||||
NewAddIDPConfigNameUniqueConstraint(*e.Name, e.Aggregate().ResourceOwner),
|
||||
}
|
||||
}
|
||||
|
||||
func NewIDPConfigChangedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
configID,
|
||||
oldName string,
|
||||
changes []IDPConfigChanges,
|
||||
) (*IDPConfigChangedEvent, error) {
|
||||
if len(changes) == 0 {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "IDPCONFIG-Dsg21", "Errors.NoChangesFound")
|
||||
}
|
||||
changeEvent := &IDPConfigChangedEvent{
|
||||
BaseEvent: *base,
|
||||
ConfigID: configID,
|
||||
oldName: oldName,
|
||||
}
|
||||
for _, change := range changes {
|
||||
change(changeEvent)
|
||||
}
|
||||
return changeEvent, nil
|
||||
}
|
||||
|
||||
type IDPConfigChanges func(*IDPConfigChangedEvent)
|
||||
|
||||
func ChangeName(name string) func(*IDPConfigChangedEvent) {
|
||||
return func(e *IDPConfigChangedEvent) {
|
||||
e.Name = &name
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeStyleType(styleType domain.IDPConfigStylingType) func(*IDPConfigChangedEvent) {
|
||||
return func(e *IDPConfigChangedEvent) {
|
||||
e.StylingType = &styleType
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeAutoRegister(autoRegister bool) func(*IDPConfigChangedEvent) {
|
||||
return func(e *IDPConfigChangedEvent) {
|
||||
e.AutoRegister = &autoRegister
|
||||
}
|
||||
}
|
||||
|
||||
func IDPConfigChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e := &IDPConfigChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := event.Unmarshal(e)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type IDPConfigDeactivatedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
ConfigID string `json:"idpConfigId"`
|
||||
}
|
||||
|
||||
func NewIDPConfigDeactivatedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
configID string,
|
||||
) *IDPConfigDeactivatedEvent {
|
||||
|
||||
return &IDPConfigDeactivatedEvent{
|
||||
BaseEvent: *base,
|
||||
ConfigID: configID,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *IDPConfigDeactivatedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *IDPConfigDeactivatedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func IDPConfigDeactivatedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e := &IDPConfigDeactivatedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := event.Unmarshal(e)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type IDPConfigReactivatedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
ConfigID string `json:"idpConfigId"`
|
||||
}
|
||||
|
||||
func NewIDPConfigReactivatedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
configID string,
|
||||
) *IDPConfigReactivatedEvent {
|
||||
|
||||
return &IDPConfigReactivatedEvent{
|
||||
BaseEvent: *base,
|
||||
ConfigID: configID,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *IDPConfigReactivatedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *IDPConfigReactivatedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func IDPConfigReactivatedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e := &IDPConfigReactivatedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := event.Unmarshal(e)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type IDPConfigRemovedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
ConfigID string `json:"idpConfigId"`
|
||||
name string
|
||||
}
|
||||
|
||||
func NewIDPConfigRemovedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
configID string,
|
||||
name string,
|
||||
) *IDPConfigRemovedEvent {
|
||||
|
||||
return &IDPConfigRemovedEvent{
|
||||
BaseEvent: *base,
|
||||
ConfigID: configID,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *IDPConfigRemovedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *IDPConfigRemovedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return []*eventstore.UniqueConstraint{NewRemoveIDPConfigNameUniqueConstraint(e.name, e.Aggregate().ResourceOwner)}
|
||||
}
|
||||
|
||||
func IDPConfigRemovedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e := &IDPConfigRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := event.Unmarshal(e)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
136
apps/api/internal/repository/idpconfig/jwt_config.go
Normal file
136
apps/api/internal/repository/idpconfig/jwt_config.go
Normal file
@@ -0,0 +1,136 @@
|
||||
package idpconfig
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
const (
|
||||
JWTConfigAddedEventType eventstore.EventType = "jwt.config.added"
|
||||
JWTConfigChangedEventType eventstore.EventType = "jwt.config.changed"
|
||||
)
|
||||
|
||||
type JWTConfigAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
IDPConfigID string `json:"idpConfigId"`
|
||||
JWTEndpoint string `json:"jwtEndpoint,omitempty"`
|
||||
Issuer string `json:"issuer,omitempty"`
|
||||
KeysEndpoint string `json:"keysEndpoint,omitempty"`
|
||||
HeaderName string `json:"headerName,omitempty"`
|
||||
}
|
||||
|
||||
func (e *JWTConfigAddedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *JWTConfigAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewJWTConfigAddedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
idpConfigID,
|
||||
jwtEndpoint,
|
||||
issuer,
|
||||
keysEndpoint,
|
||||
headerName string,
|
||||
) *JWTConfigAddedEvent {
|
||||
return &JWTConfigAddedEvent{
|
||||
BaseEvent: *base,
|
||||
IDPConfigID: idpConfigID,
|
||||
JWTEndpoint: jwtEndpoint,
|
||||
Issuer: issuer,
|
||||
KeysEndpoint: keysEndpoint,
|
||||
HeaderName: headerName,
|
||||
}
|
||||
}
|
||||
|
||||
func JWTConfigAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e := &JWTConfigAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := event.Unmarshal(e)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "JWT-m0fwf", "unable to unmarshal event")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type JWTConfigChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
IDPConfigID string `json:"idpConfigId"`
|
||||
|
||||
JWTEndpoint *string `json:"jwtEndpoint,omitempty"`
|
||||
Issuer *string `json:"issuer,omitempty"`
|
||||
KeysEndpoint *string `json:"keysEndpoint,omitempty"`
|
||||
HeaderName *string `json:"headerName,omitempty"`
|
||||
}
|
||||
|
||||
func (e *JWTConfigChangedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *JWTConfigChangedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewJWTConfigChangedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
idpConfigID string,
|
||||
changes []JWTConfigChanges,
|
||||
) (*JWTConfigChangedEvent, error) {
|
||||
if len(changes) == 0 {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "IDPCONFIG-fn93s", "Errors.NoChangesFound")
|
||||
}
|
||||
changeEvent := &JWTConfigChangedEvent{
|
||||
BaseEvent: *base,
|
||||
IDPConfigID: idpConfigID,
|
||||
}
|
||||
for _, change := range changes {
|
||||
change(changeEvent)
|
||||
}
|
||||
return changeEvent, nil
|
||||
}
|
||||
|
||||
type JWTConfigChanges func(*JWTConfigChangedEvent)
|
||||
|
||||
func ChangeJWTEndpoint(jwtEndpoint string) func(*JWTConfigChangedEvent) {
|
||||
return func(e *JWTConfigChangedEvent) {
|
||||
e.JWTEndpoint = &jwtEndpoint
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeJWTIssuer(issuer string) func(*JWTConfigChangedEvent) {
|
||||
return func(e *JWTConfigChangedEvent) {
|
||||
e.Issuer = &issuer
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeKeysEndpoint(keysEndpoint string) func(*JWTConfigChangedEvent) {
|
||||
return func(e *JWTConfigChangedEvent) {
|
||||
e.KeysEndpoint = &keysEndpoint
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeHeaderName(headerName string) func(*JWTConfigChangedEvent) {
|
||||
return func(e *JWTConfigChangedEvent) {
|
||||
e.HeaderName = &headerName
|
||||
}
|
||||
}
|
||||
|
||||
func JWTConfigChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e := &JWTConfigChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := event.Unmarshal(e)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "JWT-fk3fs", "unable to unmarshal event")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
181
apps/api/internal/repository/idpconfig/oidc_config.go
Normal file
181
apps/api/internal/repository/idpconfig/oidc_config.go
Normal file
@@ -0,0 +1,181 @@
|
||||
package idpconfig
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/crypto"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
"github.com/zitadel/zitadel/internal/zerrors"
|
||||
)
|
||||
|
||||
const (
|
||||
OIDCConfigAddedEventType eventstore.EventType = "oidc.config.added"
|
||||
OIDCConfigChangedEventType eventstore.EventType = "oidc.config.changed"
|
||||
)
|
||||
|
||||
type OIDCConfigAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
IDPConfigID string `json:"idpConfigId"`
|
||||
ClientID string `json:"clientId,omitempty"`
|
||||
ClientSecret *crypto.CryptoValue `json:"clientSecret,omitempty"`
|
||||
Issuer string `json:"issuer,omitempty"`
|
||||
AuthorizationEndpoint string `json:"authorizationEndpoint,omitempty"`
|
||||
TokenEndpoint string `json:"tokenEndpoint,omitempty"`
|
||||
Scopes []string `json:"scopes,omitempty"`
|
||||
|
||||
IDPDisplayNameMapping domain.OIDCMappingField `json:"idpDisplayNameMapping,omitempty"`
|
||||
UserNameMapping domain.OIDCMappingField `json:"usernameMapping,omitempty"`
|
||||
}
|
||||
|
||||
func (e *OIDCConfigAddedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *OIDCConfigAddedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewOIDCConfigAddedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
clientID,
|
||||
idpConfigID,
|
||||
issuer,
|
||||
authorizationEndpoint,
|
||||
tokenEndpoint string,
|
||||
clientSecret *crypto.CryptoValue,
|
||||
idpDisplayNameMapping,
|
||||
userNameMapping domain.OIDCMappingField,
|
||||
scopes ...string,
|
||||
) *OIDCConfigAddedEvent {
|
||||
|
||||
return &OIDCConfigAddedEvent{
|
||||
BaseEvent: *base,
|
||||
IDPConfigID: idpConfigID,
|
||||
ClientID: clientID,
|
||||
ClientSecret: clientSecret,
|
||||
Issuer: issuer,
|
||||
AuthorizationEndpoint: authorizationEndpoint,
|
||||
TokenEndpoint: tokenEndpoint,
|
||||
Scopes: scopes,
|
||||
IDPDisplayNameMapping: idpDisplayNameMapping,
|
||||
UserNameMapping: userNameMapping,
|
||||
}
|
||||
}
|
||||
|
||||
func OIDCConfigAddedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e := &OIDCConfigAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := event.Unmarshal(e)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type OIDCConfigChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
IDPConfigID string `json:"idpConfigId"`
|
||||
|
||||
ClientID *string `json:"clientId,omitempty"`
|
||||
ClientSecret *crypto.CryptoValue `json:"clientSecret,omitempty"`
|
||||
Issuer *string `json:"issuer,omitempty"`
|
||||
AuthorizationEndpoint *string `json:"authorizationEndpoint,omitempty"`
|
||||
TokenEndpoint *string `json:"tokenEndpoint,omitempty"`
|
||||
Scopes []string `json:"scopes,omitempty"`
|
||||
|
||||
IDPDisplayNameMapping *domain.OIDCMappingField `json:"idpDisplayNameMapping,omitempty"`
|
||||
UserNameMapping *domain.OIDCMappingField `json:"usernameMapping,omitempty"`
|
||||
}
|
||||
|
||||
func (e *OIDCConfigChangedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *OIDCConfigChangedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewOIDCConfigChangedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
idpConfigID string,
|
||||
changes []OIDCConfigChanges,
|
||||
) (*OIDCConfigChangedEvent, error) {
|
||||
if len(changes) == 0 {
|
||||
return nil, zerrors.ThrowPreconditionFailed(nil, "IDPCONFIG-ADzr5", "Errors.NoChangesFound")
|
||||
}
|
||||
changeEvent := &OIDCConfigChangedEvent{
|
||||
BaseEvent: *base,
|
||||
IDPConfigID: idpConfigID,
|
||||
}
|
||||
for _, change := range changes {
|
||||
change(changeEvent)
|
||||
}
|
||||
return changeEvent, nil
|
||||
}
|
||||
|
||||
type OIDCConfigChanges func(*OIDCConfigChangedEvent)
|
||||
|
||||
func ChangeClientID(clientID string) func(*OIDCConfigChangedEvent) {
|
||||
return func(e *OIDCConfigChangedEvent) {
|
||||
e.ClientID = &clientID
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeClientSecret(secret *crypto.CryptoValue) func(*OIDCConfigChangedEvent) {
|
||||
return func(e *OIDCConfigChangedEvent) {
|
||||
e.ClientSecret = secret
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeIssuer(issuer string) func(*OIDCConfigChangedEvent) {
|
||||
return func(e *OIDCConfigChangedEvent) {
|
||||
e.Issuer = &issuer
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeAuthorizationEndpoint(authorizationEndpoint string) func(*OIDCConfigChangedEvent) {
|
||||
return func(e *OIDCConfigChangedEvent) {
|
||||
e.AuthorizationEndpoint = &authorizationEndpoint
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeTokenEndpoint(tokenEndpoint string) func(*OIDCConfigChangedEvent) {
|
||||
return func(e *OIDCConfigChangedEvent) {
|
||||
e.TokenEndpoint = &tokenEndpoint
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeIDPDisplayNameMapping(idpDisplayNameMapping domain.OIDCMappingField) func(*OIDCConfigChangedEvent) {
|
||||
return func(e *OIDCConfigChangedEvent) {
|
||||
e.IDPDisplayNameMapping = &idpDisplayNameMapping
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeUserNameMapping(userNameMapping domain.OIDCMappingField) func(*OIDCConfigChangedEvent) {
|
||||
return func(e *OIDCConfigChangedEvent) {
|
||||
e.UserNameMapping = &userNameMapping
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeScopes(scopes []string) func(*OIDCConfigChangedEvent) {
|
||||
return func(e *OIDCConfigChangedEvent) {
|
||||
e.Scopes = scopes
|
||||
}
|
||||
}
|
||||
|
||||
func OIDCConfigChangedEventMapper(event eventstore.Event) (eventstore.Event, error) {
|
||||
e := &OIDCConfigChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := event.Unmarshal(e)
|
||||
if err != nil {
|
||||
return nil, zerrors.ThrowInternal(err, "OIDC-plaBZ", "unable to unmarshal event")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
Reference in New Issue
Block a user