mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
fix: ignore unchanged console redirect_uris when adding an instance domain (#6156)
Co-authored-by: Fabi <fabienne@zitadel.com>
This commit is contained in:
parent
94fdb9a022
commit
a5b4319f1f
@ -501,6 +501,9 @@ func (c *Commands) ChangeSystemConfig(ctx context.Context, externalDomain string
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(cmds) == 0 {
|
||||
continue
|
||||
}
|
||||
_, err = c.eventstore.Push(ctx, cmds...)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -107,6 +107,9 @@ func (c *Commands) addInstanceDomain(a *instance.Aggregate, instanceDomain strin
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if consoleChangeEvent == nil {
|
||||
return events, nil
|
||||
}
|
||||
return append(events, consoleChangeEvent), nil
|
||||
}, nil
|
||||
}
|
||||
@ -122,6 +125,9 @@ func (c *Commands) prepareUpdateConsoleRedirectURIs(instanceDomain string) prepa
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if consoleChangeEvent == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return []eventstore.Command{
|
||||
consoleChangeEvent,
|
||||
}, nil
|
||||
@ -146,6 +152,9 @@ func (c *Commands) updateConsoleRedirectURIs(ctx context.Context, filter prepara
|
||||
if !containsURI(appWriteModel.PostLogoutRedirectUris, postLogoutRedirectURI) {
|
||||
changes = append(changes, project.ChangePostLogoutRedirectURIs(append(appWriteModel.PostLogoutRedirectUris, postLogoutRedirectURI)))
|
||||
}
|
||||
if len(changes) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
return project.NewOIDCConfigChangedEvent(
|
||||
ctx,
|
||||
ProjectAggregateFromWriteModel(&appWriteModel.WriteModel),
|
||||
@ -154,17 +163,6 @@ func (c *Commands) updateConsoleRedirectURIs(ctx context.Context, filter prepara
|
||||
)
|
||||
}
|
||||
|
||||
// checkUpdateConsoleRedirectURIs validates if the required console uri is present in the redirect_uris and post_logout_redirect_uris
|
||||
// it will return true only if present in both list, otherwise false
|
||||
func (c *Commands) checkUpdateConsoleRedirectURIs(instanceDomain string, redirectURIs, postLogoutRedirectURIs []string) bool {
|
||||
redirectURI := http.BuildHTTP(instanceDomain, c.externalPort, c.externalSecure) + consoleRedirectPath
|
||||
if !containsURI(redirectURIs, redirectURI) {
|
||||
return false
|
||||
}
|
||||
postLogoutRedirectURI := http.BuildHTTP(instanceDomain, c.externalPort, c.externalSecure) + consolePostLogoutPath
|
||||
return containsURI(postLogoutRedirectURIs, postLogoutRedirectURI)
|
||||
}
|
||||
|
||||
func setPrimaryInstanceDomain(a *instance.Aggregate, instanceDomain string) preparation.Validation {
|
||||
return func() (preparation.CreateCommands, error) {
|
||||
if instanceDomain = strings.TrimSpace(instanceDomain); instanceDomain == "" {
|
||||
|
@ -181,8 +181,5 @@ func (wm *SystemConfigWriteModel) changeConfig(validation *SystemConfigChangesVa
|
||||
}
|
||||
|
||||
func (wm *SystemConfigWriteModel) changeURIs(validation *SystemConfigChangesValidation, inst *systemConfigChangesInstanceModel, commands *Commands, domain string) {
|
||||
if commands.checkUpdateConsoleRedirectURIs(domain, inst.RedirectUris, inst.PostLogoutRedirectUris) {
|
||||
return
|
||||
}
|
||||
validation.Validations = append(validation.Validations, commands.prepareUpdateConsoleRedirectURIs(domain))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user