doorkeeper 3.1.0 → 4.0.0
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 +8 -10
- data/CONTRIBUTING.md +2 -0
- data/Gemfile +8 -4
- data/NEWS.md +57 -2
- data/README.md +48 -40
- data/Rakefile +1 -1
- data/app/controllers/doorkeeper/application_metal_controller.rb +1 -2
- data/app/controllers/doorkeeper/applications_controller.rb +2 -2
- data/app/controllers/doorkeeper/authorizations_controller.rb +1 -1
- data/app/controllers/doorkeeper/authorized_applications_controller.rb +1 -1
- data/app/controllers/doorkeeper/tokens_controller.rb +1 -1
- data/app/helpers/doorkeeper/dashboard_helper.rb +13 -11
- data/app/views/doorkeeper/applications/show.html.erb +1 -1
- data/app/views/layouts/doorkeeper/admin.html.erb +1 -1
- data/config/locales/en.yml +1 -0
- data/doorkeeper.gemspec +7 -6
- data/lib/doorkeeper/config.rb +10 -15
- data/lib/doorkeeper/engine.rb +11 -7
- data/lib/doorkeeper/helpers/controller.rb +1 -1
- data/lib/doorkeeper/models/access_grant_mixin.rb +9 -5
- data/lib/doorkeeper/models/access_token_mixin.rb +28 -22
- data/lib/doorkeeper/models/application_mixin.rb +3 -7
- data/lib/doorkeeper/models/concerns/expirable.rb +2 -2
- data/lib/doorkeeper/models/concerns/ownership.rb +6 -1
- data/lib/doorkeeper/models/concerns/revocable.rb +19 -2
- data/lib/doorkeeper/oauth/authorization/uri_builder.rb +1 -1
- data/lib/doorkeeper/oauth/client/credentials.rb +1 -1
- data/lib/doorkeeper/oauth/client_credentials/issuer.rb +2 -1
- data/lib/doorkeeper/oauth/client_credentials_request.rb +7 -4
- data/lib/doorkeeper/oauth/code_response.rb +13 -14
- data/lib/doorkeeper/oauth/helpers/scope_checker.rb +1 -1
- data/lib/doorkeeper/oauth/helpers/uri_checker.rb +2 -1
- data/lib/doorkeeper/oauth/password_access_token_request.rb +6 -10
- data/lib/doorkeeper/oauth/refresh_token_request.rb +23 -11
- data/lib/doorkeeper/oauth/scopes.rb +2 -2
- data/lib/doorkeeper/oauth/token.rb +6 -5
- data/lib/doorkeeper/oauth/token_response.rb +1 -1
- data/lib/doorkeeper/orm/active_record/access_token.rb +8 -0
- data/lib/doorkeeper/orm/active_record/application.rb +2 -7
- data/lib/doorkeeper/orm/active_record.rb +0 -16
- data/lib/doorkeeper/rails/helpers.rb +1 -1
- data/lib/doorkeeper/rails/routes/mapper.rb +1 -1
- data/lib/doorkeeper/rails/routes.rb +2 -1
- data/lib/doorkeeper/request/password.rb +11 -1
- data/lib/doorkeeper/version.rb +1 -1
- data/lib/doorkeeper.rb +1 -1
- data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +29 -0
- data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb +1 -1
- data/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb +11 -0
- data/lib/generators/doorkeeper/templates/initializer.rb +2 -2
- data/lib/generators/doorkeeper/templates/migration.rb +23 -5
- data/spec/controllers/authorizations_controller_spec.rb +0 -14
- data/spec/controllers/protected_resources_controller_spec.rb +47 -18
- data/spec/dummy/app/controllers/full_protected_resources_controller.rb +4 -4
- data/spec/dummy/app/controllers/home_controller.rb +1 -1
- data/spec/dummy/app/controllers/metal_controller.rb +1 -1
- data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +3 -3
- data/spec/dummy/app/models/user.rb +0 -4
- data/spec/dummy/config/application.rb +2 -36
- data/spec/dummy/config/environment.rb +1 -1
- data/spec/dummy/config/environments/test.rb +4 -15
- data/spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +6 -0
- data/spec/dummy/config/initializers/doorkeeper.rb +2 -2
- data/spec/dummy/db/migrate/{20130902165751_create_doorkeeper_tables.rb → 20151223192035_create_doorkeeper_tables.rb} +24 -5
- data/spec/dummy/db/migrate/{20130902175349_add_owner_to_application.rb → 20151223200000_add_owner_to_application.rb} +0 -0
- data/spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb +11 -0
- data/spec/dummy/db/schema.rb +23 -22
- data/spec/lib/config_spec.rb +2 -2
- data/spec/lib/models/revocable_spec.rb +27 -4
- data/spec/lib/oauth/authorization_code_request_spec.rb +1 -1
- data/spec/lib/oauth/code_response_spec.rb +34 -0
- data/spec/lib/oauth/password_access_token_request_spec.rb +5 -5
- data/spec/lib/oauth/refresh_token_request_spec.rb +34 -3
- data/spec/lib/oauth/scopes_spec.rb +0 -1
- data/spec/lib/oauth/token_spec.rb +12 -5
- data/spec/models/doorkeeper/access_token_spec.rb +45 -1
- data/spec/models/doorkeeper/application_spec.rb +2 -10
- data/spec/requests/flows/password_spec.rb +26 -5
- data/spec/requests/flows/refresh_token_spec.rb +87 -17
- data/spec/spec_helper_integration.rb +3 -0
- data/spec/support/helpers/model_helper.rb +27 -5
- data/spec/support/http_method_shim.rb +24 -0
- data/spec/support/shared/controllers_shared_context.rb +13 -4
- data/spec/support/shared/models_shared_examples.rb +1 -1
- metadata +52 -32
- data/lib/generators/doorkeeper/application_scopes_generator.rb +0 -34
- data/lib/generators/doorkeeper/templates/add_scopes_to_oauth_applications.rb +0 -5
- data/spec/dummy/db/migrate/20141209001746_add_scopes_to_oauth_applications.rb +0 -5
@@ -41,10 +41,10 @@ Doorkeeper.configure do
|
|
41
41
|
# use_refresh_token
|
42
42
|
|
43
43
|
# Provide support for an owner to be assigned to each registered application (disabled by default)
|
44
|
-
# Optional parameter :
|
44
|
+
# Optional parameter confirmation: true (default false) if you want to enforce ownership of
|
45
45
|
# a registered application
|
46
46
|
# Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support
|
47
|
-
# enable_application_owner :
|
47
|
+
# enable_application_owner confirmation: false
|
48
48
|
|
49
49
|
# Define access token scopes for your provider
|
50
50
|
# For more information go to
|
@@ -6,14 +6,14 @@ class CreateDoorkeeperTables < ActiveRecord::Migration
|
|
6
6
|
t.string :secret, null: false
|
7
7
|
t.text :redirect_uri, null: false
|
8
8
|
t.string :scopes, null: false, default: ''
|
9
|
-
t.timestamps
|
9
|
+
t.timestamps null: false
|
10
10
|
end
|
11
11
|
|
12
12
|
add_index :oauth_applications, :uid, unique: true
|
13
13
|
|
14
14
|
create_table :oauth_access_grants do |t|
|
15
15
|
t.integer :resource_owner_id, null: false
|
16
|
-
t.
|
16
|
+
t.references :application, null: false
|
17
17
|
t.string :token, null: false
|
18
18
|
t.integer :expires_in, null: false
|
19
19
|
t.text :redirect_uri, null: false
|
@@ -23,10 +23,15 @@ class CreateDoorkeeperTables < ActiveRecord::Migration
|
|
23
23
|
end
|
24
24
|
|
25
25
|
add_index :oauth_access_grants, :token, unique: true
|
26
|
+
add_foreign_key(
|
27
|
+
:oauth_access_grants,
|
28
|
+
:oauth_applications,
|
29
|
+
column: :application_id
|
30
|
+
)
|
26
31
|
|
27
32
|
create_table :oauth_access_tokens do |t|
|
28
33
|
t.integer :resource_owner_id
|
29
|
-
t.
|
34
|
+
t.references :application
|
30
35
|
|
31
36
|
# If you use a custom token generator you may need to change this column
|
32
37
|
# from string to text, so that it accepts tokens larger than 255
|
@@ -34,17 +39,30 @@ class CreateDoorkeeperTables < ActiveRecord::Migration
|
|
34
39
|
# https://github.com/doorkeeper-gem/doorkeeper/tree/v3.0.0.rc1#custom-access-token-generator
|
35
40
|
#
|
36
41
|
# t.text :token, null: false
|
37
|
-
t.string :token,
|
42
|
+
t.string :token, null: false
|
38
43
|
|
39
44
|
t.string :refresh_token
|
40
45
|
t.integer :expires_in
|
41
46
|
t.datetime :revoked_at
|
42
|
-
t.datetime :created_at,
|
47
|
+
t.datetime :created_at, null: false
|
43
48
|
t.string :scopes
|
49
|
+
|
50
|
+
# If there is a previous_refresh_token column,
|
51
|
+
# refresh tokens will be revoked after a related access token is used.
|
52
|
+
# If there is no previous_refresh_token column,
|
53
|
+
# previous tokens are revoked as soon as a new access token is created.
|
54
|
+
# Comment out this line if you'd rather have refresh tokens
|
55
|
+
# instantly revoked.
|
56
|
+
t.string :previous_refresh_token, null: false, default: ""
|
44
57
|
end
|
45
58
|
|
46
59
|
add_index :oauth_access_tokens, :token, unique: true
|
47
60
|
add_index :oauth_access_tokens, :resource_owner_id
|
48
61
|
add_index :oauth_access_tokens, :refresh_token, unique: true
|
62
|
+
add_foreign_key(
|
63
|
+
:oauth_access_tokens,
|
64
|
+
:oauth_applications,
|
65
|
+
column: :application_id
|
66
|
+
)
|
49
67
|
end
|
50
68
|
end
|
@@ -89,16 +89,6 @@ describe Doorkeeper::AuthorizationsController, 'implicit grant flow' do
|
|
89
89
|
it 'returns the existing access token in a fragment'
|
90
90
|
end
|
91
91
|
|
92
|
-
describe 'GET #new' do
|
93
|
-
before do
|
94
|
-
get :new, client_id: client.uid, response_type: 'token', redirect_uri: client.redirect_uri
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'renders new template' do
|
98
|
-
expect(response).to render_template(:new)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
92
|
describe 'GET #new token request with native url and skip_authorization true' do
|
103
93
|
before do
|
104
94
|
allow(Doorkeeper.configuration).to receive(:skip_authorization).and_return(proc do
|
@@ -191,10 +181,6 @@ describe Doorkeeper::AuthorizationsController, 'implicit grant flow' do
|
|
191
181
|
expect(response).to_not be_redirect
|
192
182
|
end
|
193
183
|
|
194
|
-
it 'renders error template' do
|
195
|
-
expect(response).to render_template(:error)
|
196
|
-
end
|
197
|
-
|
198
184
|
it 'does not issue any token' do
|
199
185
|
expect(Doorkeeper::AccessGrant.count).to eq 0
|
200
186
|
expect(Doorkeeper::AccessToken.count).to eq 0
|
@@ -2,27 +2,35 @@ require 'spec_helper_integration'
|
|
2
2
|
|
3
3
|
module ControllerActions
|
4
4
|
def index
|
5
|
-
render
|
5
|
+
render plain: 'index'
|
6
6
|
end
|
7
7
|
|
8
8
|
def show
|
9
|
-
render
|
9
|
+
render plain: 'show'
|
10
|
+
end
|
11
|
+
|
12
|
+
def doorkeeper_unauthorized_render_options(*)
|
13
|
+
end
|
14
|
+
|
15
|
+
def doorkeeper_forbidden_render_options(*)
|
10
16
|
end
|
11
17
|
end
|
12
18
|
|
13
19
|
describe 'doorkeeper authorize filter' do
|
14
20
|
context 'accepts token code specified as' do
|
15
21
|
controller do
|
16
|
-
|
22
|
+
before_action :doorkeeper_authorize!
|
17
23
|
|
18
24
|
def index
|
19
|
-
render
|
25
|
+
render plain: 'index'
|
20
26
|
end
|
21
27
|
end
|
22
28
|
|
23
29
|
let(:token_string) { '1A2BC3' }
|
24
30
|
let(:token) do
|
25
|
-
double(Doorkeeper::AccessToken,
|
31
|
+
double(Doorkeeper::AccessToken,
|
32
|
+
acceptable?: true, previous_refresh_token: "",
|
33
|
+
revoke_previous_refresh_token!: true)
|
26
34
|
end
|
27
35
|
|
28
36
|
it 'access_token param' do
|
@@ -58,7 +66,7 @@ describe 'doorkeeper authorize filter' do
|
|
58
66
|
|
59
67
|
context 'defined for all actions' do
|
60
68
|
controller do
|
61
|
-
|
69
|
+
before_action :doorkeeper_authorize!
|
62
70
|
|
63
71
|
include ControllerActions
|
64
72
|
end
|
@@ -92,7 +100,7 @@ describe 'doorkeeper authorize filter' do
|
|
92
100
|
|
93
101
|
context 'defined with scopes' do
|
94
102
|
controller do
|
95
|
-
|
103
|
+
before_action -> { doorkeeper_authorize! :write }
|
96
104
|
|
97
105
|
include ControllerActions
|
98
106
|
end
|
@@ -100,16 +108,26 @@ describe 'doorkeeper authorize filter' do
|
|
100
108
|
let(:token_string) { '1A2DUWE' }
|
101
109
|
|
102
110
|
it 'allows if the token has particular scopes' do
|
103
|
-
token = double(Doorkeeper::AccessToken,
|
111
|
+
token = double(Doorkeeper::AccessToken,
|
112
|
+
accessible?: true, scopes: %w(write public),
|
113
|
+
previous_refresh_token: "",
|
114
|
+
revoke_previous_refresh_token!: true)
|
104
115
|
expect(token).to receive(:acceptable?).with([:write]).and_return(true)
|
105
|
-
expect(
|
116
|
+
expect(
|
117
|
+
Doorkeeper::AccessToken
|
118
|
+
).to receive(:by_token).with(token_string).and_return(token)
|
106
119
|
get :index, access_token: token_string
|
107
120
|
expect(response).to be_success
|
108
121
|
end
|
109
122
|
|
110
123
|
it 'does not allow if the token does not include given scope' do
|
111
|
-
token = double(Doorkeeper::AccessToken,
|
112
|
-
|
124
|
+
token = double(Doorkeeper::AccessToken,
|
125
|
+
accessible?: true, scopes: ['public'], revoked?: false,
|
126
|
+
expired?: false, previous_refresh_token: "",
|
127
|
+
revoke_previous_refresh_token!: true)
|
128
|
+
expect(
|
129
|
+
Doorkeeper::AccessToken
|
130
|
+
).to receive(:by_token).with(token_string).and_return(token)
|
113
131
|
expect(token).to receive(:acceptable?).with([:write]).and_return(false)
|
114
132
|
get :index, access_token: token_string
|
115
133
|
expect(response.status).to eq 403
|
@@ -119,7 +137,7 @@ describe 'doorkeeper authorize filter' do
|
|
119
137
|
|
120
138
|
context 'when custom unauthorized render options are configured' do
|
121
139
|
controller do
|
122
|
-
|
140
|
+
before_action :doorkeeper_authorize!
|
123
141
|
|
124
142
|
include ControllerActions
|
125
143
|
end
|
@@ -127,6 +145,7 @@ describe 'doorkeeper authorize filter' do
|
|
127
145
|
context 'with a JSON custom render', token: :invalid do
|
128
146
|
before do
|
129
147
|
module ControllerActions
|
148
|
+
remove_method :doorkeeper_unauthorized_render_options
|
130
149
|
def doorkeeper_unauthorized_render_options(error: nil)
|
131
150
|
{ json: ActiveSupport::JSON.encode(error_message: error.description) }
|
132
151
|
end
|
@@ -134,6 +153,7 @@ describe 'doorkeeper authorize filter' do
|
|
134
153
|
end
|
135
154
|
after do
|
136
155
|
module ControllerActions
|
156
|
+
remove_method :doorkeeper_unauthorized_render_options
|
137
157
|
def doorkeeper_unauthorized_render_options(error: nil)
|
138
158
|
end
|
139
159
|
end
|
@@ -153,13 +173,15 @@ describe 'doorkeeper authorize filter' do
|
|
153
173
|
context 'with a text custom render', token: :invalid do
|
154
174
|
before do
|
155
175
|
module ControllerActions
|
176
|
+
remove_method :doorkeeper_unauthorized_render_options
|
156
177
|
def doorkeeper_unauthorized_render_options(error: nil)
|
157
|
-
{
|
178
|
+
{ plain: 'Unauthorized' }
|
158
179
|
end
|
159
180
|
end
|
160
181
|
end
|
161
182
|
after do
|
162
183
|
module ControllerActions
|
184
|
+
remove_method :doorkeeper_unauthorized_render_options
|
163
185
|
def doorkeeper_unauthorized_render_options(error: nil)
|
164
186
|
end
|
165
187
|
end
|
@@ -168,7 +190,7 @@ describe 'doorkeeper authorize filter' do
|
|
168
190
|
it 'it renders a custom text response', token: :invalid do
|
169
191
|
get :index, access_token: token_string
|
170
192
|
expect(response.status).to eq 401
|
171
|
-
expect(response.content_type).to eq('text/
|
193
|
+
expect(response.content_type).to eq('text/plain')
|
172
194
|
expect(response.header['WWW-Authenticate']).to match(/^Bearer/)
|
173
195
|
expect(response.body).to eq('Unauthorized')
|
174
196
|
end
|
@@ -183,26 +205,30 @@ describe 'doorkeeper authorize filter' do
|
|
183
205
|
|
184
206
|
after do
|
185
207
|
module ControllerActions
|
208
|
+
remove_method :doorkeeper_forbidden_render_options
|
186
209
|
def doorkeeper_forbidden_render_options(*)
|
187
210
|
end
|
188
211
|
end
|
189
212
|
end
|
190
213
|
|
191
214
|
controller do
|
192
|
-
|
215
|
+
before_action -> { doorkeeper_authorize! :write }
|
193
216
|
|
194
217
|
include ControllerActions
|
195
218
|
end
|
196
219
|
|
197
220
|
let(:token) do
|
198
221
|
double(Doorkeeper::AccessToken,
|
199
|
-
accessible?: true, scopes: ['public'], revoked?: false,
|
222
|
+
accessible?: true, scopes: ['public'], revoked?: false,
|
223
|
+
expired?: false, previous_refresh_token: "",
|
224
|
+
revoke_previous_refresh_token!: true)
|
200
225
|
end
|
201
226
|
let(:token_string) { '1A2DUWE' }
|
202
227
|
|
203
228
|
context 'with a JSON custom render' do
|
204
229
|
before do
|
205
230
|
module ControllerActions
|
231
|
+
remove_method :doorkeeper_forbidden_render_options
|
206
232
|
def doorkeeper_forbidden_render_options(*)
|
207
233
|
{ json: { error_message: 'Forbidden' } }
|
208
234
|
end
|
@@ -223,6 +249,7 @@ describe 'doorkeeper authorize filter' do
|
|
223
249
|
context 'with a status and JSON custom render' do
|
224
250
|
before do
|
225
251
|
module ControllerActions
|
252
|
+
remove_method :doorkeeper_forbidden_render_options
|
226
253
|
def doorkeeper_forbidden_render_options(*)
|
227
254
|
{ json: { error_message: 'Not Found' },
|
228
255
|
respond_not_found_when_forbidden: true }
|
@@ -239,8 +266,9 @@ describe 'doorkeeper authorize filter' do
|
|
239
266
|
context 'with a text custom render' do
|
240
267
|
before do
|
241
268
|
module ControllerActions
|
269
|
+
remove_method :doorkeeper_forbidden_render_options
|
242
270
|
def doorkeeper_forbidden_render_options(*)
|
243
|
-
{
|
271
|
+
{ plain: 'Forbidden' }
|
244
272
|
end
|
245
273
|
end
|
246
274
|
end
|
@@ -256,8 +284,9 @@ describe 'doorkeeper authorize filter' do
|
|
256
284
|
context 'with a status and text custom render' do
|
257
285
|
before do
|
258
286
|
module ControllerActions
|
287
|
+
remove_method :doorkeeper_forbidden_render_options
|
259
288
|
def doorkeeper_forbidden_render_options(*)
|
260
|
-
{ respond_not_found_when_forbidden: true,
|
289
|
+
{ respond_not_found_when_forbidden: true, plain: 'Not Found' }
|
261
290
|
end
|
262
291
|
end
|
263
292
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class FullProtectedResourcesController < ApplicationController
|
2
|
-
|
3
|
-
|
2
|
+
before_action -> { doorkeeper_authorize! :write, :admin }, only: :show
|
3
|
+
before_action :doorkeeper_authorize!, only: :index
|
4
4
|
|
5
5
|
def index
|
6
|
-
render
|
6
|
+
render plain: 'index'
|
7
7
|
end
|
8
8
|
|
9
9
|
def show
|
10
|
-
render
|
10
|
+
render plain: 'show'
|
11
11
|
end
|
12
12
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class SemiProtectedResourcesController < ApplicationController
|
2
|
-
|
2
|
+
before_action :doorkeeper_authorize!, only: :index
|
3
3
|
|
4
4
|
def index
|
5
|
-
render
|
5
|
+
render plain: 'protected index'
|
6
6
|
end
|
7
7
|
|
8
8
|
def show
|
9
|
-
render
|
9
|
+
render plain: 'non protected show'
|
10
10
|
end
|
11
11
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'sprockets/railtie'
|
3
|
+
require 'rails/all'
|
5
4
|
|
6
|
-
Bundler.require
|
5
|
+
Bundler.require(*Rails.groups)
|
7
6
|
|
8
7
|
require 'yaml'
|
9
8
|
|
@@ -20,38 +19,5 @@ module Dummy
|
|
20
19
|
# Settings in config/environments/* take precedence over those specified here.
|
21
20
|
# Application configuration should go into files in config/initializers
|
22
21
|
# -- all .rb files in that directory are automatically loaded.
|
23
|
-
|
24
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
25
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
26
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
27
|
-
|
28
|
-
# Activate observers that should always be running.
|
29
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
30
|
-
|
31
|
-
if defined?(ActiveRecord) && Rails.version.to_i < 4
|
32
|
-
config.active_record.whitelist_attributes = true
|
33
|
-
end
|
34
|
-
|
35
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
36
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
37
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
38
|
-
|
39
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
40
|
-
config.i18n.load_path += Dir[Rails.root.join('../../', 'config/locales', '*.{rb,yml}').to_s]
|
41
|
-
# config.i18n.default_locale = :en
|
42
|
-
|
43
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
44
|
-
config.encoding = 'utf-8'
|
45
|
-
|
46
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
47
|
-
config.filter_parameters += [:password]
|
48
|
-
|
49
|
-
# Enable the asset pipeline
|
50
|
-
config.assets.enabled = true
|
51
|
-
|
52
|
-
# Version of your assets, change this if you want to expire all your assets
|
53
|
-
config.assets.version = '1.0'
|
54
|
-
|
55
|
-
I18n.enforce_available_locales = false
|
56
22
|
end
|
57
23
|
end
|
@@ -7,21 +7,10 @@ Dummy::Application.configure do
|
|
7
7
|
# and recreated between test runs. Don't rely on the data there!
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# Log error messages when you accidentally call methods on nil
|
15
|
-
config.whiny_nils = true
|
16
|
-
end
|
17
|
-
|
18
|
-
if Rails.version.to_i >= 4
|
19
|
-
# Do not eager load code on boot. This avoids loading your whole application
|
20
|
-
# just for the purpose of running a single test. If you are using a tool that
|
21
|
-
# preloads Rails for running tests, you may have to set it to true.
|
22
|
-
config.eager_load = false
|
23
|
-
config.i18n.enforce_available_locales = true
|
24
|
-
end
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
25
14
|
|
26
15
|
# Show full error reports and disable caching
|
27
16
|
config.consider_all_requests_local = true
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# Require `belongs_to` associations by default. This is a new Rails 5.0
|
2
|
+
# default, so it is introduced as a configuration option to ensure that apps
|
3
|
+
# made on earlier versions of Rails are not affected when upgrading.
|
4
|
+
if Rails.version.to_i >= 5
|
5
|
+
Rails.application.config.active_record.belongs_to_required_by_default = true
|
6
|
+
end
|
@@ -30,10 +30,10 @@ Doorkeeper.configure do
|
|
30
30
|
use_refresh_token
|
31
31
|
|
32
32
|
# Provide support for an owner to be assigned to each registered application (disabled by default)
|
33
|
-
# Optional parameter :
|
33
|
+
# Optional parameter confirmation: true (default false) if you want to enforce ownership of
|
34
34
|
# a registered application
|
35
35
|
# Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support
|
36
|
-
# enable_application_owner :
|
36
|
+
# enable_application_owner confirmation: false
|
37
37
|
|
38
38
|
# Define access token scopes for your provider
|
39
39
|
# For more information go to
|
@@ -4,29 +4,43 @@ class CreateDoorkeeperTables < ActiveRecord::Migration
|
|
4
4
|
t.string :name, null: false
|
5
5
|
t.string :uid, null: false
|
6
6
|
t.string :secret, null: false
|
7
|
-
t.
|
8
|
-
t.
|
7
|
+
t.text :redirect_uri, null: false
|
8
|
+
t.string :scopes, null: false, default: ''
|
9
|
+
t.timestamps null: false
|
9
10
|
end
|
10
11
|
|
11
12
|
add_index :oauth_applications, :uid, unique: true
|
12
13
|
|
13
14
|
create_table :oauth_access_grants do |t|
|
14
15
|
t.integer :resource_owner_id, null: false
|
15
|
-
t.
|
16
|
+
t.references :application, null: false
|
16
17
|
t.string :token, null: false
|
17
18
|
t.integer :expires_in, null: false
|
18
|
-
t.
|
19
|
+
t.text :redirect_uri, null: false
|
19
20
|
t.datetime :created_at, null: false
|
20
21
|
t.datetime :revoked_at
|
21
22
|
t.string :scopes
|
22
23
|
end
|
23
24
|
|
24
25
|
add_index :oauth_access_grants, :token, unique: true
|
26
|
+
add_foreign_key(
|
27
|
+
:oauth_access_grants,
|
28
|
+
:oauth_applications,
|
29
|
+
column: :application_id,
|
30
|
+
)
|
25
31
|
|
26
32
|
create_table :oauth_access_tokens do |t|
|
27
33
|
t.integer :resource_owner_id
|
28
|
-
t.
|
34
|
+
t.references :application
|
35
|
+
|
36
|
+
# If you use a custom token generator you may need to change this column
|
37
|
+
# from string to text, so that it accepts tokens larger than 255
|
38
|
+
# characters. More info on custom token generators in:
|
39
|
+
# https://github.com/doorkeeper-gem/doorkeeper/tree/v3.0.0.rc1#custom-access-token-generator
|
40
|
+
#
|
41
|
+
# t.text :token, null: false
|
29
42
|
t.string :token, null: false
|
43
|
+
|
30
44
|
t.string :refresh_token
|
31
45
|
t.integer :expires_in
|
32
46
|
t.datetime :revoked_at
|
@@ -37,5 +51,10 @@ class CreateDoorkeeperTables < ActiveRecord::Migration
|
|
37
51
|
add_index :oauth_access_tokens, :token, unique: true
|
38
52
|
add_index :oauth_access_tokens, :resource_owner_id
|
39
53
|
add_index :oauth_access_tokens, :refresh_token, unique: true
|
54
|
+
add_foreign_key(
|
55
|
+
:oauth_access_tokens,
|
56
|
+
:oauth_applications,
|
57
|
+
column: :application_id,
|
58
|
+
)
|
40
59
|
end
|
41
60
|
end
|
File without changes
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,55 +11,56 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20160320211015) do
|
15
15
|
|
16
|
-
create_table "oauth_access_grants", force:
|
17
|
-
t.integer "resource_owner_id",
|
18
|
-
t.integer "application_id",
|
19
|
-
t.string "token",
|
20
|
-
t.integer "expires_in",
|
21
|
-
t.
|
22
|
-
t.datetime "created_at",
|
16
|
+
create_table "oauth_access_grants", force: :cascade do |t|
|
17
|
+
t.integer "resource_owner_id", null: false
|
18
|
+
t.integer "application_id", null: false
|
19
|
+
t.string "token", null: false
|
20
|
+
t.integer "expires_in", null: false
|
21
|
+
t.text "redirect_uri", null: false
|
22
|
+
t.datetime "created_at", null: false
|
23
23
|
t.datetime "revoked_at"
|
24
24
|
t.string "scopes"
|
25
25
|
end
|
26
26
|
|
27
27
|
add_index "oauth_access_grants", ["token"], name: "index_oauth_access_grants_on_token", unique: true
|
28
28
|
|
29
|
-
create_table "oauth_access_tokens", force:
|
29
|
+
create_table "oauth_access_tokens", force: :cascade do |t|
|
30
30
|
t.integer "resource_owner_id"
|
31
31
|
t.integer "application_id"
|
32
|
-
t.string "token",
|
32
|
+
t.string "token", null: false
|
33
33
|
t.string "refresh_token"
|
34
34
|
t.integer "expires_in"
|
35
35
|
t.datetime "revoked_at"
|
36
|
-
t.datetime "created_at",
|
36
|
+
t.datetime "created_at", null: false
|
37
37
|
t.string "scopes"
|
38
|
+
t.string "previous_refresh_token", default: "", null: false
|
38
39
|
end
|
39
40
|
|
40
41
|
add_index "oauth_access_tokens", ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true
|
41
42
|
add_index "oauth_access_tokens", ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id"
|
42
43
|
add_index "oauth_access_tokens", ["token"], name: "index_oauth_access_tokens_on_token", unique: true
|
43
44
|
|
44
|
-
create_table "oauth_applications", force:
|
45
|
-
t.string "name",
|
46
|
-
t.string "uid",
|
47
|
-
t.string "secret",
|
48
|
-
t.
|
49
|
-
t.
|
50
|
-
t.datetime "
|
45
|
+
create_table "oauth_applications", force: :cascade do |t|
|
46
|
+
t.string "name", null: false
|
47
|
+
t.string "uid", null: false
|
48
|
+
t.string "secret", null: false
|
49
|
+
t.text "redirect_uri", null: false
|
50
|
+
t.string "scopes", default: "", null: false
|
51
|
+
t.datetime "created_at"
|
52
|
+
t.datetime "updated_at"
|
51
53
|
t.integer "owner_id"
|
52
54
|
t.string "owner_type"
|
53
|
-
t.string "scopes", default: "", null: false
|
54
55
|
end
|
55
56
|
|
56
57
|
add_index "oauth_applications", ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type"
|
57
58
|
add_index "oauth_applications", ["uid"], name: "index_oauth_applications_on_uid", unique: true
|
58
59
|
|
59
|
-
create_table "users", force:
|
60
|
+
create_table "users", force: :cascade do |t|
|
60
61
|
t.string "name"
|
61
|
-
t.datetime "created_at"
|
62
|
-
t.datetime "updated_at"
|
62
|
+
t.datetime "created_at"
|
63
|
+
t.datetime "updated_at"
|
63
64
|
t.string "password"
|
64
65
|
end
|
65
66
|
|
data/spec/lib/config_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Doorkeeper, 'configuration' do
|
|
8
8
|
block = proc {}
|
9
9
|
Doorkeeper.configure do
|
10
10
|
orm DOORKEEPER_ORM
|
11
|
-
resource_owner_authenticator
|
11
|
+
resource_owner_authenticator(&block)
|
12
12
|
end
|
13
13
|
expect(subject.authenticate_resource_owner).to eq(block)
|
14
14
|
end
|
@@ -149,7 +149,7 @@ describe Doorkeeper, 'configuration' do
|
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
152
|
-
describe '
|
152
|
+
describe 'access_token_methods' do
|
153
153
|
it 'has defaults order' do
|
154
154
|
expect(subject.access_token_methods).to eq([:from_bearer_authorization, :from_access_token_param, :from_bearer_param])
|
155
155
|
end
|