rack-oauth2 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/Gemfile.lock +3 -3
- data/README.rdoc +8 -7
- data/VERSION +1 -1
- data/lib/rack/oauth2.rb +37 -7
- data/lib/rack/oauth2/access_token.rb +1 -0
- data/lib/rack/oauth2/client.rb +9 -3
- data/lib/rack/oauth2/debugger.rb +1 -0
- data/lib/rack/oauth2/debugger/request_filter.rb +22 -0
- data/spec/helpers/webmock_helper.rb +0 -4
- metadata +61 -2
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rack-oauth2 (0.9.
|
4
|
+
rack-oauth2 (0.9.2)
|
5
5
|
activesupport (>= 2.3)
|
6
6
|
attr_required (>= 0.0.3)
|
7
7
|
httpclient (>= 2.2.0.2)
|
@@ -12,7 +12,7 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: http://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activesupport (3.0.
|
15
|
+
activesupport (3.0.10)
|
16
16
|
addressable (2.2.6)
|
17
17
|
attr_required (0.0.3)
|
18
18
|
bouncy-castle-java (1.5.0146.1)
|
@@ -36,7 +36,7 @@ GEM
|
|
36
36
|
rspec-expectations (2.6.0)
|
37
37
|
diff-lcs (~> 1.1.2)
|
38
38
|
rspec-mocks (2.6.0)
|
39
|
-
webmock (1.
|
39
|
+
webmock (1.7.4)
|
40
40
|
addressable (> 2.2.5, ~> 2.2)
|
41
41
|
crack (>= 0.1.7)
|
42
42
|
|
data/README.rdoc
CHANGED
@@ -18,27 +18,28 @@ http://www.ietf.org/id/draft-ietf-oauth-v2-http-mac-00.txt
|
|
18
18
|
|
19
19
|
== Resources
|
20
20
|
|
21
|
-
* View Source on GitHub (
|
22
|
-
* Report Issues on GitHub (
|
23
|
-
* Subscribe Update Info (
|
21
|
+
* View Source on GitHub (https://github.com/nov/rack-oauth2)
|
22
|
+
* Report Issues on GitHub (https://github.com/nov/rack-oauth2/issues)
|
23
|
+
* Subscribe Update Info (https://www.facebook.com/rackoauth2)
|
24
|
+
* Q&A on Google Groups (https://groups.google.com/group/rack-oauth2)
|
24
25
|
|
25
26
|
== Sample Server Application (Rails3)
|
26
27
|
|
27
28
|
=== Bearer
|
28
29
|
|
29
30
|
Running on Heroku
|
30
|
-
|
31
|
+
https://rack-oauth2-sample.heroku.com
|
31
32
|
|
32
33
|
Source on GitHub
|
33
|
-
|
34
|
+
https://github.com/nov/rack-oauth2-sample
|
34
35
|
|
35
36
|
=== MAC
|
36
37
|
|
37
38
|
Running on Heroku
|
38
|
-
|
39
|
+
https://rack-oauth2-sample-mac.heroku.com
|
39
40
|
|
40
41
|
Source on GitHub
|
41
|
-
|
42
|
+
https://github.com/nov/rack-oauth2-sample-mac
|
42
43
|
|
43
44
|
== Sample Client
|
44
45
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.3
|
data/lib/rack/oauth2.rb
CHANGED
@@ -1,18 +1,48 @@
|
|
1
|
+
require 'rack'
|
2
|
+
require 'json'
|
3
|
+
require 'httpclient'
|
4
|
+
require 'logger'
|
5
|
+
require 'active_support/core_ext'
|
6
|
+
require 'attr_required'
|
7
|
+
require 'attr_optional'
|
8
|
+
|
1
9
|
module Rack
|
2
10
|
module OAuth2
|
3
11
|
VERSION = ::File.read(
|
4
12
|
::File.join(::File.dirname(__FILE__), '../../VERSION')
|
5
13
|
)
|
14
|
+
|
15
|
+
def self.logger
|
16
|
+
@@logger
|
17
|
+
end
|
18
|
+
def self.logger=(logger)
|
19
|
+
@@logger = logger
|
20
|
+
end
|
21
|
+
self.logger = ::Logger.new(STDOUT)
|
22
|
+
self.logger.progname = 'Rack::OAuth2'
|
23
|
+
|
24
|
+
def self.debugging?
|
25
|
+
@@debugging
|
26
|
+
end
|
27
|
+
def self.debugging=(boolean)
|
28
|
+
@@debugging = boolean
|
29
|
+
end
|
30
|
+
def self.debug!
|
31
|
+
self.debugging = true
|
32
|
+
end
|
33
|
+
def self.debug(&block)
|
34
|
+
original = self.debugging?
|
35
|
+
self.debugging = true
|
36
|
+
yield
|
37
|
+
ensure
|
38
|
+
self.debugging = original
|
39
|
+
end
|
40
|
+
self.debugging = false
|
6
41
|
end
|
7
42
|
end
|
8
43
|
|
9
|
-
require 'rack'
|
10
|
-
require 'json'
|
11
|
-
require 'httpclient'
|
12
|
-
require 'active_support/core_ext'
|
13
|
-
require 'attr_required'
|
14
|
-
require 'attr_optional'
|
15
44
|
require 'rack/oauth2/util'
|
16
45
|
require 'rack/oauth2/server'
|
17
46
|
require 'rack/oauth2/client'
|
18
|
-
require 'rack/oauth2/access_token'
|
47
|
+
require 'rack/oauth2/access_token'
|
48
|
+
require 'rack/oauth2/debugger'
|
data/lib/rack/oauth2/client.rb
CHANGED
@@ -51,14 +51,20 @@ module Rack
|
|
51
51
|
:client_secret => self.secret
|
52
52
|
)
|
53
53
|
handle_response do
|
54
|
-
|
55
|
-
:agent_name => "#{self.class} (#{VERSION})"
|
56
|
-
).post absolute_uri_for(token_endpoint), Util.compact_hash(params)
|
54
|
+
http_client.post absolute_uri_for(token_endpoint), Util.compact_hash(params)
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
60
58
|
private
|
61
59
|
|
60
|
+
def http_client
|
61
|
+
_http_client_ = HTTPClient.new(
|
62
|
+
:agent_name => "#{self.class} (#{VERSION})"
|
63
|
+
)
|
64
|
+
_http_client_.request_filter << Debugger::RequestFilter.new if Rack::OAuth2.debugging?
|
65
|
+
_http_client_
|
66
|
+
end
|
67
|
+
|
62
68
|
def absolute_uri_for(endpoint)
|
63
69
|
_endpoint_ = Util.parse_uri endpoint
|
64
70
|
_endpoint_.scheme ||= self.scheme || 'https'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'rack/oauth2/debugger/request_filter'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Rack
|
2
|
+
module OAuth2
|
3
|
+
module Debugger
|
4
|
+
class RequestFilter
|
5
|
+
# Callback called in HTTPClient (before sending a request)
|
6
|
+
# request:: HTTP::Message
|
7
|
+
def filter_request(request)
|
8
|
+
started = "======= [Rack::OAuth2] HTTP REQUEST STARTED ======="
|
9
|
+
FbGraph.logger.info [started, request.dump].join("\n")
|
10
|
+
end
|
11
|
+
|
12
|
+
# Callback called in HTTPClient (after received a response)
|
13
|
+
# request:: HTTP::Message
|
14
|
+
# response:: HTTP::Message
|
15
|
+
def filter_response(request, response)
|
16
|
+
finished = "======= [Rack::OAuth2] HTTP REQUEST FINISHED ======="
|
17
|
+
FbGraph.logger.info ['-' * 50, response.dump, finished].join("\n")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -13,10 +13,6 @@ module WebMockHelper
|
|
13
13
|
|
14
14
|
def request_for(method, options = {})
|
15
15
|
request = {}
|
16
|
-
if options[:access_token]
|
17
|
-
options[:params] ||= {}
|
18
|
-
options[:params][:oauth_token] = options[:access_token].to_s
|
19
|
-
end
|
20
16
|
if options[:params]
|
21
17
|
case method
|
22
18
|
when :post, :put
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 61
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
- 3
|
10
|
+
version: 0.9.3
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- nov matake
|
@@ -10,7 +15,7 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-
|
18
|
+
date: 2011-09-10 00:00:00 Z
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rack
|
@@ -20,6 +25,10 @@ dependencies:
|
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
hash: 13
|
29
|
+
segments:
|
30
|
+
- 1
|
31
|
+
- 1
|
23
32
|
version: "1.1"
|
24
33
|
type: :runtime
|
25
34
|
version_requirements: *id001
|
@@ -31,6 +40,11 @@ dependencies:
|
|
31
40
|
requirements:
|
32
41
|
- - ">="
|
33
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 1
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 4
|
47
|
+
- 3
|
34
48
|
version: 1.4.3
|
35
49
|
type: :runtime
|
36
50
|
version_requirements: *id002
|
@@ -42,6 +56,12 @@ dependencies:
|
|
42
56
|
requirements:
|
43
57
|
- - ">="
|
44
58
|
- !ruby/object:Gem::Version
|
59
|
+
hash: 123
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 2
|
63
|
+
- 0
|
64
|
+
- 2
|
45
65
|
version: 2.2.0.2
|
46
66
|
type: :runtime
|
47
67
|
version_requirements: *id003
|
@@ -53,6 +73,10 @@ dependencies:
|
|
53
73
|
requirements:
|
54
74
|
- - ">="
|
55
75
|
- !ruby/object:Gem::Version
|
76
|
+
hash: 5
|
77
|
+
segments:
|
78
|
+
- 2
|
79
|
+
- 3
|
56
80
|
version: "2.3"
|
57
81
|
type: :runtime
|
58
82
|
version_requirements: *id004
|
@@ -64,6 +88,9 @@ dependencies:
|
|
64
88
|
requirements:
|
65
89
|
- - ">="
|
66
90
|
- !ruby/object:Gem::Version
|
91
|
+
hash: 3
|
92
|
+
segments:
|
93
|
+
- 0
|
67
94
|
version: "0"
|
68
95
|
type: :runtime
|
69
96
|
version_requirements: *id005
|
@@ -75,6 +102,11 @@ dependencies:
|
|
75
102
|
requirements:
|
76
103
|
- - ">="
|
77
104
|
- !ruby/object:Gem::Version
|
105
|
+
hash: 25
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
- 0
|
109
|
+
- 3
|
78
110
|
version: 0.0.3
|
79
111
|
type: :runtime
|
80
112
|
version_requirements: *id006
|
@@ -86,6 +118,10 @@ dependencies:
|
|
86
118
|
requirements:
|
87
119
|
- - ">="
|
88
120
|
- !ruby/object:Gem::Version
|
121
|
+
hash: 27
|
122
|
+
segments:
|
123
|
+
- 0
|
124
|
+
- 8
|
89
125
|
version: "0.8"
|
90
126
|
type: :development
|
91
127
|
version_requirements: *id007
|
@@ -97,6 +133,10 @@ dependencies:
|
|
97
133
|
requirements:
|
98
134
|
- - ">="
|
99
135
|
- !ruby/object:Gem::Version
|
136
|
+
hash: 25
|
137
|
+
segments:
|
138
|
+
- 0
|
139
|
+
- 9
|
100
140
|
version: "0.9"
|
101
141
|
type: :development
|
102
142
|
version_requirements: *id008
|
@@ -108,6 +148,9 @@ dependencies:
|
|
108
148
|
requirements:
|
109
149
|
- - ">="
|
110
150
|
- !ruby/object:Gem::Version
|
151
|
+
hash: 7
|
152
|
+
segments:
|
153
|
+
- 2
|
111
154
|
version: "2"
|
112
155
|
type: :development
|
113
156
|
version_requirements: *id009
|
@@ -119,6 +162,11 @@ dependencies:
|
|
119
162
|
requirements:
|
120
163
|
- - ">="
|
121
164
|
- !ruby/object:Gem::Version
|
165
|
+
hash: 11
|
166
|
+
segments:
|
167
|
+
- 1
|
168
|
+
- 6
|
169
|
+
- 2
|
122
170
|
version: 1.6.2
|
123
171
|
type: :development
|
124
172
|
version_requirements: *id010
|
@@ -135,6 +183,7 @@ files:
|
|
135
183
|
- .document
|
136
184
|
- .gitignore
|
137
185
|
- .rspec
|
186
|
+
- .travis.yml
|
138
187
|
- Gemfile
|
139
188
|
- Gemfile.lock
|
140
189
|
- LICENSE
|
@@ -157,6 +206,8 @@ files:
|
|
157
206
|
- lib/rack/oauth2/client/grant/client_credentials.rb
|
158
207
|
- lib/rack/oauth2/client/grant/password.rb
|
159
208
|
- lib/rack/oauth2/client/grant/refresh_token.rb
|
209
|
+
- lib/rack/oauth2/debugger.rb
|
210
|
+
- lib/rack/oauth2/debugger/request_filter.rb
|
160
211
|
- lib/rack/oauth2/server.rb
|
161
212
|
- lib/rack/oauth2/server/abstract.rb
|
162
213
|
- lib/rack/oauth2/server/abstract/error.rb
|
@@ -241,12 +292,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
241
292
|
requirements:
|
242
293
|
- - ">="
|
243
294
|
- !ruby/object:Gem::Version
|
295
|
+
hash: 3
|
296
|
+
segments:
|
297
|
+
- 0
|
244
298
|
version: "0"
|
245
299
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
246
300
|
none: false
|
247
301
|
requirements:
|
248
302
|
- - ">="
|
249
303
|
- !ruby/object:Gem::Version
|
304
|
+
hash: 23
|
305
|
+
segments:
|
306
|
+
- 1
|
307
|
+
- 3
|
308
|
+
- 6
|
250
309
|
version: 1.3.6
|
251
310
|
requirements: []
|
252
311
|
|