authlogic-connect-andrewacove 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ require 'rake/gempackagetask'
|
|
6
6
|
spec = Gem::Specification.new do |s|
|
7
7
|
s.name = "authlogic-connect-andrewacove"
|
8
8
|
s.authors = ['Lance Pollard', 'Andrew Cove']
|
9
|
-
s.version = '0.5.
|
9
|
+
s.version = '0.5.7'
|
10
10
|
s.summary = "Personal fork of Authlogic Connect: Oauth and OpenID made dead simple"
|
11
11
|
s.homepage = "http://github.com/andrewacove/authlogic-connect"
|
12
12
|
s.email = "andrewacove@gmail.com"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
require "rubygems"
|
3
3
|
require 'authlogic'
|
4
|
-
require 'oauth'
|
4
|
+
require 'apigee-oauth'
|
5
5
|
require 'oauth2'
|
6
6
|
|
7
7
|
this = File.dirname(__FILE__)
|
@@ -24,4 +24,4 @@ custom_models += Dir["#{library}/openid/tokens"]
|
|
24
24
|
custom_models.each do |path|
|
25
25
|
$LOAD_PATH << path
|
26
26
|
ActiveSupport::Dependencies.load_paths << path
|
27
|
-
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require "rubygems"
|
3
|
+
require 'authlogic'
|
4
|
+
require 'oauth'
|
5
|
+
require 'oauth2'
|
6
|
+
|
7
|
+
this = File.dirname(__FILE__)
|
8
|
+
library = "#{this}/authlogic_connect"
|
9
|
+
|
10
|
+
require "#{this}/open_id_authentication"
|
11
|
+
require "#{library}/ext"
|
12
|
+
require "#{library}/authlogic_connect"
|
13
|
+
require "#{library}/callback_filter"
|
14
|
+
require "#{library}/access_token"
|
15
|
+
require "#{library}/openid"
|
16
|
+
require "#{library}/oauth"
|
17
|
+
require "#{library}/common"
|
18
|
+
require "#{library}/engine" if defined?(Rails) && Rails::VERSION::MAJOR == 3
|
19
|
+
|
20
|
+
custom_models = ["#{library}/access_token"]
|
21
|
+
custom_models += Dir["#{library}/oauth/tokens"]
|
22
|
+
custom_models += Dir["#{library}/openid/tokens"]
|
23
|
+
|
24
|
+
custom_models.each do |path|
|
25
|
+
$LOAD_PATH << path
|
26
|
+
ActiveSupport::Dependencies.load_paths << path
|
27
|
+
end
|
@@ -1,4 +1,12 @@
|
|
1
1
|
class OauthToken < AccessToken
|
2
|
+
OAuth::Consumer.class_eval do
|
3
|
+
alias_method :orig_sign!, :sign!
|
4
|
+
|
5
|
+
def sign!(request, token=nil, request_options={})
|
6
|
+
request_options.reverse_merge!(:site => options[:signing_endpoint]) if options[:signing_endpoint]
|
7
|
+
orig_sign!(request, token, request_options)
|
8
|
+
end
|
9
|
+
end
|
2
10
|
|
3
11
|
def client
|
4
12
|
unless @client
|
@@ -23,18 +31,19 @@ class OauthToken < AccessToken
|
|
23
31
|
user_agent = config_options[:user_agent]
|
24
32
|
end
|
25
33
|
path.insert(0, "/#{api_version}") unless api_version.nil?
|
26
|
-
options.reverse_merge!
|
34
|
+
options.reverse_merge!("User-Agent" => user_agent) unless user_agent.nil?
|
27
35
|
client.get(path, options)
|
28
36
|
end
|
29
37
|
|
30
38
|
def post(path, body='', headers ={})
|
39
|
+
debugger
|
31
40
|
config_options = self.class.send(:credentials)[:options]
|
32
41
|
unless config_options.nil?
|
33
42
|
api_version = config_options[:api_version]
|
34
43
|
user_agent = config_options[:user_agent]
|
35
44
|
end
|
36
45
|
path.insert(0, "/#{api_version}") unless api_version.nil?
|
37
|
-
headers.reverse_merge!
|
46
|
+
headers.reverse_merge!("User-Agent" => user_agent) unless user_agent.nil?
|
38
47
|
client.post(path, body, headers)
|
39
48
|
end
|
40
49
|
|
@@ -66,13 +75,23 @@ class OauthToken < AccessToken
|
|
66
75
|
end
|
67
76
|
|
68
77
|
|
69
|
-
def
|
78
|
+
def consumer_helper options
|
70
79
|
if oauth_version == 1.0
|
71
|
-
OAuth::Consumer.new(credentials[:key], credentials[:secret], config.merge(
|
80
|
+
OAuth::Consumer.new(credentials[:key], credentials[:secret], config.merge(options || {}))
|
72
81
|
else
|
73
|
-
OAuth2::Client.new(credentials[:key], credentials[:secret], config.merge(
|
82
|
+
OAuth2::Client.new(credentials[:key], credentials[:secret], config.merge(options || {}))
|
74
83
|
end
|
75
84
|
end
|
85
|
+
|
86
|
+
def consumer
|
87
|
+
consumer_helper credentials[:options]
|
88
|
+
end
|
89
|
+
|
90
|
+
def signing_consumer
|
91
|
+
signing_endpoint = credentials[:options].try(:fetch, :signing_endpoint, nil)
|
92
|
+
site_option = {:site => signing_endpoint} unless signing_endpoint.nil?
|
93
|
+
consumer_helper credentials[:options].try(:merge, site_option||{})
|
94
|
+
end
|
76
95
|
|
77
96
|
# if we're lucky we can find it by the token.
|
78
97
|
def find_by_key_or_token(key, token, options = {})
|
@@ -137,14 +156,14 @@ class OauthToken < AccessToken
|
|
137
156
|
end
|
138
157
|
|
139
158
|
def request_token(token, secret)
|
140
|
-
OAuth::RequestToken.new(
|
159
|
+
OAuth::RequestToken.new(signing_consumer, token, secret)
|
141
160
|
end
|
142
161
|
|
143
162
|
# if you pass a hash as the second parameter to consumer.get_request_token,
|
144
163
|
# ruby oauth will think this is a form and all sorts of bad things happen
|
145
164
|
def get_request_token(callback_url)
|
146
165
|
options = {:scope => config[:scope]} if config[:scope]
|
147
|
-
|
166
|
+
signing_consumer.get_request_token({:oauth_callback => callback_url}, options)
|
148
167
|
end
|
149
168
|
|
150
169
|
def get_access_token(oauth_verifier)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authlogic-connect-andrewacove
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 7
|
10
|
+
version: 0.5.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lance Pollard
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-07-
|
19
|
+
date: 2010-07-22 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- init.rb
|
152
152
|
- MIT-LICENSE
|
153
153
|
- lib/authlogic-connect-andrewacove.rb
|
154
|
+
- lib/authlogic-connect-andrewacove.rb~
|
154
155
|
- lib/authlogic_connect/access_token.rb
|
155
156
|
- lib/authlogic_connect/authlogic_connect.rb
|
156
157
|
- lib/authlogic_connect/callback_filter.rb
|