Revert 0.5.1, sorry for my going too far.

parent 85d2e833
source :rubygems
group :development do
gem 'rake'
gem 'jeweler'
end
group :test do
gem 'actionpack', '~>2.3.8'
gem 'mocha', '>=0.9.8'
gem 'typhoeus', '>=0.1.13'
gem 'em-http-request', "0.2.11"
gem 'curb', ">= 0.6.6.0"
gem 'webmock'
end
GEM
remote: http://rubygems.org/
specs:
actionpack (2.3.14)
activesupport (= 2.3.14)
rack (~> 1.1.0)
activesupport (2.3.14)
addressable (2.2.7)
crack (0.3.1)
curb (0.8.0)
em-http-request (0.2.11)
addressable (>= 2.0.0)
eventmachine (>= 0.12.9)
eventmachine (0.12.10)
git (1.2.5)
jeweler (1.8.3)
bundler (~> 1.0)
git (>= 1.2.5)
rake
rdoc
json (1.6.6)
metaclass (0.0.1)
mime-types (1.18)
mocha (0.11.1)
metaclass (~> 0.0.1)
rack (1.1.3)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
typhoeus (0.3.3)
mime-types
webmock (1.8.6)
addressable (>= 2.2.7)
crack (>= 0.1.7)
PLATFORMS
ruby
DEPENDENCIES
actionpack (~> 2.3.8)
curb (>= 0.6.6.0)
em-http-request (= 0.2.11)
jeweler
mocha (>= 0.9.8)
rake
typhoeus (>= 0.1.13)
webmock
=== 0.4.7 2012-09-03
* Fix merging paths if the path is not empty
* Set a configurable timeout for all requests (Rick Olson)
* Fix nested hash params in Consumer#request (Ernie Miller)
=== 0.4.6 2012-04-21
* Fixed nested attributes in #normalize (Shaliko Usubov)
* Make use the path component of the :site parameter (Jonathon M. Abbott)
* Fixed post body's being dropped in 1.9 (Steven Hammond)
* Fixed PUT request handling (Anton Panasenko)
=== 0.4.5 2011-06-25
* Add explicit require for rsa/sha1 (Juris Galang)
* Use webmock to mock all http-requests in tests (Adrian Feldman)
* Add gemtest support (Adrian Feldman)
* Fix POST Requests with Typhoeus proxy (niedhui)
* Mention Typhoeus require in the README (Kim Ahlström)
* Fix incorrect hardcoded port (Ian Taylor)
* Use Net::HTTPGenericRequest (Jakub Kuźma)
=== 0.4.4 2010-10-31
* Fix LoadError rescue in tests: return can't be used in this context (Hans de Graaff)
* HTTP headers should be strings. (seancribbs)
* ensure consumer uri gets set back to original config even if an error occurs (Brian Finney)
* Yahoo uses & to split records in OAuth headers (Brian Finney)
* Added support for Rails 3 in client/action_controller_request (Pelle)
== 0.4.3 2010-09-01
* Fix for em-http proxy (ichverstehe)
== 0.4.2 2010-08-13
* Fixed compatibility with Ruby 1.9.2 (ecavazos)
* Fixed the em-http request proxy (Joshua Hull)
* Fix for oauth proxy string manipulation (Jakub Suder)
* Added Bundler (rc) Gemfile for easier dev/testing
== 0.4.1 2010-06-16
* Added support for using OAuth with proxies (Marsh Gardiner)
* Rails 3 Compatibility fixes (Pelle Braendgaard)
* Fixed load errors on tests for missing (non-required) libraries
== 0.4.0 2010-04-22
* Added computation of oauth_body_hash as per OAuth Request Body Hash 1.0
Draft 4 (Michael Reinsch)
* Added the optional `oauth_session_handle` parameter for the Yahoo implementation (Will Bailey)
* Better marshalling implementation (Yoan Blanc)
* Added optional block to OAuth::Consumer.get_*_token (Neill Pearman)
* Exclude `oauth_callback` with :exclude_callback (Neill Pearman)
* Strip extraneous spaces and line breaks from access_token responses
(observed in the wild with Yahoo!'s OAuth+OpenID hybrid) (Eric Hartmann)
* Stop double-escaping PLAINTEXT signatures (Jimmy Zimmerman)
* OAuth::Client::Helper won't override the specified `oauth_version`
(Philip Kromer)
* Support for Ruby 1.9 (Aaron Quint, Corey Donahoe, et al)
* Fixed an encoding / multibyte issue (成田 一生)
* Replaced hoe with Jeweler (Aaron Quint)
* Support for Typhoeus (Bill Kocik)
* Support for em-http (EventMachine) (Darcy Laycock)
* Support for curb (André Luis Leal Cardoso Junior)
* New website (Aaron Quint)
== 0.3.6 2009-09-14
* Added -B CLI option to use the :body authentication scheme (Seth)
* Respect `--method` in `authorize` CLI command (Seth)
* Support POST and PUT with raw bodies (Yu-Shan Fung et al)
* Test clean-up (Xavier Shay, Hannes Tydén)
* Added :ca_file consumer option to allow consumer specific certificate
override. (Pelle)
== 0.3.5 2009-06-03
* `query` CLI command to access protected resources (Seth)
* Added -H, -Q CLI options for specifying the authentication scheme (Seth)
* Added -O CLI option for specifying a file containing options (Seth)
* Support streamable body contents for large request bodies (Seth Cousins)
* Support for OAuth 1.0a (Seth)
* Added proxy support to OAuth::Consumer (Marshall Huss)
* Added --scope CLI option for Google's 'scope' parameter (Seth)
== 0.3.4 2009-05-06
* OAuth::Client::Helper uses OAuth::VERSION (chadisfaction)
* Fix OAuth::RequestProxy::ActionControllerRequest's handling of params
(Tristan Groléat)
== 0.3.3 2009-05-04
* Corrected OAuth XMPP namespace (Seth)
* Improved error handling for invalid Authorization headers (Matt Sanford)
* Fixed signatures for non-ASCII under $KCODE other than 'u' (Matt Sanford)
* Fixed edge cases in ActionControllerRequestProxy where params were being
incorrectly signed (Marcos Wright Kuhns)
* Support for arguments in OAuth::Consumer#get_access_token (Matt Sanford)
* Add gem version to user-agent header (Matt Sanford)
* Handle input from aggressive form encoding libraries (Matt Wood)
== 0.3.2 2009-03-23
* 2xx statuses should be treated as success (Anders Conbere)
* Support applications using the MethodOverride Rack middleware (László Bácsi)
* `authorize` command for `oauth` CLI (Seth)
* Initial support for Problem Reporting extension (Seth)
* Verify SSL certificates if CA certificates are available (Seth)
* Fixed ActionController parameter escaping behavior (Thiago Arrais, László
Bácsi, Brett Gibson, et al)
* Fixed signature calculation when both options and a block were provided to
OAuth::Signature::Base#initialize (Seth)
* Added help to the 'oauth' CLI (Seth)
* Fixed a problem when attempting to normalize MockRequest URIs (Seth)
== 0.3.1 2009-1-26
* Fixed a problem with relative and absolute token request paths. (Michael
Wood)
== 0.3.0 2009-1-25
* Support ActionController::Request from Edge Rails (László Bácsi)
* Correctly handle multi-valued parameters (Seth)
* Added #normalized_parameters to OAuth::RequestProxy::Base (Pelle)
* OAuth::Signature.sign and friends now yield the RequestProxy instead of the
token when the passed block's arity is 1. (Seth)
* Token requests are made to the configured URL rather than generating a
potentially incorrect one. (Kellan Elliott-McCrea)
* Command-line app for generating signatures. (Seth)
* Improved test-cases and compatibility for encoding issues. (Pelle)
== 0.2.7 2008-9-10 The lets fix the last release release
* Fixed plain text signatures (Andrew Arrow)
* Fixed RSA requests using OAuthTokens. (Philip Lipu Tsai)
== 0.2.6 2008-9-9 The lets RSA release
* Improved support for Ruby 1.8.7 (Bill Kocik)
* Fixed RSA verification to support RSA providers
now using Ruby and RSA
* Improved RSA testing
* Omit token when signing with RSA
* Added support for 'private_key_file' option for RSA signatures (Chris Mear)
* Fixed several edge cases where params were being incorrectly signed (Scott
Hill)
* Fixed RSA signing (choonkeat)
== 0.2.2 2008-2-22 Lets actually support SSL release
* Use HTTPS when required.
== 0.2 2008-1-19 All together now release
This is a big release, where we have merged the efforts of various parties into one common library.
This means there are definitely some API changes you should be aware of. They should be minimal
but please have a look at the unit tests.
== 0.1.2 2007-12-1
* Fixed checks for missing OAuth params to improve performance
* Includes Pat's fix for getting the realm out.
== 0.1.1 2007-11-26
* First release as a GEM
* Moved all non-Rails functionality from the Rails plugin:
http://code.google.com/p/oauth-plugin/
......@@ -10,7 +10,7 @@ See the OAuth specs http://oauth.net/core/1.0/
sudo gem install oauth
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/oauth-ruby
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth/oauth-ruby
== The basics
......@@ -44,9 +44,9 @@ Now that you have an access token, you can use Typhoeus to interact with the OAu
require 'oauth/request_proxy/typhoeus_request'
oauth_params = {:consumer => oauth_consumer, :token => access_token}
hydra = Typhoeus::Hydra.new
req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
req = Typhoeus::Request.new(uri, options)
oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
req.options[:headers].merge!({"Authorization" => oauth_helper.header}) # Signs the request
req.headers.merge!({"Authorization" => oauth_helper.header}) # Signs the request
hydra.queue(req)
hydra.run
@response = req.response
......@@ -54,22 +54,22 @@ Now that you have an access token, you can use Typhoeus to interact with the OAu
== More Information
* RDoc: http://rdoc.info/github/oauth-xx/oauth-ruby/master/frames
* RDoc: http://rdoc.info/projects/oauth/oauth-ruby/
* Mailing List/Google Group: http://groups.google.com/group/oauth-ruby
== How to submit patches
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/oauth-ruby
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth/oauth-ruby
To submit a patch, please fork the oauth project and create a patch with tests. Once you're happy with it send a pull request and post a message to the google group.
== License
This code is free to use under the terms of the MIT license.
This code is free to use under the terms of the MIT license.
== Contact
OAuth Ruby has been created and maintained by a large number of talented individuals.
OAuth Ruby has been created and maintained by a large number of talented individuals.
The current maintainer is Aaron Quint (quirkey).
Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby
Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby
\ No newline at end of file
%w[rubygems rake rake/clean rake/testtask fileutils].each { |f| require f }
$LOAD_PATH << File.dirname(__FILE__) + '/lib'
require 'oauth'
begin
require 'jeweler'
Jeweler::Tasks.new do |s|
s.name = %q{oauth}
s.version = OAuth::VERSION
s.authors = ["Pelle Braendgaard", "Blaine Cook", "Larry Halff", "Jesse Clark", "Jon Crosby", "Seth Fitzsimmons", "Matt Sanford", "Aaron Quint"]
s.email = "oauth-ruby@googlegroups.com"
s.description = "OAuth Core Ruby implementation"
s.summary = s.description
s.rubyforge_project = %q{oauth}
s.add_development_dependency(%q<actionpack>, [">=2.3.5"])
s.add_development_dependency(%q<rack>, [">= 1.0.0"])
s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
s.add_development_dependency(%q<typhoeus>, [">= 0.1.13"])
s.add_development_dependency(%q<em-http-request>, [">= 0.2.10"])
s.add_development_dependency(%q<curb>, [">= 0.6.6.0"])
s.files.include '.gemtest'
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/**/*test*.rb']
t.verbose = true
end
Dir['tasks/**/*.rake'].each { |t| load t }
task :default => :test
......@@ -5,17 +5,8 @@ Maintainer: Debian Ruby Extras Maintainers <pkg-ruby-extras-maintainers@lists.al
Uploaders: Taku YASUI <tach@debian.org>
Build-Depends: debhelper (>= 9~),
gem2deb,
ruby-actionpack,
ruby-byebug,
ruby-curb,
ruby-mocha,
ruby-typhoeus,
ruby-rack-test,
ruby-webmock,
ruby-activesupport,
ruby-rest-client,
rake
Standards-Version: 3.9.8
Standards-Version: 3.9.7
Vcs-Git: https://anonscm.debian.org/git/pkg-ruby-extras/ruby-oauth.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-ruby-extras/ruby-oauth.git
Homepage: https://github.com/oauth-xx/oauth-ruby
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: OAuth
Upstream-Contact: Blaine Cook, Larry Halff, Pelle Braendgaard
Source: https://github.com/oauth-xx/oauth-ruby
Source: http://rubygems.org/gems/oauth
Files: *
Copyright: Copyright (c) 2007 Blaine Cook, Larry Halff, Pelle Braendgaard
......
Description: Add missing RSA files
Author: HIGUCHI Daisuke (VDR dai) <dai@debian.org>
Last-Update: 2016-05-22
Index: ruby-oauth/test/keys/rsa.cert
===================================================================
--- /dev/null
+++ ruby-oauth/test/keys/rsa.cert
@@ -0,0 +1,11 @@
+-----BEGIN CERTIFICATE-----
+MIIBpjCCAQ+gAwIBAgIBATANBgkqhkiG9w0BAQUFADAZMRcwFQYDVQQDDA5UZXN0
+IFByaW5jaXBhbDAeFw03MDAxMDEwODAwMDBaFw0zODEyMzEwODAwMDBaMBkxFzAV
+BgNVBAMMDlRlc3QgUHJpbmNpcGFsMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
+gQC0YjCwIfYoprq/FQO6lb3asXrxLlJFuCvtinTF5p0GxvQGu5O3gYytUvtC2JlY
+zypSRjVxwxrsuRcP3e641SdASwfrmzyvIgP08N4S0IFzEURkV1wp/IpH7kH41Etb
+mUmrXSwfNZsnQRE5SYSOhh+LcK2wyQkdgcMv11l4KoBkcwIDAQABMA0GCSqGSIb3
+DQEBBQUAA4GBAGZLPEuJ5SiJ2ryq+CmEGOXfvlTtEL2nuGtr9PewxkgnOjZpUy+d
+4TvuXJbNQc8f4AMWL/tO9w0Fk80rWKp9ea8/df4qMq5qlFWlx6yOLQxumNOmECKb
+WpkUQDIDJEoFUzKMVuJf4KO/FJ345+BNLGgbJ6WujreoM1X/gYfdnJ/J
+-----END CERTIFICATE-----
Index: ruby-oauth/test/keys/rsa.pem
===================================================================
--- /dev/null
+++ ruby-oauth/test/keys/rsa.pem
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBALRiMLAh9iimur8V
+A7qVvdqxevEuUkW4K+2KdMXmnQbG9Aa7k7eBjK1S+0LYmVjPKlJGNXHDGuy5Fw/d
+7rjVJ0BLB+ubPK8iA/Tw3hLQgXMRRGRXXCn8ikfuQfjUS1uZSatdLB81mydBETlJ
+hI6GH4twrbDJCR2Bwy/XWXgqgGRzAgMBAAECgYBYWVtleUzavkbrPjy0T5FMou8H
+X9u2AC2ry8vD/l7cqedtwMPp9k7TubgNFo+NGvKsl2ynyprOZR1xjQ7WgrgVB+mm
+uScOM/5HVceFuGRDhYTCObE+y1kxRloNYXnx3ei1zbeYLPCHdhxRYW7T0qcynNmw
+rn05/KO2RLjgQNalsQJBANeA3Q4Nugqy4QBUCEC09SqylT2K9FrrItqL2QKc9v0Z
+zO2uwllCbg0dwpVuYPYXYvikNHHg+aCWF+VXsb9rpPsCQQDWR9TT4ORdzoj+Nccn
+qkMsDmzt0EfNaAOwHOmVJ2RVBspPcxt5iN4HI7HNeG6U5YsFBb+/GZbgfBT3kpNG
+WPTpAkBI+gFhjfJvRw38n3g/+UeAkwMI2TJQS4n8+hid0uus3/zOjDySH3XHCUno
+cn1xOJAyZODBo47E+67R4jV1/gzbAkEAklJaspRPXP877NssM5nAZMU0/O/NGCZ+
+3jPgDUno6WbJn5cqm8MqWhW1xGkImgRk+fkDBquiq4gPiT898jusgQJAd5Zrr6Q8
+AO/0isr/3aa6O6NLQxISLKcPDk2NOccAfS/xOtfOz4sJYM3+Bs4Io9+dZGSDCA54
+Lw03eHTNQghS0A==
+-----END PRIVATE KEY-----
add_missing_rsa.patch
Dir['test/**/*.rb'].each { |f| require f }
# FIXME
# there's a spec/ or a test/ directory in the upstream source, but
# no test suite was defined in the Gem specification. It would be
# a good idea to define it here so the package gets tested at build time.
# Examples:
# $: << 'lib' << '.'
# Dir['{spec,test}/**/*.rb'].each { |f| require f }
#
# require 'test/ts_foo.rb'
#
# require 'rbconfig'
# ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
# exec("#{ruby} -I. test/runtests.rb")
#!/usr/bin/env ruby -rubygems
# Sample queries:
# ./yql.rb --consumer-key <key> --consumer-secret <secret> "show tables"
# ./yql.rb --consumer-key <key> --consumer-secret <secret> "select * from flickr.photos.search where text='Cat' limit 10"
require 'oauth'
require 'optparse'
require 'json'
require 'pp'
options = {}
option_parser = OptionParser.new do |opts|
opts.banner = "Usage: #{$0} [options] <query>"
opts.on("--consumer-key KEY", "Specifies the consumer key to use.") do |v|
options[:consumer_key] = v
end
opts.on("--consumer-secret SECRET", "Specifies the consumer secret to use.") do |v|
options[:consumer_secret] = v
end
end
option_parser.parse!
query = ARGV.pop
query = STDIN.read if query == "-"
if options[:consumer_key].nil? || options[:consumer_secret].nil? || query.nil?
puts option_parser.help
exit 1
end
consumer = OAuth::Consumer.new \
options[:consumer_key],
options[:consumer_secret],
:site => "http://query.yahooapis.com"
access_token = OAuth::AccessToken.new(consumer)
response = access_token.request(:get, "/v1/yql?q=#{OAuth::Helper.escape(query)}&format=json")
rsp = JSON.parse(response.body)
pp rsp
# = digest/hmac.rb
#
# An implementation of HMAC keyed-hashing algorithm
#
# == Overview
#
# This library adds a method named hmac() to Digest classes, which
# creates a Digest class for calculating HMAC digests.
#
# == Examples
#
# require 'digest/hmac'
#
# # one-liner example
# puts Digest::HMAC.hexdigest("data", "hash key", Digest::SHA1)
#
# # rather longer one
# hmac = Digest::HMAC.new("foo", Digest::RMD160)
#
# buf = ""
# while stream.read(16384, buf)
# hmac.update(buf)
# end
#
# puts hmac.bubblebabble
#
# == License
#
# Copyright (c) 2006 Akinori MUSHA <knu@iDaemons.org>
#
# Documentation by Akinori MUSHA
#
# All rights reserved. You can redistribute and/or modify it under
# the same terms as Ruby.
#
# $Id: hmac.rb 14881 2008-01-04 07:26:14Z akr $
#
require 'digest'
unless defined?(Digest::HMAC)
module Digest
class HMAC < Digest::Class
def initialize(key, digester)
@md = digester.new
block_len = @md.block_length
if key.bytesize > block_len
key = @md.digest(key)
end
ipad = Array.new(block_len).fill(0x36)
opad = Array.new(block_len).fill(0x5c)
key.bytes.each_with_index { |c, i|
ipad[i] ^= c
opad[i] ^= c
}
@key = key.freeze
@ipad = ipad.inject('') { |s, c| s << c.chr }.freeze
@opad = opad.inject('') { |s, c| s << c.chr }.freeze
@md.update(@ipad)
end
def initialize_copy(other)
@md = other.instance_eval { @md.clone }
end
def update(text)
@md.update(text)
self
end
alias << update
def reset
@md.reset
@md.update(@ipad)
self
end
def finish
d = @md.digest!
@md.update(@opad)
@md.update(d)
@md.digest!
end
private :finish
def digest_length
@md.digest_length
end
def block_length
@md.block_length
end
def inspect
sprintf('#<%s: key=%s, digest=%s>', self.class.name, @key.inspect, @md.inspect.sub(/^\#<(.*)>$/) { $1 });
end
end
end
end
$LOAD_PATH << File.dirname(__FILE__) unless $LOAD_PATH.include?(File.dirname(__FILE__))
require 'oauth/version'
module OAuth
VERSION = "0.4.7"
end
require 'oauth/oauth'
require 'oauth/core_ext'
......
......@@ -57,7 +57,7 @@ module OAuth
oauth_verifier = nil
# get a request token
request_token = consumer.get_request_token({ :oauth_callback => options[:oauth_callback] }, options[:scope] ? { "scope" => options[:scope] } : {})
request_token = consumer.get_request_token({ :oauth_callback => options[:oauth_callback] }, { "scope" => options[:scope] })
if request_token.callback_confirmed?
stdout.puts "Server appears to support OAuth 1.0a; enabling support."
......@@ -107,7 +107,7 @@ module OAuth
uri.query = [uri.query, *params].reject { |x| x.nil? } * "&"
p uri.to_s
response = access_token.request(options[:method].to_s.downcase.to_sym, uri.to_s)
response = access_token.request(options[:method].downcase.to_sym, uri.to_s)
puts "#{response.code} #{response.message}"
puts response.body
when "sign"
......@@ -268,7 +268,7 @@ module OAuth
options[:uri] = v
end
opts.on("--version [VERSION]", "Specifies the OAuth version to use.") do |v|
opts.on(:OPTIONAL, "--version VERSION", "Specifies the OAuth version to use.") do |v|
if v
options[:oauth_version] = v
else
......
......@@ -56,10 +56,6 @@ module OAuth::Client
:parameters => oauth_parameters}.merge(extra_options) )
end
def token_request?
@options[:token_request].eql?(true)
end
def hash_body
@options[:body_hash] = OAuth::Signature.body_hash(@request, :parameters => oauth_parameters)
end
......
......@@ -21,8 +21,7 @@ class Net::HTTPGenericRequest
# This method also modifies the <tt>User-Agent</tt> header to add the OAuth gem version.
#
# See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1],
# {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html,
# http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html#when_to_include]
# {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html]
def oauth!(http, consumer = nil, token = nil, options = {})
helper_options = oauth_helper_options(http, consumer, token, options)
@oauth_helper = OAuth::Client::Helper.new(self, helper_options)
......@@ -43,14 +42,13 @@ class Net::HTTPGenericRequest
# * options - Request-specific options (e.g. +request_uri+, +consumer+, +token+, +scheme+,
# +signature_method+, +nonce+, +timestamp+)
#
# See Also: {OAuth core spec version 1.0, section 5.4.1}[http://oauth.net/core/1.0#rfc.section.5.4.1],
# {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html,
# http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/oauth-bodyhash.html#when_to_include]
# See Also: {OAuth core spec version 1.0, section 9.1.1}[http://oauth.net/core/1.0#rfc.section.9.1.1],
# {OAuth Request Body Hash 1.0 Draft 4}[http://oauth.googlecode.com/svn/spec/ext/body_hash/1.0/drafts/4/spec.html]
def signature_base_string(http, consumer = nil, token = nil, options = {})
helper_options = oauth_helper_options(http, consumer, token, options)
@oauth_helper = OAuth::Client::Helper.new(self, helper_options)
@oauth_helper.hash_body if oauth_body_hash_required?
@oauth_helper.signature_base_string
oauth_helper = OAuth::Client::Helper.new(self, helper_options)
oauth_helper.hash_body if oauth_body_hash_required?
oauth_helper.signature_base_string
end
private
......@@ -86,7 +84,7 @@ private
end
def oauth_body_hash_required?
!@oauth_helper.token_request? && request_body_permitted? && !content_type.to_s.downcase.start_with?("application/x-www-form-urlencoded")
request_body_permitted? && !content_type.to_s.downcase.start_with?("application/x-www-form-urlencoded")
end
def set_oauth_header
......
......@@ -8,9 +8,9 @@ require 'cgi'
module OAuth
class Consumer
# determine the certificate authority path to verify SSL certs
CA_FILES = %W(#{ENV['SSL_CERT_FILE']} /etc/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt /usr/share/curl/curl-ca-bundle.crt)
CA_FILES = %w(/etc/ssl/certs/ca-certificates.crt /usr/share/curl/curl-ca-bundle.crt)
CA_FILES.each do |ca_file|
if File.exist?(ca_file)
if File.exists?(ca_file)
CA_FILE = ca_file
break
end
......@@ -191,7 +191,6 @@ module OAuth
# Creates a request and parses the result as url_encoded. This is used internally for the RequestToken and AccessToken requests.
def token_request(http_method, path, token = nil, request_options = {}, *arguments)
request_options[:token_request] ||= true
response = request(http_method, path, token, request_options, *arguments)
case response.code.to_i
......@@ -235,8 +234,8 @@ module OAuth
end
def request_endpoint
return nil if @options[:request_endpoint].nil?
@options[:request_endpoint].to_s
return nil if @options[:request_endpoint].nil?
@options[:request_endpoint].to_s
end
def scheme
......@@ -329,7 +328,7 @@ module OAuth
def create_http_request(http_method, path, *arguments)
http_method = http_method.to_sym
if [:post, :put, :patch].include?(http_method)
if [:post, :put].include?(http_method)
data = arguments.shift
end
......@@ -346,9 +345,6 @@ module OAuth
when :put
request = Net::HTTP::Put.new(path,headers)
request["Content-Length"] = '0' # Default to 0
when :patch
request = Net::HTTP::Patch.new(path,headers)
request["Content-Length"] = '0' # Default to 0
when :get
request = Net::HTTP::Get.new(path,headers)
when :delete
......
......@@ -9,9 +9,9 @@ module OAuth
#
# See Also: {OAuth core spec version 1.0, section 5.1}[http://oauth.net/core/1.0#rfc.section.5.1]
def escape(value)
URI::escape(value.to_s.to_str, OAuth::RESERVED_CHARACTERS)
URI::escape(value.to_s, OAuth::RESERVED_CHARACTERS)
rescue ArgumentError
URI::escape(value.to_s.to_str.force_encoding(Encoding::UTF_8), OAuth::RESERVED_CHARACTERS)
URI::escape(value.to_s.force_encoding(Encoding::UTF_8), OAuth::RESERVED_CHARACTERS)
end
# Generate a random key of up to +size+ bytes. The value returned is Base64 encoded with non-word
......@@ -49,7 +49,7 @@ module OAuth
end
end * "&"
end
#Returns a string representation of the Hash like in URL query string
# build_nested_query({:level_1 => {:level_2 => ['value_1','value_2']}}, 'prefix'))
# #=> ["prefix%5Blevel_1%5D%5Blevel_2%5D%5B%5D=value_1", "prefix%5Blevel_1%5D%5Blevel_2%5D%5B%5D=value_2"]
......
require 'active_support'
require "active_support/version"
require 'action_controller'
require 'action_controller/request'
require 'uri'
if
Gem::Version.new(ActiveSupport::VERSION::STRING) < Gem::Version.new("3")
then # rails 2.x
require 'action_controller/request'
unless ActionController::Request::HTTP_METHODS.include?("patch")
ActionController::Request::HTTP_METHODS << "patch"