Skip to content

Commit

Permalink
Merge branch 'master' of http://github.com/oauth/oauth-ruby into oaut…
Browse files Browse the repository at this point in the history
…h-ruby

Conflicts:
	HISTORY
	Rakefile
	lib/oauth/helper.rb
	lib/oauth/signature/plaintext.rb
	oauth.gemspec
	test/test_action_controller_request_proxy.rb
	test/test_signature.rb
  • Loading branch information
pelle committed May 6, 2010
2 parents c867394 + b23a609 commit 3bc0db7
Show file tree
Hide file tree
Showing 59 changed files with 1,636 additions and 2,915 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
pkg/*
_site
34 changes: 30 additions & 4 deletions History.txt → HISTORY
@@ -1,8 +1,32 @@
== 0.3.6
== 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)
* Added :ca_file consumer option to allow consumer specific certificate override. (Pelle)
* Added a secure_equals in Helper to prevent timing attacks. (Pelle)
* 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

Expand Down Expand Up @@ -85,7 +109,9 @@

== 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.
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

Expand Down
File renamed without changes.
84 changes: 0 additions & 84 deletions Manifest.txt

This file was deleted.

37 changes: 18 additions & 19 deletions README.rdoc
@@ -1,4 +1,4 @@
= Ruby OAuth GEM
= Ruby OAuth

== What

Expand All @@ -10,9 +10,7 @@ See the OAuth specs http://oauth.net/core/1.0/

sudo gem install oauth

You can also install it from the oauth rubyforge project http://rubyforge.org/projects/oauth/.

The source code is now hosted on the OAuth GitHub Project http://github.com/mojodna/oauth
The source code is now hosted on the OAuth GitHub Project http://github.com/oauth/oauth-ruby

== The basics

Expand All @@ -37,27 +35,26 @@ When user returns create an access_token
@access_token = @request_token.get_access_token
@photos = @access_token.get('/photos.xml')

For more detailed instructions I have written this OAuth Client Tutorial http://stakeventures.com/articles/2008/02/23/developing-oauth-clients-in-ruby and "How to turn your rails site into an OAuth Provider ":http://stakeventures.com/articles/2007/11/26/how-to-turn-your-rails-site-into-an-oauth-provider .

Finally be sure to check out the OAuth RDoc Manual http://oauth.rubyforge.org/rdoc/ .

== Documentation Wiki
Now that you have an access token, you can use Typhoeus to interact with the OAuth provider if you choose.

There is some documentation on the Google Code project for the "OAuth Rails Plugin":http://code.google.com/p/oauth-plugin/ :
oauth_params = {:consumer => oauth_consumer, :token => access_token}
hydra = Typhoeus::Hydra.new
req = Typhoeus::Request.new(uri, options)
oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
req.headers.merge!({"Authorization" => oauth_helper.header}) # Signs the request
hydra.queue(req)
hydra.run
@response = req.response

* RequestToken http://code.google.com/p/oauth-plugin/wiki/RequestToken
* AccessToken http://code.google.com/p/oauth-plugin/wiki/AccessToken

== Forum

http://groups.google.com/group/oauth-ruby
== More Information

* RDoc: http://rdoc.info/projects/oauth/oauth-ruby/
* Mailing List/Google Group: http://groups.google.com/group/oauth-ruby

== How to submit patches

Read the "8 steps for fixing other people's code" http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/.

The source code is now hosted on the OAuth GitHub Project http://github.com/mojodna/oauth
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.

Expand All @@ -67,5 +64,7 @@ This code is free to use under the terms of the MIT license.

== Contact

Comments are welcome. Send an email to "Pelle Braendgaard" pelleb@gmail.com email via the OAuth Ruby mailing list http://groups.google.com/group/oauth-ruby
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
60 changes: 25 additions & 35 deletions Rakefile
@@ -1,45 +1,35 @@
%w[rubygems rake rake/clean fileutils].each { |f| require f }
%w[rubygems rake rake/clean rake/testtask fileutils].each { |f| require f }
$LOAD_PATH << File.dirname(__FILE__) + '/lib'
require 'oauth'
require 'oauth/version'

begin
require 'hoe'
require 'newgem'
require 'rubigen'

# Generate all the Rake tasks
# Run 'rake -T' to see list of generated tasks (from gem root directory)
$hoe = Hoe.new('oauth', OAuth::VERSION) do |p|
p.author = ['Pelle Braendgaard','Blaine Cook','Larry Halff','Jesse Clark','Jon Crosby', 'Seth Fitzsimmons']
p.email = "oauth-ruby@googlegroups.com"
p.description = "OAuth Core Ruby implementation"
p.summary = p.description
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
p.rubyforge_name = p.name # TODO this is default value
p.url = "http://oauth.rubyforge.org"

p.extra_deps = [
['ruby-hmac','>= 0.3.1']
]
p.extra_dev_deps = [
['newgem', ">= #{::Newgem::VERSION}"],
['actionpack'],
['rack']
]

p.clean_globs |= %w[**/.DS_Store tmp *.log **/.*.sw? *.gem .config **/.DS_Store]
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
p.rsync_args = '-av --delete --ignore-errors'
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.2.0", "<2.3.0"])
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>)
s.add_development_dependency(%q<curb>, [">= 0.6.6.0"])
end

require 'newgem/tasks' # load /tasks/*.rake
Jeweler::GemcutterTasks.new
rescue LoadError
puts "hoe not available"
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 }

# TODO - want other tests/tasks run by default? Add them to the list
# task :default => [:spec, :features]
task :default => :test
1 change: 1 addition & 0 deletions TODO
Expand Up @@ -29,3 +29,4 @@ Random TODOs:
* sensible Exception hierarchy
* Tokens as Modules
* don't tie to Net::HTTP
* Take a look at Curb HTTP Verbs
4 changes: 2 additions & 2 deletions bin/oauth
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby -w -rubygems
#!/usr/bin/env ruby

require "oauth/cli"

OAuth::CLI.execute(STDOUT, STDIN, STDERR, ARGV)
OAuth::CLI.execute(STDOUT, STDIN, STDERR, ARGV)
104 changes: 104 additions & 0 deletions lib/digest/hmac.rb
@@ -0,0 +1,104 @@
# = 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

0 comments on commit 3bc0db7

Please sign in to comment.