doorkeeper 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of doorkeeper might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f77e11de4933a587d6936a1185a31d722fd21a7
4
- data.tar.gz: d7aa73af1c190fab721a82e364d3c02035ed1974
3
+ metadata.gz: a284126c1f1a3788dd355b21caebb53aec39b113
4
+ data.tar.gz: de3aa39b50748e9e476247249ac8e8ab9061906f
5
5
  SHA512:
6
- metadata.gz: 1e21a060785183070bc2fc685b18cadedd220a069aeab87028caaf0d584f894fb47d69dc554e4169205d869de80c4e385a861bf5755565f45986ec4cf6124720
7
- data.tar.gz: 0374fabbd9af363de49f374bc1aecb51579d4e13ddc74fc538c5856ee16dc7b9378bd9cf4c99b8cbbefab49086920382d87cba21f9232691ee2bb79a27028891
6
+ metadata.gz: 3e3a84a470d287473a53a65b145fa5aa19a5c14478991766717d175af9251cd097f3b391627a1eb52bf44ec33642570358e46b31e123078db6718ecdb2ddb999
7
+ data.tar.gz: 66aa9dcc5d678484ff32496a3cd5e897cf4b73a3e649ae57dba9e98a1dd17fbe48be609caf8502a7462fdaa9433839b8146a477b6622f0641968383ebcfdc775
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.3
4
+
5
+ - enhancements
6
+ - [#204] Allow to overwrite scope in routes
7
+ - internals
8
+ - Returns only present keys in Token Response (may imply a backwards
9
+ incompatible change). https://github.com/applicake/doorkeeper/issues/220
10
+ - bug
11
+ - [#290] Support for Rails 4 when 'protected_attributes' gem is present.
12
+
13
+
3
14
  ## 0.7.2
4
15
 
5
16
  - enhancements
data/README.md CHANGED
@@ -25,7 +25,7 @@ The gem is under constant development. It is based in the [version 22 of the OAu
25
25
  Put this in your Gemfile:
26
26
 
27
27
  ``` ruby
28
- gem 'doorkeeper', '~> 0.7.2'
28
+ gem 'doorkeeper', '~> 0.7.0'
29
29
  ```
30
30
 
31
31
  Run the installation generator with:
@@ -8,7 +8,7 @@ module Doorkeeper
8
8
 
9
9
  belongs_to :application, :class_name => "Doorkeeper::Application", :inverse_of => :access_grants
10
10
 
11
- if ::Rails.version.to_i < 4
11
+ if ::Rails.version.to_i < 4 || defined?(ProtectedAttributes)
12
12
  attr_accessible :resource_owner_id, :application_id, :expires_in, :redirect_uri, :scopes
13
13
  end
14
14
 
@@ -13,7 +13,7 @@ module Doorkeeper
13
13
  validates :refresh_token, :uniqueness => true, :if => :use_refresh_token?
14
14
 
15
15
  attr_accessor :use_refresh_token
16
- if ::Rails.version.to_i < 4
16
+ if ::Rails.version.to_i < 4 || defined?(ProtectedAttributes)
17
17
  attr_accessible :application_id, :resource_owner_id, :expires_in, :scopes, :use_refresh_token
18
18
  end
19
19
 
@@ -11,7 +11,7 @@ module Doorkeeper
11
11
 
12
12
  before_validation :generate_uid, :generate_secret, :on => :create
13
13
 
14
- if ::Rails.version.to_i < 4
14
+ if ::Rails.version.to_i < 4 || defined?(ProtectedAttributes)
15
15
  attr_accessible :name, :redirect_uri
16
16
  end
17
17
 
@@ -14,7 +14,7 @@ module Doorkeeper
14
14
  'expires_in' => token.expires_in,
15
15
  'refresh_token' => token.refresh_token,
16
16
  'scope' => token.scopes_string
17
- }
17
+ }.reject { |_, value| value.blank? }
18
18
  end
19
19
 
20
20
  def status
@@ -28,13 +28,13 @@ module Doorkeeper
28
28
 
29
29
  attr_accessor :routes
30
30
 
31
- def initialize(routes, &options)
32
- @routes, @options = routes, options
31
+ def initialize(routes, &block)
32
+ @routes, @block = routes, block
33
33
  end
34
34
 
35
35
  def generate_routes!(options)
36
- @mapping = Mapper.new.map(&@options)
37
- routes.scope 'oauth', :as => 'oauth' do
36
+ @mapping = Mapper.new.map(&@block)
37
+ routes.scope options[:scope] || 'oauth', :as => 'oauth' do
38
38
  map_route(:authorizations, :authorization_routes)
39
39
  map_route(:tokens, :token_routes)
40
40
  map_route(:applications, :application_routes)
@@ -1,3 +1,3 @@
1
1
  module Doorkeeper
2
- VERSION = "0.7.2"
2
+ VERSION = '0.7.3'
3
3
  end
@@ -1,5 +1,19 @@
1
1
  Rails.application.routes.draw do
2
2
  use_doorkeeper
3
+ use_doorkeeper :scope => 'scope'
4
+
5
+ scope 'inner_space' do
6
+ use_doorkeeper :scope => 'scope' do
7
+ controllers :authorizations => 'custom_authorizations',
8
+ :tokens => 'custom_authorizations',
9
+ :applications => 'custom_authorizations',
10
+ :token_info => 'custom_authorizations'
11
+
12
+ as :authorizations => 'custom_auth',
13
+ :tokens => 'custom_token',
14
+ :token_info => 'custom_token_info'
15
+ end
16
+ end
3
17
 
4
18
  scope 'space' do
5
19
  use_doorkeeper do
@@ -48,5 +48,31 @@ module Doorkeeper::OAuth
48
48
  subject['refresh_token'].should == 'some-refresh-token'
49
49
  end
50
50
  end
51
+
52
+ describe '.body filters out empty values' do
53
+ let(:access_token) do
54
+ mock :access_token, {
55
+ :token => 'some-token',
56
+ :expires_in => '',
57
+ :scopes_string => '',
58
+ :refresh_token => '',
59
+ :token_type => 'bearer'
60
+ }
61
+ end
62
+
63
+ subject { TokenResponse.new(access_token).body }
64
+
65
+ it 'includes :expires_in' do
66
+ subject['expires_in'].should be_nil
67
+ end
68
+
69
+ it 'includes :scope' do
70
+ subject['scope'].should be_nil
71
+ end
72
+
73
+ it 'includes :refresh_token' do
74
+ subject['refresh_token'].should be_nil
75
+ end
76
+ end
51
77
  end
52
78
  end
@@ -25,7 +25,7 @@ feature 'Token endpoint' do
25
25
  config_is_set(:access_token_expires_in, nil)
26
26
  post token_endpoint_url(:code => @authorization.token, :client => @client)
27
27
  should_have_json 'access_token', Doorkeeper::AccessToken.first.token
28
- should_have_json 'expires_in', nil
28
+ should_not_have_json 'expires_in'
29
29
  end
30
30
 
31
31
  scenario 'returns unsupported_grant_type for invalid grant_type param' do
@@ -12,8 +12,8 @@ describe 'Client Credentials Request' do
12
12
 
13
13
  should_have_json 'access_token', Doorkeeper::AccessToken.first.token
14
14
  should_have_json 'expires_in', Doorkeeper.configuration.access_token_expires_in
15
- should_have_json 'scope', ''
16
- should_have_json 'refresh_token', nil
15
+ should_not_have_json 'scope'
16
+ should_not_have_json 'refresh_token'
17
17
 
18
18
  should_not_have_json 'error'
19
19
  should_not_have_json 'error_description'
@@ -1,6 +1,30 @@
1
1
  require 'spec_helper_integration'
2
2
 
3
3
  describe 'Custom controller for routes' do
4
+ it 'GET /space/scope/authorize routes to custom authorizations controller' do
5
+ get('/inner_space/scope/authorize').should route_to('custom_authorizations#new')
6
+ end
7
+
8
+ it 'POST /space/scope/authorize routes to custom authorizations controller' do
9
+ post('/inner_space/scope/authorize').should route_to('custom_authorizations#create')
10
+ end
11
+
12
+ it 'DELETE /space/scope/authorize routes to custom authorizations controller' do
13
+ delete('/inner_space/scope/authorize').should route_to('custom_authorizations#destroy')
14
+ end
15
+
16
+ it 'POST /space/scope/token routes to tokens controller' do
17
+ post('/inner_space/scope/token').should route_to('custom_authorizations#create')
18
+ end
19
+
20
+ it 'GET /space/scope/applications routes to applications controller' do
21
+ get('/inner_space/scope/applications').should route_to('custom_authorizations#index')
22
+ end
23
+
24
+ it 'GET /space/scope/token/info routes to the token_info controller' do
25
+ get('/inner_space/scope/token/info').should route_to('custom_authorizations#show')
26
+ end
27
+
4
28
  it 'GET /space/oauth/authorize routes to custom authorizations controller' do
5
29
  get('/space/oauth/authorize').should route_to('custom_authorizations#new')
6
30
  end
@@ -22,7 +46,7 @@ describe 'Custom controller for routes' do
22
46
  end
23
47
 
24
48
  it 'GET /space/oauth/token/info routes to the token_info controller' do
25
- get('/space/oauth/token/info').should route_to('custom_authorizations#show')
49
+ get('/space/oauth/token/info').should route_to('custom_authorizations#show')
26
50
  end
27
51
 
28
52
  it 'POST /outer_space/oauth/token is not be routable' do
@@ -40,5 +64,5 @@ describe 'Custom controller for routes' do
40
64
  it 'GET /outer_space/oauth/token_info is not routable' do
41
65
  get('/outer_space/oauth/token/info').should_not be_routable
42
66
  end
43
-
67
+
44
68
  end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper_integration'
2
+
3
+ describe 'Scoped routes' do
4
+ it 'GET /scope/authorize routes to authorizations controller' do
5
+ get('/scope/authorize').should route_to('doorkeeper/authorizations#new')
6
+ end
7
+
8
+ it 'POST /scope/authorize routes to authorizations controller' do
9
+ post('/scope/authorize').should route_to('doorkeeper/authorizations#create')
10
+ end
11
+
12
+ it 'DELETE /scope/authorize routes to authorizations controller' do
13
+ delete('/scope/authorize').should route_to('doorkeeper/authorizations#destroy')
14
+ end
15
+
16
+ it 'POST /scope/token routes to tokens controller' do
17
+ post('/scope/token').should route_to('doorkeeper/tokens#create')
18
+ end
19
+
20
+ it 'GET /scope/applications routes to applications controller' do
21
+ get('/scope/applications').should route_to('doorkeeper/applications#index')
22
+ end
23
+
24
+ it 'GET /scope/authorized_applications routes to authorized applications controller' do
25
+ get('/scope/authorized_applications').should route_to('doorkeeper/authorized_applications#index')
26
+ end
27
+
28
+ it 'GET /scope/token/info route to authorzed tokeninfo controller' do
29
+ get('/scope/token/info').should route_to('doorkeeper/token_info#show')
30
+ end
31
+
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doorkeeper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Elias Philipp
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-11 00:00:00.000000000 Z
12
+ date: 2013-10-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -372,6 +372,7 @@ files:
372
372
  - spec/requests/protected_resources/private_api_spec.rb
373
373
  - spec/routing/custom_controller_routes_spec.rb
374
374
  - spec/routing/default_routes_spec.rb
375
+ - spec/routing/scoped_routes_spec.rb
375
376
  - spec/spec_helper.rb
376
377
  - spec/spec_helper_integration.rb
377
378
  - spec/support/dependencies/factory_girl.rb