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 +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +3 -0
- data/NEWS.md +10 -0
- data/README.md +1 -1
- data/RELEASING.md +2 -2
- data/app/views/doorkeeper/authorizations/new.html.erb +1 -1
- data/doorkeeper.gemspec +0 -1
- data/lib/doorkeeper/errors.rb +6 -0
- data/lib/doorkeeper/helpers/controller.rb +4 -0
- data/lib/doorkeeper/models/application_mixin.rb +1 -1
- data/lib/doorkeeper/oauth/authorization_code_request.rb +10 -5
- data/lib/doorkeeper/oauth/refresh_token_request.rb +7 -2
- data/lib/doorkeeper/orm/active_record/access_grant.rb +2 -2
- data/lib/doorkeeper/orm/active_record/access_token.rb +2 -2
- data/lib/doorkeeper/orm/active_record/application.rb +2 -2
- data/lib/doorkeeper/version.rb +1 -1
- data/spec/models/doorkeeper/access_token_spec.rb +3 -3
- data/spec/models/doorkeeper/application_spec.rb +1 -1
- data/spec/requests/flows/authorization_code_spec.rb +26 -0
- data/spec/requests/flows/refresh_token_spec.rb +8 -0
- data/spec/spec_helper_integration.rb +7 -0
- data/spec/support/shared/models_shared_examples.rb +1 -1
- metadata +3 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a81fba54edf374cfc12827a6de4b83736c0ad02
|
4
|
+
data.tar.gz: 90ac8eaf779f57d66a1957bbb245d29fec53ecfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5fe713de5da62552891c73ad8ccd85f07f3e71ec03418c5d9ae363ea762cae8cdb73d1ab976a602af172cca120e4db3845f27ea9307b980ce5ff34ef2fa5c2a
|
7
|
+
data.tar.gz: 861e8d86128858ca338912e096737267c0254092ae4c5054c97b2193be467c42d7487fd7e464646bca648a8ccc2be631936f65d93a77697d67f1ef4e14864820
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
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/
|
334
|
+
[changelog](https://github.com/doorkeeper-gem/doorkeeper/blob/master/NEWS.md).
|
335
335
|
|
336
336
|
## Development
|
337
337
|
|
data/RELEASING.md
CHANGED
@@ -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
|
data/doorkeeper.gemspec
CHANGED
@@ -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"
|
data/lib/doorkeeper/errors.rb
CHANGED
@@ -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]
|
@@ -21,11 +21,16 @@ module Doorkeeper
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def before_successful_response
|
24
|
-
grant.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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.
|
36
|
-
|
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,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
|
data/lib/doorkeeper/version.rb
CHANGED
@@ -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.
|
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.
|
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}"
|
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.
|
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-
|
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:
|