/usr/lib/ruby/vendor_ruby/faraday/request/authorization.rb is in ruby-faraday 0.9.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | module Faraday
class Request::Authorization < Faraday::Middleware
KEY = "Authorization".freeze unless defined? KEY
# Public
def self.header(type, token)
case token
when String, Symbol
"#{type} #{token}"
when Hash
build_hash(type.to_s, token)
else
raise ArgumentError, "Can't build an Authorization #{type} header from #{token.inspect}"
end
end
# Internal
def self.build_hash(type, hash)
offset = KEY.size + type.size + 3
comma = ",\n#{' ' * offset}"
values = []
hash.each do |key, value|
values << "#{key}=#{value.to_s.inspect}"
end
"#{type} #{values * comma}"
end
def initialize(app, type, token)
@header_value = self.class.header(type, token)
super(app)
end
# Public
def call(env)
unless env.request_headers[KEY]
env.request_headers[KEY] = @header_value
end
@app.call(env)
end
end
end
|