@@ -61,24 +61,66 @@ func applyInto(a AutomationConfig, into *Deployment) error {
6161(* into )["ldap" ] = mergedLdap
6262}
6363
64- if _ , ok := a .Deployment ["oidcProviderConfigs" ]; ok || len (a .OIDCProviderConfigs ) > 0 {
65- // TODO: this is not merged yet, but only overridden
66- bytes , err := json .Marshal (a .OIDCProviderConfigs )
67- if err != nil {
68- return err
64+ if len (a .OIDCProviderConfigs ) > 0 {
65+ deploymentConfigs := make ([]map [string ]any , 0 )
66+ if configs , ok := a .Deployment ["oidcProviderConfigs" ]; ok {
67+ configsSlice := cast .ToSlice (configs )
68+ for _ , config := range configsSlice {
69+ deploymentConfigs = append (deploymentConfigs , config .(map [string ]any ))
70+ }
6971}
7072
71- dst := make ([]map [string ]interface {}, 0 )
72- err = json .Unmarshal (bytes , & dst )
73- if err != nil {
74- return err
73+ result := make ([]map [string ]any , 0 )
74+ for _ , config := range a .OIDCProviderConfigs {
75+ deploymentConfig := findOrCreateEmptyDeploymentConfig (deploymentConfigs , config .AuthNamePrefix )
76+
77+ deploymentConfig ["authNamePrefix" ] = config .AuthNamePrefix
78+ deploymentConfig ["audience" ] = config .Audience
79+ deploymentConfig ["issuerUri" ] = config .IssuerUri
80+ deploymentConfig ["userClaim" ] = config .UserClaim
81+ deploymentConfig ["supportsHumanFlows" ] = config .SupportsHumanFlows
82+ deploymentConfig ["useAuthorizationClaim" ] = config .UseAuthorizationClaim
83+
84+ if config .ClientId == util .MergoDelete {
85+ delete (deploymentConfig , "clientId" )
86+ } else {
87+ deploymentConfig ["clientId" ] = config .ClientId
88+ }
89+
90+ if len (config .RequestedScopes ) == 0 {
91+ delete (deploymentConfig , "requestedScopes" )
92+ } else {
93+ deploymentConfig ["requestedScopes" ] = config .RequestedScopes
94+ }
95+
96+ if config .GroupsClaim == util .MergoDelete {
97+ delete (deploymentConfig , "groupsClaim" )
98+ } else {
99+ deploymentConfig ["groupsClaim" ] = config .GroupsClaim
100+ }
101+
102+ result = append (result , deploymentConfig )
75103}
76- (* into )["oidcProviderConfigs" ] = dst
104+
105+ (* into )["oidcProviderConfigs" ] = result
106+ } else {
107+ // Clear oidcProviderConfigs if no configs are provided
108+ delete (* into , "oidcProviderConfigs" )
77109}
78110
79111return nil
80112}
81113
114+ func findOrCreateEmptyDeploymentConfig (deploymentConfigs []map [string ]any , configName string ) map [string ]any {
115+ for _ , deploymentConfig := range deploymentConfigs {
116+ if configName == deploymentConfig ["authNamePrefix" ] {
117+ return deploymentConfig
118+ }
119+ }
120+
121+ return make (map [string ]any )
122+ }
123+
82124// EqualsWithoutDeployment returns true if two AutomationConfig objects are meaningful equal by following the following conditions:
83125// - Not taking AutomationConfig.Deployment into consideration.
84126// - Serializing ac A and ac B to ensure that we remove util.MergoDelete before comparing those two.
@@ -450,9 +492,9 @@ func BuildAutomationConfigFromDeployment(deployment Deployment) (*AutomationConf
450492finalAutomationConfig .Ldap = acLdap
451493}
452494
453- oidcSlice , ok := deployment ["oidcProviderConfigs" ]
495+ oidcConfigsArray , ok := deployment ["oidcProviderConfigs" ]
454496if ok {
455- oidcMarshalled , err := json .Marshal (oidcSlice )
497+ oidcMarshalled , err := json .Marshal (oidcConfigsArray )
456498if err != nil {
457499return nil , err
458500}
0 commit comments