exvo-auth 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ class ExvoAuth::Autonomous::Consumer < ExvoAuth::Autonomous::Base
|
|
3
3
|
|
4
4
|
def initialize(params = {})
|
5
5
|
super
|
6
|
-
validate_params!(:
|
6
|
+
validate_params!(:app_id)
|
7
7
|
end
|
8
8
|
|
9
9
|
def base_uri
|
@@ -25,12 +25,12 @@ class ExvoAuth::Autonomous::Consumer < ExvoAuth::Autonomous::Base
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def authorization!
|
28
|
-
response = auth.get("/apps/consumer/authorizations/#{URI.escape(params[:
|
28
|
+
response = auth.get("/apps/consumer/authorizations/#{URI.escape(params[:app_id])}.json")
|
29
29
|
|
30
30
|
if response["authorization"]
|
31
31
|
@@cache.write(params, response["authorization"])
|
32
32
|
else
|
33
|
-
raise "Authorization not found. You need an auhorization to contact provider app (#{ params[:
|
33
|
+
raise "Authorization not found. You need an auhorization to contact provider app (#{ params[:app_id] })"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class ExvoAuth::Autonomous::Provider < ExvoAuth::Autonomous::Base
|
2
2
|
def initialize(params = {})
|
3
3
|
super
|
4
|
-
validate_params!(:
|
4
|
+
validate_params!(:app_id, :access_token)
|
5
5
|
end
|
6
6
|
|
7
7
|
def scopes
|
@@ -11,7 +11,7 @@ class ExvoAuth::Autonomous::Provider < ExvoAuth::Autonomous::Base
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def scopes!
|
14
|
-
response = auth.get("/apps/provider/authorizations/#{URI.escape(params[:
|
14
|
+
response = auth.get("/apps/provider/authorizations/#{URI.escape(params[:app_id])}.json",
|
15
15
|
:query => { :access_token => params[:access_token] }
|
16
16
|
)
|
17
17
|
|
@@ -37,15 +37,15 @@ module ExvoAuth::Controllers::Base
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def authenticate_app_in_scope!(scope)
|
40
|
-
raise("SSL not configured. Your api needs to be exposed
|
40
|
+
raise("SSL not configured. Your api needs to be exposed using https protocol.") unless request.ssl? || ExvoAuth::Config.require_ssl == false
|
41
41
|
|
42
|
-
send(basic_authentication_method_name) do |
|
42
|
+
send(basic_authentication_method_name) do |app_id, access_token|
|
43
43
|
current_scopes = ExvoAuth::Autonomous::Provider.new(
|
44
|
-
:
|
44
|
+
:app_id => app_id,
|
45
45
|
:access_token => access_token
|
46
46
|
).scopes
|
47
47
|
|
48
|
-
@
|
48
|
+
@current_app_id = app_id
|
49
49
|
|
50
50
|
current_scopes.include?(scope.to_s)
|
51
51
|
end
|
@@ -64,8 +64,8 @@ module ExvoAuth::Controllers::Base
|
|
64
64
|
@current_user = session[:user_id] && find_user_by_id(session[:user_id])
|
65
65
|
end
|
66
66
|
|
67
|
-
def
|
68
|
-
@
|
67
|
+
def current_app_id
|
68
|
+
@current_app_id
|
69
69
|
end
|
70
70
|
|
71
71
|
def signed_in?
|
@@ -111,5 +111,4 @@ module ExvoAuth::Controllers::Base
|
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
114
|
-
|
115
114
|
end
|
data/lib/exvo_auth/version.rb
CHANGED
data/test/test_exvo_auth.rb
CHANGED
@@ -7,7 +7,7 @@ class TestExvoAuth < Test::Unit::TestCase
|
|
7
7
|
end
|
8
8
|
|
9
9
|
test "consumer sanity" do
|
10
|
-
c = ExvoAuth::Autonomous::Consumer.new(:
|
10
|
+
c = ExvoAuth::Autonomous::Consumer.new(:app_id => "baz")
|
11
11
|
authorization = { "access_token" => "qux", "url" => "https://foo/api" }
|
12
12
|
auth = stub(:get => { "authorization" => authorization })
|
13
13
|
c.expects(:auth).returns(auth)
|
@@ -17,7 +17,7 @@ class TestExvoAuth < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
test "provider sanity" do
|
20
|
-
p = ExvoAuth::Autonomous::Provider.new(:
|
20
|
+
p = ExvoAuth::Autonomous::Provider.new(:app_id => "baz", :access_token => "qux")
|
21
21
|
auth = stub(:get => {"scope" => "qux quux"})
|
22
22
|
p.expects(:auth).returns(auth)
|
23
23
|
|
@@ -26,7 +26,7 @@ class TestExvoAuth < Test::Unit::TestCase
|
|
26
26
|
end
|
27
27
|
|
28
28
|
test "integration of httparty interface with auth" do
|
29
|
-
c = ExvoAuth::Autonomous::Consumer.new(:
|
29
|
+
c = ExvoAuth::Autonomous::Consumer.new(:app_id => "baz")
|
30
30
|
basement = mock("basement")
|
31
31
|
basement.expects(:base_uri)
|
32
32
|
basement.expects(:basic_auth)
|
@@ -36,7 +36,7 @@ class TestExvoAuth < Test::Unit::TestCase
|
|
36
36
|
end
|
37
37
|
|
38
38
|
test "basement includes httparty" do
|
39
|
-
c = ExvoAuth::Autonomous::Consumer.new(:
|
39
|
+
c = ExvoAuth::Autonomous::Consumer.new(:app_id => "baz")
|
40
40
|
assert_true c.send(:basement).included_modules.include?(HTTParty)
|
41
41
|
end
|
42
42
|
end
|
data/test/test_integration.rb
CHANGED
@@ -9,7 +9,7 @@ class TestIntegration < Test::Unit::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
test "integration with staging.auth.exvo.com" do
|
12
|
-
c = ExvoAuth::Autonomous::Consumer.new(:
|
12
|
+
c = ExvoAuth::Autonomous::Consumer.new(:app_id => "bar")
|
13
13
|
authorization = c.send(:authorization)
|
14
14
|
assert_true authorization["access_token"].size > 0
|
15
15
|
assert_equal "https://bar/api", authorization["url"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exvo-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 41
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 9
|
10
|
+
version: 0.9.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jacek Becela
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-10-
|
18
|
+
date: 2010-10-28 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|