manually add 0.5.3

parent 5cbd4e38
---
engines:
duplication:
enabled: true
config:
languages:
- ruby
fixme:
enabled: true
rubocop:
enabled: true
ratings:
paths:
- "**.rb"
exclude_paths:
- test/
.bundle
Gemfile.lock
coverage
*.gem
This diff is collapsed.
language: ruby
rvm:
- "ruby-head"
- "2.4.0"
- "2.3"
- "2.2"
- "2.1"
- "2.0"
addons:
code_climate:
repo_token: 8f697ca756250f0c2c54170ae27e8a9c459d18a0236903b11291c88291b3aac9
after_success:
- bundle exec codeclimate-test-reporter
source :rubygems
source 'https://rubygems.org'
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
gemspec
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
=== CURRENT
=== 0.5.3 2017-05-24
* Removing legacy scripts (James Pinto)
* Fix #145 - broken CLI required loading active_support (James Pinto)
=== 0.5.2 2017-05-17
* Adding a development dependency that had not been mentioned (James Pinto)
* Use assert_nil so as to silence a Minitest 6 deprecation warning (James Pinto)
* Stop bundling tests files in the gem (Michal Papis)
* Minor cleanup on tests (James Pinto)
* TravisCI no longer needs libcurl-dev (James Pinto)
* Nokogiri 1.7 does not accept Ruby 2.0 (James Pinto)
* Upgrading to CodeClimate 1.0 (James Pinto)
* Adding support to Ruby 2.4 and head (James Pinto)
* Locking gemspec to Rails 4 so as to allow our next version for Rails 5 (James Pinto)
* Fix #113 adding paths when a full URL has been specified (James Pinto)
* moving development dependency to gemspec (James Pinto)
* Silencing 'Net::HTTPResponse#header is obsolete' (James Pinto)
* Silencing some test warnings (James Pinto)
* Silencing 'loading in progress, circular require considered harmful' (James Pinto)
* Silence 'URI.escape obsolete' (James Pinto)
* Refactored CLI (James Pinto)
* Bug Fix, webmock 2.0 has introduced a new bug (James Pinto)
* Moving test files into test/units/ (James Pinto)
* Adding CodeClimate (James Pinto)
* Reimplementing #82 - Debug Output Option (James Pinto)
* Making a test/support dir (James Pinto)
* Fix #177 - Adjusting to webmock latest recommended implementation for minitest (James Pinto)
* Adding support to Ruby 2.4 and head (James Pinto)
* Upgrading to CodeClimate 1.0 (James Pinto)
* Nokogiri 1.7 does not accept Ruby 2.0 (James Pinto)
=== 0.5.1 2016-02-29
* Proper handling for empty query string in RequestToken#build_authorize_url (midchildan,
Harald Sitter)
* Loosen some development dependencies. Add libcurl-dev to travis
* Add license info to the gemspec (Robert Reiz)
* Fixes to travis config. Switch to rubygems for installation and loading
* Remove obsolete comment (Arthur Nogueira Neves)
* Remove jeweler from gemspec
* Replace calls to String#blank? with its implementation (Sergio Gil Pérez de la Manga)
=== 0.5.0 2016-02-20
* Fix ability to pass in an authorize url with a query string (Roger Smith)
* Add support for HTTP PATCH method (Richard Huang)
* Allow reading private key from a string (Khaja Minhajuddin)
* Fix bug in signature verification (r-stu31)
* Use standard key name (`oauth_token_secret`) in Token#to_query (Craig Walker)
* Fix error in CLI when using `query` without supplying a method (grafikchaos)
* Compatibility fix for Typhoeus >= 0.5.0 (Chad Feller)
* Add rest-client proxy (Khem Veasna)
* Rails 3+ / ActiveSupport::SafeBuffer patch (Clif Reeder)
* Handle `nil` token gracefully for RequestToken#authorize_url (Brian John)
* Replace jeweler with real spec and bundler tasks
* Extract version to separate file
* Fix typhoeus compatibility (Vladimir Mikhailov)
* Use OpenSSL for all digest and hashing. Remove signature methods not defined by OAuth spec.
Add byebug. (Kevin Hughes)
* Fix oauth cli option parser on Ruby 2.2 (Felix Bünemann)
* Change token requests to exclude `oauth_body_hash`. Update doc links in comments. (John Remmen)
* Update gemspec for security fixes. Convert to Minitest. Add .travis.yml. (Kevin Hughes)
* Allow reading certificate file path from environment variable. Add CentOS cert file path
(Danil Vlasov)
* Fix some warnings (amatsuda)
* Various fixes/updates to README (Evan Arnold, Jonathan Camenisch, Brian John, Ankur Sethi)
=== 0.4.7 2012-09-03
* Fix merging paths if the path is not empty
......@@ -157,8 +230,8 @@
== 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
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
......
= Ruby OAuth
== Status
{<img src="https://travis-ci.org/oauth-xx/oauth-ruby.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/oauth-xx/oauth-ruby]
== What
This is a RubyGem for implementing both OAuth clients and servers in Ruby applications.
......@@ -10,13 +16,13 @@ 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/oauth-ruby
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/oauth-ruby
== The basics
This is a ruby library which is intended to be used in creating Ruby Consumer and Service Provider applications. It is NOT a Rails plugin, but could easily be used for the foundation for such a Rails plugin.
As a matter of fact it has been pulled out from an OAuth Rails Plugin http://code.google.com/p/oauth-plugin/ which now requires this GEM.
As a matter of fact it has been pulled out from an OAuth Rails GEM (https://rubygems.org/gems/oauth-plugin https://github.com/pelle/oauth-plugin) which now uses this gem as a dependency.
== Demonstration of usage
......@@ -31,11 +37,15 @@ Create a new consumer instance by passing it a configuration hash:
Start the process by requesting a token
@request_token = @consumer.get_request_token(:oauth_callback => @callback_url)
session[:request_token] = @request_token
session[:token] = request_token.token
session[:token_secret] = request_token.secret
redirect_to @request_token.authorize_url(:oauth_callback => @callback_url)
When user returns create an access_token
hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
request_token = OAuth::RequestToken.from_hash(@consumer, hash)
@access_token = @request_token.get_access_token
@photos = @access_token.get('/photos.xml')
......@@ -44,9 +54,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)
req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
req.headers.merge!({"Authorization" => oauth_helper.header}) # Signs the request
req.options[:headers].merge!({"Authorization" => oauth_helper.header}) # Signs the request
hydra.queue(req)
hydra.run
@response = req.response
......@@ -54,22 +64,22 @@ Now that you have an access token, you can use Typhoeus to interact with the OAu
== More Information
* RDoc: http://rdoc.info/projects/oauth/oauth-ruby/
* RDoc: http://rdoc.info/github/oauth-xx/oauth-ruby/master/frames
* 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/oauth-ruby
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth-xx/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
\ No newline at end of file
Comments are welcome. Send an email to via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby
%w[rubygems rake rake/clean rake/testtask fileutils].each { |f| require f }
$LOAD_PATH << File.dirname(__FILE__) + '/lib'
require 'oauth'
%w[rubygems rake rake/clean rake/testtask fileutils bundler].each { |f| require f }
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
Bundler::GemHelper.install_tasks
Rake::TestTask.new do |t|
t.libs << "test"
......
#!/usr/bin/env ruby
require "oauth/cli"
require_relative "../lib/oauth"
require 'oauth/cli'
OAuth::CLI.execute(STDOUT, STDIN, STDERR, ARGV)
\ No newline at end of file
Signal.trap("INT") { puts; exit(1) } # don't dump a backtrace on a ^C
ARGV << 'help' if ARGV.empty?
command = ARGV.shift
OAuth::CLI.new(STDOUT, STDIN, STDERR, command, ARGV).run
# = 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__))
root = File.dirname(__FILE__)
$LOAD_PATH << root unless $LOAD_PATH.include?(root)
module OAuth
VERSION = "0.4.7"
end
require 'oauth/version'
require 'oauth/oauth'
require 'oauth/core_ext'
......
This diff is collapsed.
class OAuth::CLI
class AuthorizeCommand < BaseCommand
def required_options
[:uri]
end
def _run
request_token = get_request_token
if request_token.callback_confirmed?
puts "Server appears to support OAuth 1.0a; enabling support."
options[:version] = "1.0a"
end
puts "Please visit this url to authorize:"
puts request_token.authorize_url
# parameters for OAuth 1.0a
oauth_verifier = ask_user_for_verifier
verbosely_get_access_token(request_token, oauth_verifier)
end
def get_request_token
consumer = get_consumer
scope_options = options[:scope] ? { "scope" => options[:scope] } : {}
consumer.get_request_token({ :oauth_callback => options[:oauth_callback] }, scope_options)
rescue OAuth::Unauthorized => e
alert "A problem occurred while attempting to authorize:"
alert e
alert e.request.body
end
def get_consumer
OAuth::Consumer.new \
options[:oauth_consumer_key],
options[:oauth_consumer_secret],
:access_token_url => options[:access_token_url],
:authorize_url => options[:authorize_url],
:request_token_url => options[:request_token_url],
:scheme => options[:scheme],
:http_method => options[:method].to_s.downcase.to_sym
end
def ask_user_for_verifier
if options[:version] == "1.0a"
puts "Please enter the verification code provided by the SP (oauth_verifier):"
@stdin.gets.chomp
else
puts "Press return to continue..."
@stdin.gets
nil
end
end
def verbosely_get_access_token(request_token, oauth_verifier)
access_token = request_token.get_access_token(:oauth_verifier => oauth_verifier)
puts "Response:"
access_token.params.each do |k,v|
puts " #{k}: #{v}" unless k.is_a?(Symbol)
end
rescue OAuth::Unauthorized => e
alert "A problem occurred while attempting to obtain an access token:"
alert e
alert e.request.body
end
end
end
class OAuth::CLI
class BaseCommand
def initialize(stdout, stdin, stderr, arguments)
@stdout, @stdin, @stderr = stdout, stdin, stderr
@options = {}
option_parser.parse!(arguments)
end
def run
missing = required_options - options.keys
if missing.empty?
_run
else
show_missing(missing)
puts option_parser.help
end
end
def required_options
[]
end
protected
attr_reader :options
def show_missing(array)
array = array.map { |s| "--#{s}" }.join(' ')
OAuth::CLI.puts_red "Options missing to OAuth CLI: #{array}"
end
def xmpp?
options[:xmpp]
end
def verbose?
options[:verbose]
end
def puts(string=nil)
@stdout.puts(string)
end
def alert(string=nil)
@stderr.puts(string)
end
def parameters
@parameters ||= begin
escaped_pairs = options[:params].collect do |pair|
if pair =~ /:/
Hash[*pair.split(":", 2)].collect do |k,v|
[CGI.escape(k.strip), CGI.escape(v.strip)] * "="
end
else
pair
end
end
querystring = escaped_pairs * "&"
cli_params = CGI.parse(querystring)
{
"oauth_consumer_key" => options[:oauth_consumer_key],
"oauth_nonce" => options[:oauth_nonce],
"oauth_timestamp" => options[:oauth_timestamp],
"oauth_token" => options[:oauth_token],
"oauth_signature_method" => options[:oauth_signature_method],
"oauth_version" => options[:oauth_version]
}.reject { |_k,v| v.nil? || v == "" }.merge(cli_params)
end
end
def option_parser
@option_parser ||= OptionParser.new do |opts|
opts.banner = "Usage: oauth <command> [ARGS]"
_option_parser_defaults
_option_parser_common(opts)
_option_parser_sign_and_query(opts)
_option_parser_authorization(opts)
end
end
def _option_parser_defaults
options[:oauth_nonce] = OAuth::Helper.generate_key
options[:oauth_signature_method] = "HMAC-SHA1"
options[:oauth_timestamp] = OAuth::Helper.generate_timestamp
options[:oauth_version] = "1.0"
options[:method] = :post
options[:params] = []
options[:scheme] = :header
options[:version] = "1.0"
end
def _option_parser_common(opts)
## Common Options
opts.on("-B", "--body", "Use the request body for OAuth parameters.") do
options[:scheme] = :body
end
opts.on("--consumer-key KEY", "Specifies the consumer key to use.") do |v|
options[:oauth_consumer_key] = v
end
opts.on("--consumer-secret SECRET", "Specifies the consumer secret to use.") do |v|
options[:oauth_consumer_secret] = v
end
opts.on("-H", "--header", "Use the 'Authorization' header for OAuth parameters (default).") do
options[:scheme] = :header
end
opts.on("-Q", "--query-string", "Use the query string for OAuth parameters.") do
options[:scheme] = :query_string
end
opts.on("-O", "--options FILE", "Read options from a file") do |v|
arguments = open(v).readlines.map { |l| l.chomp.split(" ") }.flatten
options2 = parse_options(arguments)
options.merge!(options2)
end
end
def _option_parser_sign_and_query(opts)
opts.separator("\n options for signing and querying")
opts.on("--method METHOD", "Specifies the method (e.g. GET) to use when signing.") do |v|
options[:method] = v
end
opts.on("--nonce NONCE", "Specifies the none to use.") do |v|
options[:oauth_nonce] = v
end
opts.on("--parameters PARAMS", "Specifies the parameters to use when signing.") do |v|
options[:params] << v
end
opts.on("--signature-method METHOD", "Specifies the signature method to use; defaults to HMAC-SHA1.") do |v|
options[:oauth_signature_method] = v
end
opts.on("--token TOKEN", "Specifies the token to use.") do |v|
options[:oauth_token] = v
end
opts.on("--secret SECRET", "Specifies the token secret to use.") do |v|
options[:oauth_token_secret] = v
end
opts.on("--timestamp TIMESTAMP", "Specifies the timestamp to use.") do |v|
options[:oauth_timestamp] = v
end
opts.on("--realm REALM", "Specifies the realm to use.") do |v|
options[:realm] = v
end
opts.on("--uri URI", "Specifies the URI to use when signing.") do |v|
options[:uri] = v
end
opts.on("--version [VERSION]", "Specifies the OAuth version to use.") do |v|
options[:oauth_version] = v
end
opts.on("--no-version", "Omit oauth_version.") do
options[:oauth_version] = nil
end
opts.on("--xmpp", "Generate XMPP stanzas.") do
options[:xmpp] = true
options[:method] ||= "iq"
end
opts.on("-v", "--verbose", "Be verbose.") do
options[:verbose] = true
end
end
def _option_parser_authorization(opts)
opts.separator("\n options for authorization")
opts.on("--access-token-url URL", "Specifies the access token URL.") do |v|
options[:access_token_url] = v
end
opts.on("--authorize-url URL", "Specifies the authorization URL.") do |v|
options[:authorize_url] = v
end
opts.on("--callback-url URL", "Specifies a callback URL.") do |v|
options[:oauth_callback] = v
end
opts.on("--request-token-url URL", "Specifies the request token URL.") do |v|
options[:request_token_url] = v
end
opts.on("--scope SCOPE", "Specifies the scope (Google-specific).") do |v|
options[:scope] = v
end
end
end
end