doorkeeper 4.2.0 → 4.2.5
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/.coveralls.yml +1 -0
- data/.gitignore +5 -0
- data/.travis.yml +11 -6
- data/Appraisals +14 -0
- data/Gemfile +4 -8
- data/NEWS.md +10 -1
- data/README.md +6 -1
- data/app/controllers/doorkeeper/applications_controller.rb +1 -5
- data/app/views/doorkeeper/applications/_delete_form.html.erb +1 -2
- data/app/views/doorkeeper/authorized_applications/_delete_form.html.erb +1 -2
- data/config/locales/en.yml +2 -2
- data/doorkeeper.gemspec +9 -7
- data/gemfiles/rails_4_2.gemfile +11 -0
- data/gemfiles/rails_5_0.gemfile +12 -0
- data/gemfiles/rails_5_1.gemfile +13 -0
- data/lib/doorkeeper.rb +7 -1
- data/lib/doorkeeper/config.rb +55 -0
- data/lib/doorkeeper/grape/helpers.rb +2 -1
- data/lib/doorkeeper/helpers/controller.rb +6 -6
- data/lib/doorkeeper/models/access_grant_mixin.rb +12 -0
- data/lib/doorkeeper/models/access_token_mixin.rb +117 -1
- data/lib/doorkeeper/models/application_mixin.rb +18 -2
- data/lib/doorkeeper/models/concerns/accessible.rb +4 -0
- data/lib/doorkeeper/models/concerns/expirable.rb +8 -0
- data/lib/doorkeeper/models/concerns/revocable.rb +18 -0
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +20 -18
- data/lib/doorkeeper/oauth/authorization_code_request.rb +1 -4
- data/lib/doorkeeper/oauth/{request_concern.rb → base_request.rb} +3 -1
- data/lib/doorkeeper/oauth/base_response.rb +29 -0
- data/lib/doorkeeper/oauth/client.rb +0 -1
- data/lib/doorkeeper/oauth/client/credentials.rb +17 -6
- data/lib/doorkeeper/oauth/client_credentials/creator.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/validation.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials_request.rb +1 -4
- data/lib/doorkeeper/oauth/code_response.rb +7 -6
- data/lib/doorkeeper/oauth/error_response.rb +9 -8
- data/lib/doorkeeper/oauth/invalid_token_response.rb +2 -0
- data/lib/doorkeeper/oauth/password_access_token_request.rb +1 -3
- data/lib/doorkeeper/oauth/refresh_token_request.rb +3 -7
- data/lib/doorkeeper/oauth/token.rb +17 -19
- data/lib/doorkeeper/oauth/token_request.rb +1 -2
- data/lib/doorkeeper/orm/active_record/access_token.rb +17 -0
- data/lib/doorkeeper/orm/active_record/application.rb +10 -5
- data/lib/doorkeeper/rails/helpers.rb +0 -2
- data/lib/doorkeeper/rails/routes.rb +3 -4
- data/lib/doorkeeper/rails/routes/mapper.rb +3 -3
- data/lib/doorkeeper/rails/routes/mapping.rb +1 -1
- data/lib/doorkeeper/request/authorization_code.rb +7 -1
- data/lib/doorkeeper/request/refresh_token.rb +1 -1
- data/lib/doorkeeper/server.rb +0 -8
- data/lib/doorkeeper/version.rb +1 -1
- data/spec/controllers/authorizations_controller_spec.rb +17 -3
- data/spec/lib/doorkeeper_spec.rb +135 -13
- data/spec/lib/oauth/authorization/uri_builder_spec.rb +1 -2
- data/spec/lib/oauth/base_request_spec.rb +160 -0
- data/spec/lib/oauth/base_response_spec.rb +45 -0
- data/spec/lib/oauth/client/credentials_spec.rb +41 -0
- data/spec/lib/oauth/error_response_spec.rb +9 -9
- data/spec/lib/oauth/invalid_token_response_spec.rb +36 -8
- data/spec/lib/server_spec.rb +0 -3
- data/spec/requests/endpoints/authorization_spec.rb +5 -6
- data/spec/requests/flows/authorization_code_spec.rb +4 -12
- data/spec/spec_helper.rb +2 -0
- data/spec/spec_helper_integration.rb +5 -0
- data/spec/support/helpers/request_spec_helper.rb +12 -4
- data/spec/support/http_method_shim.rb +20 -6
- metadata +43 -21
- data/lib/doorkeeper/oauth/client/methods.rb +0 -18
- data/spec/lib/oauth/client/methods_spec.rb +0 -54
data/spec/spec_helper.rb
CHANGED
@@ -27,6 +27,10 @@ module RequestSpecHelper
|
|
27
27
|
URI.parse(page.current_url)
|
28
28
|
end
|
29
29
|
|
30
|
+
def request_response
|
31
|
+
respond_to?(:response) ? response : page.driver.response
|
32
|
+
end
|
33
|
+
|
30
34
|
def should_have_header(header, value)
|
31
35
|
expect(headers[header]).to eq(value)
|
32
36
|
end
|
@@ -44,15 +48,15 @@ module RequestSpecHelper
|
|
44
48
|
end
|
45
49
|
|
46
50
|
def should_have_json(key, value)
|
47
|
-
expect(JSON.parse(
|
51
|
+
expect(JSON.parse(request_response.body).fetch(key)).to eq(value)
|
48
52
|
end
|
49
53
|
|
50
54
|
def should_have_json_within(key, value, range)
|
51
|
-
expect(JSON.parse(
|
55
|
+
expect(JSON.parse(request_response.body).fetch(key)).to be_within(range).of(value)
|
52
56
|
end
|
53
57
|
|
54
58
|
def should_not_have_json(key)
|
55
|
-
expect(JSON.parse(
|
59
|
+
expect(JSON.parse(request_response.body)).not_to have_key(key)
|
56
60
|
end
|
57
61
|
|
58
62
|
def sign_in
|
@@ -60,6 +64,10 @@ module RequestSpecHelper
|
|
60
64
|
click_on 'Sign in'
|
61
65
|
end
|
62
66
|
|
67
|
+
def create_access_token(authorization_code, client)
|
68
|
+
page.driver.post token_endpoint_url(code: authorization_code, client: client)
|
69
|
+
end
|
70
|
+
|
63
71
|
def i_should_see_translated_error_message(key)
|
64
72
|
i_should_see translated_error_message(key)
|
65
73
|
end
|
@@ -69,7 +77,7 @@ module RequestSpecHelper
|
|
69
77
|
end
|
70
78
|
|
71
79
|
def response_status_should_be(status)
|
72
|
-
expect(
|
80
|
+
expect(request_response.status.to_i).to eq(status)
|
73
81
|
end
|
74
82
|
end
|
75
83
|
|
@@ -2,23 +2,37 @@
|
|
2
2
|
# in favor of keyword arguments. However, the keyword argument form is only
|
3
3
|
# supported in Rails 5+. Since we support back to 4, we need some sort of shim
|
4
4
|
# to avoid super noisy deprecations when running tests.
|
5
|
-
module
|
6
|
-
def get(path, params =
|
5
|
+
module RoutingHTTPMethodShim
|
6
|
+
def get(path, params = {}, headers = nil)
|
7
7
|
super(path, params: params, headers: headers)
|
8
8
|
end
|
9
9
|
|
10
|
-
def post(path, params =
|
10
|
+
def post(path, params = {}, headers = nil)
|
11
11
|
super(path, params: params, headers: headers)
|
12
12
|
end
|
13
13
|
|
14
|
-
def put(path, params =
|
14
|
+
def put(path, params = {}, headers = nil)
|
15
15
|
super(path, params: params, headers: headers)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
module ControllerHTTPMethodShim
|
20
|
+
def get(path, params = {})
|
21
|
+
super(path, params: params)
|
22
|
+
end
|
23
|
+
|
24
|
+
def post(path, params = {})
|
25
|
+
super(path, params: params)
|
26
|
+
end
|
27
|
+
|
28
|
+
def put(path, params = {})
|
29
|
+
super(path, params: params)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
19
33
|
if ::Rails::VERSION::MAJOR >= 5
|
20
34
|
RSpec.configure do |config|
|
21
|
-
config.include
|
22
|
-
config.include
|
35
|
+
config.include ControllerHTTPMethodShim, type: :controller
|
36
|
+
config.include RoutingHTTPMethodShim, type: :request
|
23
37
|
end
|
24
38
|
end
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doorkeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felipe Elias Philipp
|
8
8
|
- Tute Costa
|
9
|
+
- Jon Moss
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2017-02-12 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: railties
|
@@ -39,62 +40,76 @@ dependencies:
|
|
39
40
|
- - ">="
|
40
41
|
- !ruby/object:Gem::Version
|
41
42
|
version: '0'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: coveralls
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
42
57
|
- !ruby/object:Gem::Dependency
|
43
58
|
name: database_cleaner
|
44
59
|
requirement: !ruby/object:Gem::Requirement
|
45
60
|
requirements:
|
46
61
|
- - "~>"
|
47
62
|
- !ruby/object:Gem::Version
|
48
|
-
version: 1.3
|
63
|
+
version: 1.5.3
|
49
64
|
type: :development
|
50
65
|
prerelease: false
|
51
66
|
version_requirements: !ruby/object:Gem::Requirement
|
52
67
|
requirements:
|
53
68
|
- - "~>"
|
54
69
|
- !ruby/object:Gem::Version
|
55
|
-
version: 1.3
|
70
|
+
version: 1.5.3
|
56
71
|
- !ruby/object:Gem::Dependency
|
57
72
|
name: factory_girl
|
58
73
|
requirement: !ruby/object:Gem::Requirement
|
59
74
|
requirements:
|
60
75
|
- - "~>"
|
61
76
|
- !ruby/object:Gem::Version
|
62
|
-
version: 4.
|
77
|
+
version: 4.7.0
|
63
78
|
type: :development
|
64
79
|
prerelease: false
|
65
80
|
version_requirements: !ruby/object:Gem::Requirement
|
66
81
|
requirements:
|
67
82
|
- - "~>"
|
68
83
|
- !ruby/object:Gem::Version
|
69
|
-
version: 4.
|
84
|
+
version: 4.7.0
|
70
85
|
- !ruby/object:Gem::Dependency
|
71
86
|
name: generator_spec
|
72
87
|
requirement: !ruby/object:Gem::Requirement
|
73
88
|
requirements:
|
74
89
|
- - "~>"
|
75
90
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0.9.
|
91
|
+
version: 0.9.3
|
77
92
|
type: :development
|
78
93
|
prerelease: false
|
79
94
|
version_requirements: !ruby/object:Gem::Requirement
|
80
95
|
requirements:
|
81
96
|
- - "~>"
|
82
97
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0.9.
|
98
|
+
version: 0.9.3
|
84
99
|
- !ruby/object:Gem::Dependency
|
85
100
|
name: rake
|
86
101
|
requirement: !ruby/object:Gem::Requirement
|
87
102
|
requirements:
|
88
|
-
- - "
|
103
|
+
- - ">="
|
89
104
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
105
|
+
version: 11.3.0
|
91
106
|
type: :development
|
92
107
|
prerelease: false
|
93
108
|
version_requirements: !ruby/object:Gem::Requirement
|
94
109
|
requirements:
|
95
|
-
- - "
|
110
|
+
- - ">="
|
96
111
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
112
|
+
version: 11.3.0
|
98
113
|
- !ruby/object:Gem::Dependency
|
99
114
|
name: rspec-rails
|
100
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -115,25 +130,27 @@ dependencies:
|
|
115
130
|
requirements:
|
116
131
|
- - "~>"
|
117
132
|
- !ruby/object:Gem::Version
|
118
|
-
version: 0.
|
133
|
+
version: 0.8.1
|
119
134
|
type: :development
|
120
135
|
prerelease: false
|
121
136
|
version_requirements: !ruby/object:Gem::Requirement
|
122
137
|
requirements:
|
123
138
|
- - "~>"
|
124
139
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0.
|
140
|
+
version: 0.8.1
|
126
141
|
description: Doorkeeper is an OAuth 2 provider for Rails and Grape.
|
127
142
|
email:
|
128
|
-
-
|
143
|
+
- me@jonathanmoss.me
|
129
144
|
executables: []
|
130
145
|
extensions: []
|
131
146
|
extra_rdoc_files: []
|
132
147
|
files:
|
148
|
+
- ".coveralls.yml"
|
133
149
|
- ".gitignore"
|
134
150
|
- ".hound.yml"
|
135
151
|
- ".rspec"
|
136
152
|
- ".travis.yml"
|
153
|
+
- Appraisals
|
137
154
|
- CONTRIBUTING.md
|
138
155
|
- Gemfile
|
139
156
|
- MIT-LICENSE
|
@@ -167,6 +184,9 @@ files:
|
|
167
184
|
- app/views/layouts/doorkeeper/application.html.erb
|
168
185
|
- config/locales/en.yml
|
169
186
|
- doorkeeper.gemspec
|
187
|
+
- gemfiles/rails_4_2.gemfile
|
188
|
+
- gemfiles/rails_5_0.gemfile
|
189
|
+
- gemfiles/rails_5_1.gemfile
|
170
190
|
- lib/doorkeeper.rb
|
171
191
|
- lib/doorkeeper/config.rb
|
172
192
|
- lib/doorkeeper/engine.rb
|
@@ -186,9 +206,10 @@ files:
|
|
186
206
|
- lib/doorkeeper/oauth/authorization/token.rb
|
187
207
|
- lib/doorkeeper/oauth/authorization/uri_builder.rb
|
188
208
|
- lib/doorkeeper/oauth/authorization_code_request.rb
|
209
|
+
- lib/doorkeeper/oauth/base_request.rb
|
210
|
+
- lib/doorkeeper/oauth/base_response.rb
|
189
211
|
- lib/doorkeeper/oauth/client.rb
|
190
212
|
- lib/doorkeeper/oauth/client/credentials.rb
|
191
|
-
- lib/doorkeeper/oauth/client/methods.rb
|
192
213
|
- lib/doorkeeper/oauth/client_credentials/creator.rb
|
193
214
|
- lib/doorkeeper/oauth/client_credentials/issuer.rb
|
194
215
|
- lib/doorkeeper/oauth/client_credentials/validation.rb
|
@@ -205,7 +226,6 @@ files:
|
|
205
226
|
- lib/doorkeeper/oauth/password_access_token_request.rb
|
206
227
|
- lib/doorkeeper/oauth/pre_authorization.rb
|
207
228
|
- lib/doorkeeper/oauth/refresh_token_request.rb
|
208
|
-
- lib/doorkeeper/oauth/request_concern.rb
|
209
229
|
- lib/doorkeeper/oauth/scopes.rb
|
210
230
|
- lib/doorkeeper/oauth/token.rb
|
211
231
|
- lib/doorkeeper/oauth/token_request.rb
|
@@ -297,8 +317,9 @@ files:
|
|
297
317
|
- spec/lib/models/scopes_spec.rb
|
298
318
|
- spec/lib/oauth/authorization/uri_builder_spec.rb
|
299
319
|
- spec/lib/oauth/authorization_code_request_spec.rb
|
320
|
+
- spec/lib/oauth/base_request_spec.rb
|
321
|
+
- spec/lib/oauth/base_response_spec.rb
|
300
322
|
- spec/lib/oauth/client/credentials_spec.rb
|
301
|
-
- spec/lib/oauth/client/methods_spec.rb
|
302
323
|
- spec/lib/oauth/client_credentials/creator_spec.rb
|
303
324
|
- spec/lib/oauth/client_credentials/issuer_spec.rb
|
304
325
|
- spec/lib/oauth/client_credentials/validation_spec.rb
|
@@ -371,7 +392,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
371
392
|
requirements:
|
372
393
|
- - ">="
|
373
394
|
- !ruby/object:Gem::Version
|
374
|
-
version: '
|
395
|
+
version: '2.1'
|
375
396
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
376
397
|
requirements:
|
377
398
|
- - ">="
|
@@ -379,7 +400,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
379
400
|
version: '0'
|
380
401
|
requirements: []
|
381
402
|
rubyforge_project:
|
382
|
-
rubygems_version: 2.5.
|
403
|
+
rubygems_version: 2.5.2
|
383
404
|
signing_key:
|
384
405
|
specification_version: 4
|
385
406
|
summary: OAuth 2 provider for Rails and Grape
|
@@ -442,8 +463,9 @@ test_files:
|
|
442
463
|
- spec/lib/models/scopes_spec.rb
|
443
464
|
- spec/lib/oauth/authorization/uri_builder_spec.rb
|
444
465
|
- spec/lib/oauth/authorization_code_request_spec.rb
|
466
|
+
- spec/lib/oauth/base_request_spec.rb
|
467
|
+
- spec/lib/oauth/base_response_spec.rb
|
445
468
|
- spec/lib/oauth/client/credentials_spec.rb
|
446
|
-
- spec/lib/oauth/client/methods_spec.rb
|
447
469
|
- spec/lib/oauth/client_credentials/creator_spec.rb
|
448
470
|
- spec/lib/oauth/client_credentials/issuer_spec.rb
|
449
471
|
- spec/lib/oauth/client_credentials/validation_spec.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Doorkeeper
|
2
|
-
module OAuth
|
3
|
-
class Client
|
4
|
-
module Methods
|
5
|
-
def from_params(request)
|
6
|
-
request.parameters.values_at(:client_id, :client_secret)
|
7
|
-
end
|
8
|
-
|
9
|
-
def from_basic(request)
|
10
|
-
authorization = request.authorization
|
11
|
-
if authorization.present? && authorization =~ /^Basic (.*)/m
|
12
|
-
Base64.decode64($1).split(/:/, 2)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'active_support/core_ext/string'
|
3
|
-
require 'doorkeeper/oauth/client'
|
4
|
-
|
5
|
-
class Doorkeeper::OAuth::Client
|
6
|
-
describe 'Methods' do
|
7
|
-
let(:client_id) { 'some-uid' }
|
8
|
-
let(:client_secret) { 'some-secret' }
|
9
|
-
|
10
|
-
subject do
|
11
|
-
Class.new do
|
12
|
-
include Methods
|
13
|
-
end.new
|
14
|
-
end
|
15
|
-
|
16
|
-
describe :from_params do
|
17
|
-
it 'returns credentials from parameters when Authorization header is not available' do
|
18
|
-
request = double parameters: { client_id: client_id, client_secret: client_secret }
|
19
|
-
uid, secret = subject.from_params(request)
|
20
|
-
|
21
|
-
expect(uid).to eq('some-uid')
|
22
|
-
expect(secret).to eq('some-secret')
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'is blank when there are no credentials' do
|
26
|
-
request = double parameters: {}
|
27
|
-
uid, secret = subject.from_params(request)
|
28
|
-
|
29
|
-
expect(uid).to be_blank
|
30
|
-
expect(secret).to be_blank
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe :from_basic do
|
35
|
-
let(:credentials) { Base64.encode64("#{client_id}:#{client_secret}") }
|
36
|
-
|
37
|
-
it 'decodes the credentials' do
|
38
|
-
request = double authorization: "Basic #{credentials}"
|
39
|
-
uid, secret = subject.from_basic(request)
|
40
|
-
|
41
|
-
expect(uid).to eq('some-uid')
|
42
|
-
expect(secret).to eq('some-secret')
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'is blank if Authorization is not Basic' do
|
46
|
-
request = double authorization: "#{credentials}"
|
47
|
-
uid, secret = subject.from_basic(request)
|
48
|
-
|
49
|
-
expect(uid).to be_blank
|
50
|
-
expect(secret).to be_blank
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|