Skip to content

setting an api key in the client constructor clobbers whatever transport options you're trying to send in #1940

@svdasein

Description

@svdasein

Found this while trying to connect to a server with self signed certs. I did

transport_options = {
    ssl: {
      verify: false
    }

which didn't seem to have any affect (so I spent an hour or two trying different things - none seemed to make any difference).

I finally started digging into the library and found this little gem:

    def api_key(arguments)
      api_key = if arguments[:api_key].is_a? Hash
                  encode(arguments[:api_key])
                else
                  arguments[:api_key]
                end
      arguments.delete(:user)
      arguments.delete(:password)
      authorization = { 'Authorization' => "ApiKey #{api_key}" }
      if (headers = arguments.dig(:transport_options, :headers))
        headers.merge!(authorization)
      else
        arguments[:transport_options] = {
          headers: authorization
        }
      end
    end

In particular, "if (headers = arguments.dig(:transport_options, :headers))" will return nil if :headers is not defined, and once it does that it just completely overwrites the stuff I passed in with headers: authorization.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions