@@ -139,8 +139,17 @@ filter_mgt_resource_servers_without_oauth_client_id_for_sp_initiated(MgtResource
139139filter_mgt_resource_servers_without_oauth_provider_url (MgtResourceServers ) ->
140140 maps :filter (fun (_K1 ,V1 ) -> maps :is_key (oauth_provider_url , V1 ) end , MgtResourceServers ).
141141
142+ ensure_oauth_resource_server_properties_are_binaries (Key , Value ) ->
143+ case Key of
144+ oauth_authorization_endpoint_params -> Value ;
145+ oauth_token_endpoint_params -> Value ;
146+ _ -> to_binary (Value )
147+ end .
148+
142149produce_auth_settings (MgtResourceServers , ManagementProps ) ->
143- ConvertValuesToBinary = fun (_K ,V ) -> [ {K1 , to_binary (V1 )} || {K1 ,V1 } <- maps :to_list (V ) ] end ,
150+ ConvertValuesToBinary = fun (_K ,V ) -> [
151+ {K1 , ensure_oauth_resource_server_properties_are_binaries (K1 , V1 )} || {K1 ,V1 }
152+ <- maps :to_list (V )] end ,
144153 FilteredMgtResourceServers = filter_mgt_resource_servers_without_oauth_provider_url (
145154 filter_mgt_resource_servers_without_oauth_client_id_for_sp_initiated (MgtResourceServers , ManagementProps )),
146155
@@ -150,16 +159,16 @@ produce_auth_settings(MgtResourceServers, ManagementProps) ->
150159 filter_empty_properties ([
151160 {oauth_enabled , true },
152161 {oauth_resource_servers , maps :map (ConvertValuesToBinary , FilteredMgtResourceServers )},
153- to_tuple (oauth_disable_basic_auth , ManagementProps , true ),
162+ to_tuple (oauth_disable_basic_auth , ManagementProps , fun to_binary / 1 , true ),
154163 to_tuple (oauth_client_id , ManagementProps ),
155164 to_tuple (oauth_client_secret , ManagementProps ),
156165 to_tuple (oauth_scopes , ManagementProps ),
157166 case proplists :get_value (oauth_initiated_logon_type , ManagementProps , sp_initiated ) of
158167 sp_initiated -> {};
159168 idp_initiated -> {oauth_initiated_logon_type , <<" idp_initiated" >>}
160169 end ,
161- to_tuple (oauth_authorization_endpoint_params , ManagementProps ),
162- to_tuple (oauth_token_endpoint_params , ManagementProps )
170+ to_tuple (oauth_authorization_endpoint_params , ManagementProps , undefined , undefined ),
171+ to_tuple (oauth_token_endpoint_params , ManagementProps , undefined , undefined )
163172 ])
164173 end .
165174
@@ -171,6 +180,7 @@ filter_empty_properties(ListOfProperties) ->
171180 end
172181 end , ListOfProperties ).
173182
183+ to_binary (Value ) when is_boolean (Value )-> Value ;
174184to_binary (Value ) -> rabbit_data_coercion :to_binary (Value ).
175185
176186to_json (ReqData , Context ) ->
@@ -188,9 +198,19 @@ is_invalid(List) ->
188198 end end , List ).
189199
190200to_tuple (Key , Proplist ) ->
191- case proplists :is_defined (Key , Proplist ) of
192- true -> {Key , rabbit_data_coercion :to_binary (proplists :get_value (Key , Proplist ))};
193- false -> {}
194- end .
195- to_tuple (Key , Proplist , DefaultValue ) ->
196- {Key , proplists :get_value (Key , Proplist , DefaultValue )}.
201+ to_tuple (Key , Proplist , fun to_binary /1 , undefined ).
202+
203+ to_tuple (Key , Proplist , ConvertFun , DefaultValue ) ->
204+ case proplists :is_defined (Key , Proplist ) of
205+ true ->
206+ {Key , case ConvertFun of
207+ undefined -> proplists :get_value (Key , Proplist );
208+ _ -> ConvertFun (proplists :get_value (Key , Proplist ))
209+ end
210+ };
211+ false ->
212+ case DefaultValue of
213+ undefined -> {};
214+ _ -> {Key , proplists :get_value (Key , Proplist , DefaultValue )}
215+ end
216+ end .
0 commit comments