doorkeeper 3.0.0 → 3.0.1

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: cf516340589e1681a0f18d5452292381e95588a8
4
- data.tar.gz: b68ffee6988edc433345fabf79177b3415552a47
3
+ metadata.gz: 6a81fba54edf374cfc12827a6de4b83736c0ad02
4
+ data.tar.gz: 90ac8eaf779f57d66a1957bbb245d29fec53ecfa
5
5
  SHA512:
6
- metadata.gz: 5df594f849f22a2369d0de9b14c9d58e4870b1588a6b5a0d708229b44872393b8cddea1ddb0c499939ef522408cc7f78867ef6595d77eb641758ec0a2d0e15b8
7
- data.tar.gz: cdcfd5e55d97f04636d7af18407194f89495d408c0fd353f53735f2e05e289837f5fa0c6f21a2cba485cbbd17e0e82cde44d0c4c2da70265e512f73769194f5d
6
+ metadata.gz: b5fe713de5da62552891c73ad8ccd85f07f3e71ec03418c5d9ae363ea762cae8cdb73d1ab976a602af172cca120e4db3845f27ea9307b980ce5ff34ef2fa5c2a
7
+ data.tar.gz: 861e8d86128858ca338912e096737267c0254092ae4c5054c97b2193be467c42d7487fd7e464646bca648a8ccc2be631936f65d93a77697d67f1ef4e14864820
@@ -1,11 +1,11 @@
1
1
  language: ruby
2
- sudo: false
3
2
  cache: bundler
4
3
 
5
4
  rvm:
6
5
  - 2.0
7
6
  - 2.1
8
7
  - 2.2
8
+ - jruby-head
9
9
 
10
10
  env:
11
11
  - rails=3.2.0
data/Gemfile CHANGED
@@ -4,4 +4,7 @@ source 'https://rubygems.org'
4
4
 
5
5
  gem 'rails', "~> #{ENV['rails']}"
6
6
 
7
+ gem "sqlite3", platform: [:ruby, :mswin, :mingw]
8
+ gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
9
+
7
10
  gemspec
data/NEWS.md CHANGED
@@ -4,6 +4,16 @@ User-visible changes worth mentioning.
4
4
 
5
5
  ---
6
6
 
7
+ ## 3.0.1
8
+
9
+ - [#712] Wrap exchange of grant token for access token and access token refresh
10
+ in transactions
11
+ - [#704] Allow applications scopes to be mass assigned
12
+ - [#707] Fixed order of Mixin inclusion and table_name configuration in models
13
+ - [#712] Wrap access token and refresh grants in transactions
14
+ - Adds JRuby support
15
+ - Specs, views and documentation adjustments
16
+
7
17
  ## 3.0.0
8
18
 
9
19
  ### Other changes
data/README.md CHANGED
@@ -331,7 +331,7 @@ wiki](https://github.com/doorkeeper-gem/doorkeeper/wiki/Customizing-routes).
331
331
  If you want to upgrade doorkeeper to a new version, check out the [upgrading
332
332
  notes](https://github.com/doorkeeper-gem/doorkeeper/wiki/Migration-from-old-versions)
333
333
  and take a look at the
334
- [changelog](https://github.com/doorkeeper-gem/doorkeeper/blob/master/CHANGELOG.md).
334
+ [changelog](https://github.com/doorkeeper-gem/doorkeeper/blob/master/NEWS.md).
335
335
 
336
336
  ## Development
337
337
 
@@ -4,8 +4,8 @@
4
4
  2. Update `NEWS.md` to reflect the changes since last release.
5
5
  3. Commit changes. There shouldn’t be code changes, and thus CI doesn’t need to
6
6
  run, you can then add “[ci skip]” to the commit message.
7
- 4. Tag the release: `git tag vVERSION`
8
- 5. Push changes: `git push --tags`
7
+ 4. Tag the release: `git tag vVERSION -m "Release vVERSION"`
8
+ 5. Push changes: `git push && git push --tags`
9
9
  6. Build and publish the gem:
10
10
 
11
11
  ```bash
@@ -7,7 +7,7 @@
7
7
  <%= raw t('.prompt', client_name: "<strong class=\"text-info\">#{ @pre_auth.client.name }</strong>") %>
8
8
  </p>
9
9
 
10
- <% if @pre_auth.scopes %>
10
+ <% if @pre_auth.scopes.count > 0 %>
11
11
  <div id="oauth-permissions">
12
12
  <p><%= t('.able_to') %>:</p>
13
13
 
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_dependency "railties", ">= 3.2"
20
20
 
21
- s.add_development_dependency "sqlite3", "~> 1.3.5"
22
21
  s.add_development_dependency "rspec-rails", "~> 3.2.0"
23
22
  s.add_development_dependency "capybara", "~> 2.3.0"
24
23
  s.add_development_dependency "generator_spec", "~> 0.9.0"
@@ -6,6 +6,12 @@ module Doorkeeper
6
6
  class InvalidAuthorizationStrategy < DoorkeeperError
7
7
  end
8
8
 
9
+ class InvalidTokenReuse < DoorkeeperError
10
+ end
11
+
12
+ class InvalidGrantReuse < DoorkeeperError
13
+ end
14
+
9
15
  class InvalidTokenStrategy < DoorkeeperError
10
16
  end
11
17
 
@@ -41,6 +41,10 @@ module Doorkeeper
41
41
  :unsupported_response_type
42
42
  when Errors::MissingRequestStrategy
43
43
  :invalid_request
44
+ when Errors::InvalidTokenReuse
45
+ :invalid_request
46
+ when Errors::InvalidGrantReuse
47
+ :invalid_grant
44
48
  end
45
49
 
46
50
  OAuth::ErrorResponse.new name: error_name, state: params[:state]
@@ -17,7 +17,7 @@ module Doorkeeper
17
17
  before_validation :generate_uid, :generate_secret, on: :create
18
18
 
19
19
  if respond_to?(:attr_accessible)
20
- attr_accessible :name, :redirect_uri
20
+ attr_accessible :name, :redirect_uri, :scopes
21
21
  end
22
22
  end
23
23
 
@@ -21,11 +21,16 @@ module Doorkeeper
21
21
  private
22
22
 
23
23
  def before_successful_response
24
- grant.revoke
25
- find_or_create_access_token(grant.application,
26
- grant.resource_owner_id,
27
- grant.scopes,
28
- server)
24
+ grant.transaction do
25
+ grant.lock!
26
+ raise Errors::InvalidGrantReuse if grant.revoked?
27
+
28
+ grant.revoke
29
+ find_or_create_access_token(grant.application,
30
+ grant.resource_owner_id,
31
+ grant.scopes,
32
+ server)
33
+ end
29
34
  end
30
35
 
31
36
  def validate_attributes
@@ -32,8 +32,13 @@ module Doorkeeper
32
32
  attr_reader :refresh_token_parameter
33
33
 
34
34
  def before_successful_response
35
- refresh_token.revoke
36
- create_access_token
35
+ refresh_token.transaction do
36
+ refresh_token.lock!
37
+ raise Errors::InvalidTokenReuse if refresh_token.revoked?
38
+
39
+ refresh_token.revoke
40
+ create_access_token
41
+ end
37
42
  end
38
43
 
39
44
  def default_scopes
@@ -1,7 +1,7 @@
1
1
  module Doorkeeper
2
2
  class AccessGrant < ActiveRecord::Base
3
- include AccessGrantMixin
4
-
5
3
  self.table_name = "#{table_name_prefix}oauth_access_grants#{table_name_suffix}".to_sym
4
+
5
+ include AccessGrantMixin
6
6
  end
7
7
  end
@@ -1,9 +1,9 @@
1
1
  module Doorkeeper
2
2
  class AccessToken < ActiveRecord::Base
3
- include AccessTokenMixin
4
-
5
3
  self.table_name = "#{table_name_prefix}oauth_access_tokens#{table_name_suffix}".to_sym
6
4
 
5
+ include AccessTokenMixin
6
+
7
7
  def self.delete_all_for(application_id, resource_owner)
8
8
  where(application_id: application_id,
9
9
  resource_owner_id: resource_owner.id).delete_all
@@ -1,9 +1,9 @@
1
1
  module Doorkeeper
2
2
  class Application < ActiveRecord::Base
3
- include ApplicationMixin
4
-
5
3
  self.table_name = "#{table_name_prefix}oauth_applications#{table_name_suffix}".to_sym
6
4
 
5
+ include ApplicationMixin
6
+
7
7
  if ActiveRecord::VERSION::MAJOR >= 4
8
8
  has_many :authorized_tokens, -> { where(revoked_at: nil) }, class_name: 'AccessToken'
9
9
  else
@@ -1,3 +1,3 @@
1
1
  module Doorkeeper
2
- VERSION = '3.0.0'
2
+ VERSION = '3.0.1'
3
3
  end
@@ -123,7 +123,7 @@ module Doorkeeper
123
123
  it 'is not valid if token exists' do
124
124
  token1 = FactoryGirl.create :access_token, use_refresh_token: true
125
125
  token2 = FactoryGirl.create :access_token, use_refresh_token: true
126
- token2.send :write_attribute, :refresh_token, token1.refresh_token
126
+ token2.refresh_token = token1.refresh_token
127
127
  expect(token2).not_to be_valid
128
128
  end
129
129
 
@@ -131,9 +131,9 @@ module Doorkeeper
131
131
  token1 = FactoryGirl.create :access_token, use_refresh_token: true
132
132
  token2 = FactoryGirl.create :access_token, use_refresh_token: true
133
133
  expect do
134
- token2.write_attribute :refresh_token, token1.refresh_token
134
+ token2.refresh_token = token1.refresh_token
135
135
  token2.save(validate: false)
136
- end.to raise_error
136
+ end.to raise_error(ActiveRecord::RecordNotUnique)
137
137
  end
138
138
  end
139
139
 
@@ -90,7 +90,7 @@ module Doorkeeper
90
90
  app1 = FactoryGirl.create(:application)
91
91
  app2 = FactoryGirl.create(:application)
92
92
  app2.uid = app1.uid
93
- expect { app2.save!(validate: false) }.to raise_error
93
+ expect { app2.save!(validate: false) }.to raise_error(ActiveRecord::RecordNotUnique)
94
94
  end
95
95
 
96
96
  it 'generate secret on create' do
@@ -128,3 +128,29 @@ feature 'Authorization Code Flow' do
128
128
  end
129
129
  end
130
130
  end
131
+
132
+ describe 'Authorization Code Flow' do
133
+ before do
134
+ Doorkeeper.configure do
135
+ orm DOORKEEPER_ORM
136
+ use_refresh_token
137
+ end
138
+ client_exists
139
+ end
140
+
141
+ context 'issuing a refresh token' do
142
+ before do
143
+ authorization_code_exists application: @client
144
+ end
145
+
146
+ it 'second of simultaneous client requests get an error for revoked acccess token' do
147
+ authorization_code = Doorkeeper::AccessGrant.first.token
148
+ allow_any_instance_of(Doorkeeper::AccessGrant).to receive(:revoked?).and_return(false, true)
149
+
150
+ post token_endpoint_url(code: authorization_code, client: @client)
151
+
152
+ should_not_have_json 'access_token'
153
+ should_have_json 'error', 'invalid_grant'
154
+ end
155
+ end
156
+ end
@@ -65,6 +65,14 @@ describe 'Refresh Token Flow' do
65
65
  should_not_have_json 'refresh_token'
66
66
  should_have_json 'error', 'invalid_grant'
67
67
  end
68
+
69
+ it 'second of simultaneous client requests get an error for revoked acccess token' do
70
+ allow_any_instance_of(Doorkeeper::AccessToken).to receive(:revoked?).and_return(false, true)
71
+ post refresh_token_endpoint_url(client: @client, refresh_token: @token.refresh_token)
72
+
73
+ should_not_have_json 'refresh_token'
74
+ should_have_json 'error', 'invalid_request'
75
+ end
68
76
  end
69
77
 
70
78
  context 'refreshing the token with multiple sessions (devices)' do
@@ -14,6 +14,13 @@ require 'generator_spec/test_case'
14
14
  require 'timecop'
15
15
  require 'database_cleaner'
16
16
 
17
+ # Load JRuby SQLite3 if in that platform
18
+ begin
19
+ require 'jdbc/sqlite3'
20
+ Jdbc::SQLite3.load_driver
21
+ rescue LoadError
22
+ end
23
+
17
24
  Rails.logger.info "====> Doorkeeper.orm = #{Doorkeeper.configuration.orm.inspect}"
18
25
  if Doorkeeper.configuration.orm == :active_record
19
26
  Rails.logger.info "======> active_record.table_name_prefix = #{Rails.configuration.active_record.table_name_prefix.inspect}"
@@ -46,7 +46,7 @@ shared_examples 'a unique token' do
46
46
  token2.token = token1.token
47
47
  expect do
48
48
  token2.save!(validate: false)
49
- end.to raise_error
49
+ end.to raise_error(ActiveRecord::RecordNotUnique)
50
50
  end
51
51
  end
52
52
  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: 3.0.0
4
+ version: 3.0.1
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: 2015-07-30 00:00:00.000000000 Z
12
+ date: 2015-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -25,20 +25,6 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '3.2'
28
- - !ruby/object:Gem::Dependency
29
- name: sqlite3
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: 1.3.5
35
- type: :development
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: 1.3.5
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: rspec-rails
44
30
  requirement: !ruby/object:Gem::Requirement
@@ -373,7 +359,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
373
359
  version: '0'
374
360
  requirements: []
375
361
  rubyforge_project:
376
- rubygems_version: 2.4.5
362
+ rubygems_version: 2.4.5.1
377
363
  signing_key:
378
364
  specification_version: 4
379
365
  summary: OAuth 2 provider for Rails and Grape
@@ -492,4 +478,3 @@ test_files:
492
478
  - spec/support/shared/controllers_shared_context.rb
493
479
  - spec/support/shared/models_shared_examples.rb
494
480
  - spec/validators/redirect_uri_validator_spec.rb
495
- has_rdoc: