-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Labels
Description
Description
In the ruby generator, config is shared across all instances. For example, setting config.api_key on one, changes it for all others as well.
This may be a security issue if separate instances are used to authenticate with different credentials.
openapi-generator version
7.19.0-SNAPSHOT
Steps to reproduce
$ git clone https://github.com/OpenAPITools/openapi-generator.git --depth 1
$ cd openapi-generator/samples/client/petstore/ruby
$ bundle install
$ irb -Ilib
irb(main):001> require 'petstore'
irb(main):002> client1 = Petstore::ApiClient.new
irb(main):003> client2 = Petstore::ApiClient.new
irb(main):004> client1.config.api_key
=> {}
irb(main):005> client2.config.api_key
=> {}
irb(main):006> client1.config.api_key['api_key_query'] = 'foo'
irb(main):007> client1.config.api_key
=> {"api_key_query" => "foo"}
irb(main):008> client2.config.api_key
=> {"api_key_query" => "foo"}Suggest a fix
Currently, Configuration.default is a singleton and the default when instantiating a new ApiClient.
To fix this issue, we could create a new Configuration instance when instantiating a new ApiClient, merely copying the default configuration. While this would break calling .configure after instantiating a client, this was probably already surprising behavior as well. In any case, the new approach would match behavior of ActiveSupport::Configurable, for example.