mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-02 08:58:52 +00:00
feat: implement instance-level UpdateZitadelProvider (#12378)
# Which Problems Are Solved This PR implements the instance-level `UpdateZitadelProvider` endpoint, enabling updates to existing instance Zitadel IdP templates. # How the Problems Are Solved - Added `AdminService.UpdateZitadelProvider` handler, converter - Added the command-layer implementation to update a ZitadelProvider and push `instance.idp.zitadel.changed` event - Added projection-layer implementation to persist Zitadel provider updates into `projections.idp_templates6_zitadel` - Added unit and integration tests # Additional Changes N/A # Additional Context Related to https://github.com/zitadel/zitadel/issues/11922 Follow-up for PRs: - https://github.com/zitadel/zitadel/pull/12018 - https://github.com/zitadel/zitadel/pull/12020 - https://github.com/zitadel/zitadel/pull/12055 - https://github.com/zitadel/zitadel/pull/12056 - https://github.com/zitadel/zitadel/pull/12371 --------- Co-authored-by: Copilot Autofix powered by AI <[email protected]>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI
parent
1beabed8cf
commit
653a968d91
@@ -57,5 +57,88 @@ func (e *ZitadelIDPAddedEvent) UniqueConstraints() []*eventstore.UniqueConstrain
|
||||
|
||||
type ZitadelIDPChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
// todo (@grvijayan): will be added along with UpdateZitadelProvider changes
|
||||
|
||||
ID string `json:"id"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Issuer *string `json:"issuer,omitempty"`
|
||||
ClientID *string `json:"clientId,omitempty"`
|
||||
ClientSecret *crypto.CryptoValue `json:"clientSecret,omitempty"`
|
||||
Scopes *[]string `json:"scopes,omitempty"`
|
||||
InstanceRolesInfo *[]RolesInfo `json:"instanceRolesInfo,omitempty"`
|
||||
OptionChanges
|
||||
}
|
||||
|
||||
func NewZitadelIDPChangedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
id string,
|
||||
changes []ZitadelIDPChanges,
|
||||
) *ZitadelIDPChangedEvent {
|
||||
e := &ZitadelIDPChangedEvent{
|
||||
BaseEvent: *base,
|
||||
ID: id,
|
||||
}
|
||||
for _, change := range changes {
|
||||
change(e)
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
type ZitadelIDPChanges func(*ZitadelIDPChangedEvent)
|
||||
|
||||
func ChangeZitadelIDPName(name string) ZitadelIDPChanges {
|
||||
return func(e *ZitadelIDPChangedEvent) {
|
||||
e.Name = &name
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeZitadelIDPIssuer(issuer string) ZitadelIDPChanges {
|
||||
return func(e *ZitadelIDPChangedEvent) {
|
||||
e.Issuer = &issuer
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeZitadelIDPClientID(clientID string) ZitadelIDPChanges {
|
||||
return func(e *ZitadelIDPChangedEvent) {
|
||||
e.ClientID = &clientID
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeZitadelIDPClientSecret(clientSecret *crypto.CryptoValue) ZitadelIDPChanges {
|
||||
return func(e *ZitadelIDPChangedEvent) {
|
||||
e.ClientSecret = clientSecret
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeZitadelIDPScopes(scopes []string) ZitadelIDPChanges {
|
||||
return func(e *ZitadelIDPChangedEvent) {
|
||||
// explicitly set them to empty in case the scopes are unset
|
||||
if scopes == nil {
|
||||
scopes = make([]string, 0)
|
||||
}
|
||||
e.Scopes = &scopes
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeZitadelIDPInstanceRolesInfo(instanceRolesInfo []RolesInfo) ZitadelIDPChanges {
|
||||
return func(e *ZitadelIDPChangedEvent) {
|
||||
// explicitly set them to empty in case the instance roles are unset
|
||||
if instanceRolesInfo == nil {
|
||||
instanceRolesInfo = make([]RolesInfo, 0)
|
||||
}
|
||||
e.InstanceRolesInfo = &instanceRolesInfo
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeZitadelIDPOptions(options OptionChanges) ZitadelIDPChanges {
|
||||
return func(e *ZitadelIDPChangedEvent) {
|
||||
e.OptionChanges = options
|
||||
}
|
||||
}
|
||||
|
||||
func (e *ZitadelIDPChangedEvent) Payload() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *ZitadelIDPChangedEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@ func init() {
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, SAMLIDPChangedEventType, SAMLIDPChangedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, IDPRemovedEventType, IDPRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, ZitadelIDPAddedEventType, eventstore.GenericEventMapper[ZitadelIDPAddedEvent])
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, ZitadelIDPChangedEventType, eventstore.GenericEventMapper[ZitadelIDPChangedEvent])
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderAddedEventType, IdentityProviderAddedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderRemovedEventType, IdentityProviderRemovedEventMapper)
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, LoginPolicyIDPProviderCascadeRemovedEventType, IdentityProviderCascadeRemovedEventMapper)
|
||||
|
||||
@@ -39,6 +39,7 @@ const (
|
||||
SAMLIDPChangedEventType eventstore.EventType = "instance.idp.saml.changed"
|
||||
IDPRemovedEventType eventstore.EventType = "instance.idp.removed"
|
||||
ZitadelIDPAddedEventType eventstore.EventType = "instance.idp.zitadel.added"
|
||||
ZitadelIDPChangedEventType eventstore.EventType = "instance.idp.zitadel.changed"
|
||||
)
|
||||
|
||||
type OAuthIDPAddedEvent struct {
|
||||
@@ -1171,3 +1172,29 @@ func NewZitadelIDPAddedEvent(
|
||||
func (e *ZitadelIDPAddedEvent) SetBaseEvent(event *eventstore.BaseEvent) {
|
||||
e.BaseEvent = *event
|
||||
}
|
||||
|
||||
type ZitadelIDPChangedEvent struct {
|
||||
idp.ZitadelIDPChangedEvent
|
||||
}
|
||||
|
||||
func NewZitadelIDPChangedEvent(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
id string,
|
||||
changes []idp.ZitadelIDPChanges,
|
||||
) *ZitadelIDPChangedEvent {
|
||||
changedEvent := idp.NewZitadelIDPChangedEvent(
|
||||
eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
aggregate,
|
||||
ZitadelIDPChangedEventType,
|
||||
),
|
||||
id,
|
||||
changes,
|
||||
)
|
||||
return &ZitadelIDPChangedEvent{ZitadelIDPChangedEvent: *changedEvent}
|
||||
}
|
||||
|
||||
func (e *ZitadelIDPChangedEvent) SetBaseEvent(event *eventstore.BaseEvent) {
|
||||
e.BaseEvent = *event
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user