rack-oauth2 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.rdoc +1 -2
- data/VERSION +1 -1
- data/lib/rack/oauth2.rb +2 -1
- data/lib/rack/oauth2/util.rb +1 -1
- data/rack-oauth2.gemspec +4 -3
- data/spec/helpers/webmock_helper.rb +6 -7
- data/spec/rack/oauth2/access_token/authenticator_spec.rb +1 -1
- data/spec/rack/oauth2/access_token/bearer_spec.rb +1 -1
- data/spec/rack/oauth2/access_token/legacy_spec.rb +1 -1
- data/spec/rack/oauth2/access_token/mac_spec.rb +4 -4
- data/spec/rack/oauth2/access_token_spec.rb +1 -1
- data/spec/rack/oauth2/debugger/request_filter_spec.rb +2 -2
- data/spec/rack/oauth2/oauth2_spec.rb +7 -7
- data/spec/rack/oauth2/util_spec.rb +7 -7
- data/spec/spec_helper.rb +8 -0
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85fbc5f6cc2f9216589bebdf3f9e56e0a3b2af4a
|
4
|
+
data.tar.gz: 9c9774de8ba9e8b4bd4ff346dec70626105ebea1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 989642e1ae224eee2deab2738024d2214fe2b3478f13367be33371af8141297ce363d8ae8845acf4117a1da13ca320c6932d3bc74f77964ca7facc825fcf4c07
|
7
|
+
data.tar.gz: 58c119cabf5525303d7166a34833196c63814a4082bfb13a5744eafc4fb2faee66de32b628e357d9e6881b5b553acf4b80f8487b203ccff23771be54907aa589
|
data/README.rdoc
CHANGED
@@ -21,9 +21,8 @@ http://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01
|
|
21
21
|
== Resources
|
22
22
|
|
23
23
|
* View Source on GitHub (https://github.com/nov/rack-oauth2)
|
24
|
+
* Docs on GitHub (https://github.com/nov/rack-oauth2/wiki)
|
24
25
|
* Report Issues on GitHub (https://github.com/nov/rack-oauth2/issues)
|
25
|
-
* Subscribe Update Info (https://www.facebook.com/rackoauth2)
|
26
|
-
* Q&A on Google Groups (https://groups.google.com/group/rack-oauth2)
|
27
26
|
|
28
27
|
== Sample Server Application (Rails3)
|
29
28
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.9
|
data/lib/rack/oauth2.rb
CHANGED
data/lib/rack/oauth2/util.rb
CHANGED
data/rack-oauth2.gemspec
CHANGED
@@ -16,11 +16,12 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.add_runtime_dependency "rack", ">= 1.1"
|
18
18
|
s.add_runtime_dependency "multi_json", ">= 1.3.6"
|
19
|
-
s.add_runtime_dependency "httpclient", ">= 2.
|
19
|
+
s.add_runtime_dependency "httpclient", ">= 2.4"
|
20
20
|
s.add_runtime_dependency "activesupport", ">= 2.3"
|
21
21
|
s.add_runtime_dependency "attr_required", ">= 0.0.5"
|
22
22
|
s.add_development_dependency "rake", ">= 0.8"
|
23
23
|
s.add_development_dependency "simplecov"
|
24
|
-
s.add_development_dependency "rspec"
|
25
|
-
s.add_development_dependency "
|
24
|
+
s.add_development_dependency "rspec"
|
25
|
+
s.add_development_dependency "rspec-its"
|
26
|
+
s.add_development_dependency "webmock"
|
26
27
|
end
|
@@ -13,13 +13,12 @@ module WebMockHelper
|
|
13
13
|
|
14
14
|
def request_for(method, options = {})
|
15
15
|
request = {}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
16
|
+
params = options.try(:[], :params) || {}
|
17
|
+
case method
|
18
|
+
when :post, :put, :delete
|
19
|
+
request[:body] = params
|
20
|
+
else
|
21
|
+
request[:query] = params
|
23
22
|
end
|
24
23
|
if options[:request_header]
|
25
24
|
request[:headers] = options[:request_header]
|
@@ -7,7 +7,7 @@ describe Rack::OAuth2::AccessToken::Authenticator do
|
|
7
7
|
|
8
8
|
shared_examples_for :authenticator do
|
9
9
|
it 'should let the token authenticate the request' do
|
10
|
-
token.
|
10
|
+
expect(token).to receive(:authenticate).with(request)
|
11
11
|
authenticator.filter_request(request)
|
12
12
|
end
|
13
13
|
end
|
@@ -11,7 +11,7 @@ describe Rack::OAuth2::AccessToken::Bearer do
|
|
11
11
|
|
12
12
|
describe '.authenticate' do
|
13
13
|
it 'should set Authorization header' do
|
14
|
-
request.header.
|
14
|
+
expect(request.header).to receive(:[]=).with('Authorization', 'Bearer access_token')
|
15
15
|
token.authenticate(request)
|
16
16
|
end
|
17
17
|
end
|
@@ -16,7 +16,7 @@ describe Rack::OAuth2::AccessToken::Legacy do
|
|
16
16
|
|
17
17
|
describe '.authenticate' do
|
18
18
|
it 'should set Authorization header' do
|
19
|
-
request.header.
|
19
|
+
expect(request.header).to receive(:[]=).with('Authorization', 'OAuth access_token')
|
20
20
|
token.authenticate(request)
|
21
21
|
end
|
22
22
|
end
|
@@ -121,8 +121,8 @@ describe Rack::OAuth2::AccessToken::MAC do
|
|
121
121
|
let(:signature) { 'pOBaL6HRawe4tUPmcU4vJEj1f2GJqrbQOlCcdAYgI/s=' }
|
122
122
|
|
123
123
|
it 'should set Authorization header' do
|
124
|
-
token.
|
125
|
-
request.header.
|
124
|
+
expect(token).to receive(:generate_nonce).and_return(nonce)
|
125
|
+
expect(request.header).to receive(:[]=).with('Authorization', "MAC id=\"access_token\", nonce=\"#{nonce}\", ts=\"#{ts.to_i}\", mac=\"#{signature}\"")
|
126
126
|
token.authenticate(request)
|
127
127
|
end
|
128
128
|
end
|
@@ -131,8 +131,8 @@ describe Rack::OAuth2::AccessToken::MAC do
|
|
131
131
|
let(:signature) { 'vgU0fj6rSpwUCAoCOrXlu8pZBR8a5Q5xIVlB4MCvJeM=' }
|
132
132
|
let(:ext) { '3d011e09502a84552a0f8ae112d024cc2c115597e3a577d5f49007902c221dc5' }
|
133
133
|
it 'should set Authorization header with ext_verifier' do
|
134
|
-
token_with_ext_verifier.
|
135
|
-
request.header.
|
134
|
+
expect(token_with_ext_verifier).to receive(:generate_nonce).and_return(nonce)
|
135
|
+
expect(request.header).to receive(:[]=).with('Authorization', "MAC id=\"access_token\", nonce=\"#{nonce}\", ts=\"#{ts.to_i}\", mac=\"#{signature}\", ext=\"#{ext}\"")
|
136
136
|
token_with_ext_verifier.authenticate(request)
|
137
137
|
end
|
138
138
|
end
|
@@ -51,7 +51,7 @@ describe Rack::OAuth2::AccessToken do
|
|
51
51
|
[:get, :delete, :post, :put].each do |method|
|
52
52
|
describe method do
|
53
53
|
it 'should delegate to HTTPClient with Authenticator filter' do
|
54
|
-
token.httpclient.
|
54
|
+
expect(token.httpclient).to receive(method).with(resource_endpoint)
|
55
55
|
token.httpclient.request_filter.last.should be_a Rack::OAuth2::AccessToken::Authenticator
|
56
56
|
token.send method, resource_endpoint
|
57
57
|
end
|
@@ -12,7 +12,7 @@ describe Rack::OAuth2::Debugger::RequestFilter do
|
|
12
12
|
"======= [Rack::OAuth2] HTTP REQUEST STARTED =======",
|
13
13
|
request.dump
|
14
14
|
].each do |output|
|
15
|
-
Rack::OAuth2.logger.
|
15
|
+
expect(Rack::OAuth2.logger).to receive(:info).with output
|
16
16
|
end
|
17
17
|
request_filter.filter_request(request)
|
18
18
|
end
|
@@ -25,7 +25,7 @@ describe Rack::OAuth2::Debugger::RequestFilter do
|
|
25
25
|
response.dump,
|
26
26
|
"======= [Rack::OAuth2] HTTP REQUEST FINISHED ======="
|
27
27
|
].each do |output|
|
28
|
-
Rack::OAuth2.logger.
|
28
|
+
expect(Rack::OAuth2.logger).to receive(:info).with output
|
29
29
|
end
|
30
30
|
request_filter.filter_response(request, response)
|
31
31
|
end
|
@@ -5,27 +5,27 @@ describe Rack::OAuth2 do
|
|
5
5
|
after { Rack::OAuth2.debugging = false }
|
6
6
|
|
7
7
|
its(:logger) { should be_a Logger }
|
8
|
-
its(:debugging?) { should
|
8
|
+
its(:debugging?) { should == false }
|
9
9
|
|
10
10
|
describe '.debug!' do
|
11
11
|
before { Rack::OAuth2.debug! }
|
12
|
-
its(:debugging?) { should
|
12
|
+
its(:debugging?) { should == true }
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '.debug' do
|
16
16
|
it 'should enable debugging within given block' do
|
17
17
|
Rack::OAuth2.debug do
|
18
|
-
Rack::OAuth2.debugging?.should
|
18
|
+
Rack::OAuth2.debugging?.should == true
|
19
19
|
end
|
20
|
-
Rack::OAuth2.debugging?.should
|
20
|
+
Rack::OAuth2.debugging?.should == false
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'should not force disable debugging' do
|
24
24
|
Rack::OAuth2.debug!
|
25
25
|
Rack::OAuth2.debug do
|
26
|
-
Rack::OAuth2.debugging?.should
|
26
|
+
Rack::OAuth2.debugging?.should == true
|
27
27
|
end
|
28
|
-
Rack::OAuth2.debugging?.should
|
28
|
+
Rack::OAuth2.debugging?.should == true
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -33,7 +33,7 @@ describe Rack::OAuth2 do
|
|
33
33
|
context 'when request_filter added' do
|
34
34
|
context 'when "debug!" is called' do
|
35
35
|
after { Rack::OAuth2.reset_http_config! }
|
36
|
-
|
36
|
+
|
37
37
|
it 'should put Debugger::RequestFilter at last' do
|
38
38
|
Rack::OAuth2.debug!
|
39
39
|
Rack::OAuth2.http_config do |config|
|
@@ -73,24 +73,24 @@ describe Rack::OAuth2::Util do
|
|
73
73
|
describe '.uri_match?' do
|
74
74
|
context 'when invalid URI is given' do
|
75
75
|
it do
|
76
|
-
util.uri_match?('::', '::').should
|
77
|
-
util.uri_match?(123, 'http://client.example.com/other').should
|
78
|
-
util.uri_match?('http://client.example.com/other', nil).should
|
76
|
+
util.uri_match?('::', '::').should == false
|
77
|
+
util.uri_match?(123, 'http://client.example.com/other').should == false
|
78
|
+
util.uri_match?('http://client.example.com/other', nil).should == false
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
context 'when exactry same' do
|
83
|
-
it { util.uri_match?(uri, uri).should
|
83
|
+
it { util.uri_match?(uri, uri).should == true }
|
84
84
|
end
|
85
85
|
|
86
86
|
context 'when path prefix matches' do
|
87
|
-
it { util.uri_match?(uri, "#{uri}/deep_path").should
|
87
|
+
it { util.uri_match?(uri, "#{uri}/deep_path").should == true }
|
88
88
|
end
|
89
89
|
|
90
90
|
context 'otherwise' do
|
91
91
|
it do
|
92
|
-
util.uri_match?(uri, 'http://client.example.com/other').should
|
93
|
-
util.uri_match?(uri, 'http://attacker.example.com/callback').should
|
92
|
+
util.uri_match?(uri, 'http://client.example.com/other').should == false
|
93
|
+
util.uri_match?(uri, 'http://attacker.example.com/callback').should == false
|
94
94
|
end
|
95
95
|
end
|
96
96
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,7 +5,15 @@ SimpleCov.start do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
require 'rspec'
|
8
|
+
require 'rspec/its'
|
8
9
|
require 'rack/oauth2'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.expect_with :rspec do |c|
|
13
|
+
c.syntax = [:should, :expect]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
require 'helpers/time'
|
10
18
|
require 'helpers/webmock_helper'
|
11
19
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-oauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nov matake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: '2.4'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: '2.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activesupport
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,28 +114,42 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec-its
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: webmock
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - ">="
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
145
|
+
version: '0'
|
132
146
|
type: :development
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - ">="
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
152
|
+
version: '0'
|
139
153
|
description: OAuth 2.0 Server & Client Library. Both Bearer and MAC token type are
|
140
154
|
supported.
|
141
155
|
email: nov@matake.jp
|