warden-oauth2-strategies 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0df4f6d65b46e8d81c518dd75a1fe96556fdd753
|
4
|
+
data.tar.gz: 0e2d53987f68527aaaa9a4eb7a85fd68b2570d29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8f08fc873bf11a9c781f5d714c31d02e132fdaf06345e59a9752b9e0971adff7256ff2567837ede5aa564d8f8db3044c29107a49644a4b045d94c51d6b0170b
|
7
|
+
data.tar.gz: 4e14388e4bbfe21b1938a8f7172e37736f983e08190b4217ce1d7455324a1a8b92da1b51606ec638b331b301bddbed1e296b419f68cf117b03097361b71314b1
|
@@ -10,11 +10,11 @@ module Warden
|
|
10
10
|
|
11
11
|
def authenticate!
|
12
12
|
if token
|
13
|
-
fail!
|
14
|
-
fail!
|
13
|
+
fail! 'invalid_token' and return if token.respond_to?(:expired?) && token.expired?
|
14
|
+
fail! 'invalid_scope' and return if scope && token.respond_to?(:scope?) && !token.scope?(scope)
|
15
15
|
success! token
|
16
16
|
else
|
17
|
-
fail!
|
17
|
+
fail! 'invalid_token' and return unless token
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -28,9 +28,8 @@ module Warden
|
|
28
28
|
|
29
29
|
def error_status
|
30
30
|
case message
|
31
|
-
when
|
32
|
-
when
|
33
|
-
when "invalid_request" then 400
|
31
|
+
when 'invalid_token' then 401
|
32
|
+
when 'invalid_scope' then 403
|
34
33
|
else 400
|
35
34
|
end
|
36
35
|
end
|
@@ -18,38 +18,42 @@ describe Warden::OAuth2::Strategies::Token do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
describe '#authenticate!' do
|
21
|
+
before do
|
22
|
+
subject.stub(token_string: nil)
|
23
|
+
end
|
21
24
|
it 'should be successful if there is a token' do
|
22
25
|
token_instance = double
|
23
|
-
subject.stub(:
|
26
|
+
subject.stub(token_string: 'token_string')
|
27
|
+
token_model.stub(:locate).with('token_string').and_return(token_instance)
|
24
28
|
subject._run!
|
25
29
|
subject.result.should == :success
|
26
30
|
subject.user.should == token_instance
|
27
31
|
end
|
28
32
|
|
29
|
-
it 'should fail if there is
|
30
|
-
|
33
|
+
it 'should fail if there is no token located' do
|
34
|
+
token_model.stub(locate: nil)
|
31
35
|
subject._run!
|
32
36
|
subject.result.should == :failure
|
33
|
-
subject.message.should ==
|
34
|
-
subject.error_status.should ==
|
37
|
+
subject.message.should == 'invalid_token'
|
38
|
+
subject.error_status.should == 401
|
35
39
|
end
|
36
40
|
|
37
41
|
it 'should fail if the access token is expired' do
|
38
42
|
token_instance = double(:respond_to? => true, :expired? => true, :scope? => true)
|
39
|
-
|
43
|
+
token_model.stub(locate: token_instance)
|
40
44
|
subject._run!
|
41
45
|
subject.result.should == :failure
|
42
|
-
subject.message.should ==
|
46
|
+
subject.message.should == 'invalid_token'
|
43
47
|
subject.error_status.should == 401
|
44
48
|
end
|
45
49
|
|
46
50
|
it 'should fail if there is insufficient scope' do
|
47
51
|
token_instance = double(:respond_to? => true, :expired? => false, :scope? => false)
|
48
|
-
|
52
|
+
token_model.stub(locate: token_instance)
|
49
53
|
subject.stub(:scope).and_return(:secret)
|
50
54
|
subject._run!
|
51
55
|
subject.result.should == :failure
|
52
|
-
subject.message.should ==
|
56
|
+
subject.message.should == 'invalid_scope'
|
53
57
|
subject.error_status.should == 403
|
54
58
|
end
|
55
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden-oauth2-strategies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AirService
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: warden
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.2.
|
130
|
+
rubygems_version: 2.2.1
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: OAuth 2.0 strategies for Warden
|