exvo-auth 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{exvo-auth}
8
- s.version = "0.7.1"
8
+ s.version = "0.7.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jacek Becela"]
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  "VERSION",
25
25
  "exvo-auth.gemspec",
26
26
  "lib/exvo-auth.rb",
27
+ "lib/exvo_auth/autonomous/auth.rb",
27
28
  "lib/exvo_auth/autonomous/base.rb",
28
29
  "lib/exvo_auth/autonomous/cache.rb",
29
30
  "lib/exvo_auth/autonomous/consumer.rb",
@@ -23,6 +23,7 @@ module ExvoAuth
23
23
  autoload :Consumer, 'exvo_auth/autonomous/consumer'
24
24
  autoload :Provider, 'exvo_auth/autonomous/provider'
25
25
  autoload :Cache, 'exvo_auth/autonomous/cache'
26
+ autoload :Auth, 'exvo_auth/autonomous/auth'
26
27
  end
27
28
 
28
29
  module OAuth2
@@ -0,0 +1,6 @@
1
+ class ExvoAuth::Autonomous::Auth
2
+ include HTTParty
3
+
4
+ base_uri(ExvoAuth::Config.host)
5
+ basic_auth(ExvoAuth::Config.client_id, ExvoAuth::Config.client_secret)
6
+ end
@@ -19,7 +19,7 @@ class ExvoAuth::Autonomous::Base
19
19
  end
20
20
 
21
21
  # Makes testing easy
22
- def httparty
23
- HTTParty
22
+ def auth
23
+ ExvoAuth::Autonomous::Auth
24
24
  end
25
25
  end
@@ -50,13 +50,7 @@ class ExvoAuth::Autonomous::Consumer < ExvoAuth::Autonomous::Base
50
50
  end
51
51
 
52
52
  def authorization!
53
- response = httparty.get("/apps/consumer/authorizations/#{URI.escape(params[:provider_id])}.json",
54
- :base_uri => params[:site],
55
- :basic_auth => {
56
- :username => params[:client_id],
57
- :password => params[:client_secret]
58
- }
59
- )
53
+ response = auth.get("/apps/consumer/authorizations/#{URI.escape(params[:provider_id])}.json")
60
54
 
61
55
  @@cache.write(params, response["authorization"])
62
56
  end
@@ -11,12 +11,7 @@ class ExvoAuth::Autonomous::Provider < ExvoAuth::Autonomous::Base
11
11
  end
12
12
 
13
13
  def scopes!
14
- response = httparty.get("/apps/provider/authorizations/#{URI.escape(params[:consumer_id])}.json",
15
- :base_uri => params[:site],
16
- :basic_auth => {
17
- :username => params[:client_id],
18
- :password => params[:client_secret]
19
- },
14
+ response = auth.get("/apps/provider/authorizations/#{URI.escape(params[:consumer_id])}.json",
20
15
  :query => { :access_token => params[:access_token] }
21
16
  )
22
17
 
@@ -19,7 +19,7 @@ module ExvoAuth::Controllers::Merb
19
19
 
20
20
  @current_consumer_id = consumer_id
21
21
 
22
- current_scopes.include?(scope)
22
+ current_scopes.include?(scope) && request.ssl?
23
23
  end
24
24
  end
25
25
 
@@ -15,7 +15,7 @@ module ExvoAuth::Controllers::Rails
15
15
 
16
16
  @current_consumer_id = consumer_id
17
17
 
18
- current_scopes.include?(scope)
18
+ current_scopes.include?(scope) && request.ssl?
19
19
  end
20
20
  end
21
21
 
@@ -9,8 +9,8 @@ class TestExvoAuth < Test::Unit::TestCase
9
9
  test "consumer sanity" do
10
10
  c = ExvoAuth::Autonomous::Consumer.new(:provider_id => "baz")
11
11
  authorization = { "access_token" => "qux", "url" => "https://foo/api" }
12
- httparty = stub(:get => { "authorization" => authorization })
13
- c.expects(:httparty).returns(httparty)
12
+ auth = stub(:get => { "authorization" => authorization })
13
+ c.expects(:auth).returns(auth)
14
14
 
15
15
  assert_equal authorization, c.send(:authorization)
16
16
  assert_equal authorization, c.send(:authorization) # second time from cache, without touching httparty
@@ -18,8 +18,8 @@ class TestExvoAuth < Test::Unit::TestCase
18
18
 
19
19
  test "provider sanity" do
20
20
  p = ExvoAuth::Autonomous::Provider.new(:consumer_id => "baz", :access_token => "qux")
21
- httparty = stub(:get => {"scope" => "qux quux"})
22
- p.expects(:httparty).returns(httparty)
21
+ auth = stub(:get => {"scope" => "qux quux"})
22
+ p.expects(:auth).returns(auth)
23
23
 
24
24
  assert_equal ["qux", "quux"], p.scopes
25
25
  assert_equal ["qux", "quux"], p.scopes # second time from cache, without touching httparty
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 1
9
- version: 0.7.1
8
+ - 2
9
+ version: 0.7.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jacek Becela
@@ -90,6 +90,7 @@ files:
90
90
  - VERSION
91
91
  - exvo-auth.gemspec
92
92
  - lib/exvo-auth.rb
93
+ - lib/exvo_auth/autonomous/auth.rb
93
94
  - lib/exvo_auth/autonomous/base.rb
94
95
  - lib/exvo_auth/autonomous/cache.rb
95
96
  - lib/exvo_auth/autonomous/consumer.rb