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.

Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -10
  3. data/CONTRIBUTING.md +2 -0
  4. data/Gemfile +8 -4
  5. data/NEWS.md +57 -2
  6. data/README.md +48 -40
  7. data/Rakefile +1 -1
  8. data/app/controllers/doorkeeper/application_metal_controller.rb +1 -2
  9. data/app/controllers/doorkeeper/applications_controller.rb +2 -2
  10. data/app/controllers/doorkeeper/authorizations_controller.rb +1 -1
  11. data/app/controllers/doorkeeper/authorized_applications_controller.rb +1 -1
  12. data/app/controllers/doorkeeper/tokens_controller.rb +1 -1
  13. data/app/helpers/doorkeeper/dashboard_helper.rb +13 -11
  14. data/app/views/doorkeeper/applications/show.html.erb +1 -1
  15. data/app/views/layouts/doorkeeper/admin.html.erb +1 -1
  16. data/config/locales/en.yml +1 -0
  17. data/doorkeeper.gemspec +7 -6
  18. data/lib/doorkeeper/config.rb +10 -15
  19. data/lib/doorkeeper/engine.rb +11 -7
  20. data/lib/doorkeeper/helpers/controller.rb +1 -1
  21. data/lib/doorkeeper/models/access_grant_mixin.rb +9 -5
  22. data/lib/doorkeeper/models/access_token_mixin.rb +28 -22
  23. data/lib/doorkeeper/models/application_mixin.rb +3 -7
  24. data/lib/doorkeeper/models/concerns/expirable.rb +2 -2
  25. data/lib/doorkeeper/models/concerns/ownership.rb +6 -1
  26. data/lib/doorkeeper/models/concerns/revocable.rb +19 -2
  27. data/lib/doorkeeper/oauth/authorization/uri_builder.rb +1 -1
  28. data/lib/doorkeeper/oauth/client/credentials.rb +1 -1
  29. data/lib/doorkeeper/oauth/client_credentials/issuer.rb +2 -1
  30. data/lib/doorkeeper/oauth/client_credentials_request.rb +7 -4
  31. data/lib/doorkeeper/oauth/code_response.rb +13 -14
  32. data/lib/doorkeeper/oauth/helpers/scope_checker.rb +1 -1
  33. data/lib/doorkeeper/oauth/helpers/uri_checker.rb +2 -1
  34. data/lib/doorkeeper/oauth/password_access_token_request.rb +6 -10
  35. data/lib/doorkeeper/oauth/refresh_token_request.rb +23 -11
  36. data/lib/doorkeeper/oauth/scopes.rb +2 -2
  37. data/lib/doorkeeper/oauth/token.rb +6 -5
  38. data/lib/doorkeeper/oauth/token_response.rb +1 -1
  39. data/lib/doorkeeper/orm/active_record/access_token.rb +8 -0
  40. data/lib/doorkeeper/orm/active_record/application.rb +2 -7
  41. data/lib/doorkeeper/orm/active_record.rb +0 -16
  42. data/lib/doorkeeper/rails/helpers.rb +1 -1
  43. data/lib/doorkeeper/rails/routes/mapper.rb +1 -1
  44. data/lib/doorkeeper/rails/routes.rb +2 -1
  45. data/lib/doorkeeper/request/password.rb +11 -1
  46. data/lib/doorkeeper/version.rb +1 -1
  47. data/lib/doorkeeper.rb +1 -1
  48. data/lib/generators/doorkeeper/previous_refresh_token_generator.rb +29 -0
  49. data/lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb +1 -1
  50. data/lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb +11 -0
  51. data/lib/generators/doorkeeper/templates/initializer.rb +2 -2
  52. data/lib/generators/doorkeeper/templates/migration.rb +23 -5
  53. data/spec/controllers/authorizations_controller_spec.rb +0 -14
  54. data/spec/controllers/protected_resources_controller_spec.rb +47 -18
  55. data/spec/dummy/app/controllers/full_protected_resources_controller.rb +4 -4
  56. data/spec/dummy/app/controllers/home_controller.rb +1 -1
  57. data/spec/dummy/app/controllers/metal_controller.rb +1 -1
  58. data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +3 -3
  59. data/spec/dummy/app/models/user.rb +0 -4
  60. data/spec/dummy/config/application.rb +2 -36
  61. data/spec/dummy/config/environment.rb +1 -1
  62. data/spec/dummy/config/environments/test.rb +4 -15
  63. data/spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +6 -0
  64. data/spec/dummy/config/initializers/doorkeeper.rb +2 -2
  65. data/spec/dummy/db/migrate/{20130902165751_create_doorkeeper_tables.rb → 20151223192035_create_doorkeeper_tables.rb} +24 -5
  66. data/spec/dummy/db/migrate/{20130902175349_add_owner_to_application.rb → 20151223200000_add_owner_to_application.rb} +0 -0
  67. data/spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb +11 -0
  68. data/spec/dummy/db/schema.rb +23 -22
  69. data/spec/lib/config_spec.rb +2 -2
  70. data/spec/lib/models/revocable_spec.rb +27 -4
  71. data/spec/lib/oauth/authorization_code_request_spec.rb +1 -1
  72. data/spec/lib/oauth/code_response_spec.rb +34 -0
  73. data/spec/lib/oauth/password_access_token_request_spec.rb +5 -5
  74. data/spec/lib/oauth/refresh_token_request_spec.rb +34 -3
  75. data/spec/lib/oauth/scopes_spec.rb +0 -1
  76. data/spec/lib/oauth/token_spec.rb +12 -5
  77. data/spec/models/doorkeeper/access_token_spec.rb +45 -1
  78. data/spec/models/doorkeeper/application_spec.rb +2 -10
  79. data/spec/requests/flows/password_spec.rb +26 -5
  80. data/spec/requests/flows/refresh_token_spec.rb +87 -17
  81. data/spec/spec_helper_integration.rb +3 -0
  82. data/spec/support/helpers/model_helper.rb +27 -5
  83. data/spec/support/http_method_shim.rb +24 -0
  84. data/spec/support/shared/controllers_shared_context.rb +13 -4
  85. data/spec/support/shared/models_shared_examples.rb +1 -1
  86. metadata +52 -32
  87. data/lib/generators/doorkeeper/application_scopes_generator.rb +0 -34
  88. data/lib/generators/doorkeeper/templates/add_scopes_to_oauth_applications.rb +0 -5
  89. data/spec/dummy/db/migrate/20141209001746_add_scopes_to_oauth_applications.rb +0 -5
@@ -4,11 +4,15 @@ shared_context 'valid token', token: :valid do
4
4
  end
5
5
 
6
6
  let :token do
7
- double(Doorkeeper::AccessToken, accessible?: true, includes_scope?: true, acceptable?: true)
7
+ double(Doorkeeper::AccessToken,
8
+ accessible?: true, includes_scope?: true, acceptable?: true,
9
+ previous_refresh_token: "", revoke_previous_refresh_token!: true)
8
10
  end
9
11
 
10
12
  before :each do
11
- allow(Doorkeeper::AccessToken).to receive(:by_token).with(token_string).and_return(token)
13
+ allow(
14
+ Doorkeeper::AccessToken
15
+ ).to receive(:by_token).with(token_string).and_return(token)
12
16
  end
13
17
  end
14
18
 
@@ -18,11 +22,16 @@ shared_context 'invalid token', token: :invalid do
18
22
  end
19
23
 
20
24
  let :token do
21
- double(Doorkeeper::AccessToken, accessible?: false, revoked?: false, expired?: false, includes_scope?: false, acceptable?: false)
25
+ double(Doorkeeper::AccessToken,
26
+ accessible?: false, revoked?: false, expired?: false,
27
+ includes_scope?: false, acceptable?: false,
28
+ previous_refresh_token: "", revoke_previous_refresh_token!: true)
22
29
  end
23
30
 
24
31
  before :each do
25
- allow(Doorkeeper::AccessToken).to receive(:by_token).with(token_string).and_return(token)
32
+ allow(
33
+ Doorkeeper::AccessToken
34
+ ).to receive(:by_token).with(token_string).and_return(token)
26
35
  end
27
36
  end
28
37
 
@@ -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(ActiveRecord::RecordNotUnique)
49
+ end.to raise_error(uniqueness_error)
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.1.0
4
+ version: 4.0.0
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-23 00:00:00.000000000 Z
12
+ date: 2016-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -17,42 +17,56 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '3.2'
20
+ version: '4.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '3.2'
27
+ version: '4.2'
28
28
  - !ruby/object:Gem::Dependency
29
- name: rspec-rails
29
+ name: capybara
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: database_cleaner
30
44
  requirement: !ruby/object:Gem::Requirement
31
45
  requirements:
32
46
  - - "~>"
33
47
  - !ruby/object:Gem::Version
34
- version: 3.4.0
48
+ version: 1.3.0
35
49
  type: :development
36
50
  prerelease: false
37
51
  version_requirements: !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - "~>"
40
54
  - !ruby/object:Gem::Version
41
- version: 3.4.0
55
+ version: 1.3.0
42
56
  - !ruby/object:Gem::Dependency
43
- name: capybara
57
+ name: factory_girl
44
58
  requirement: !ruby/object:Gem::Requirement
45
59
  requirements:
46
60
  - - "~>"
47
61
  - !ruby/object:Gem::Version
48
- version: 2.3.0
62
+ version: 4.5.0
49
63
  type: :development
50
64
  prerelease: false
51
65
  version_requirements: !ruby/object:Gem::Requirement
52
66
  requirements:
53
67
  - - "~>"
54
68
  - !ruby/object:Gem::Version
55
- version: 2.3.0
69
+ version: 4.5.0
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: generator_spec
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -68,47 +82,47 @@ dependencies:
68
82
  - !ruby/object:Gem::Version
69
83
  version: 0.9.0
70
84
  - !ruby/object:Gem::Dependency
71
- name: factory_girl
85
+ name: rake
72
86
  requirement: !ruby/object:Gem::Requirement
73
87
  requirements:
74
- - - "~>"
88
+ - - ">"
75
89
  - !ruby/object:Gem::Version
76
- version: 4.5.0
90
+ version: 10.5.0
77
91
  type: :development
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
- - - "~>"
95
+ - - ">"
82
96
  - !ruby/object:Gem::Version
83
- version: 4.5.0
97
+ version: 10.5.0
84
98
  - !ruby/object:Gem::Dependency
85
- name: timecop
99
+ name: rspec-rails
86
100
  requirement: !ruby/object:Gem::Requirement
87
101
  requirements:
88
- - - "~>"
102
+ - - ">="
89
103
  - !ruby/object:Gem::Version
90
- version: 0.7.0
104
+ version: '0'
91
105
  type: :development
92
106
  prerelease: false
93
107
  version_requirements: !ruby/object:Gem::Requirement
94
108
  requirements:
95
- - - "~>"
109
+ - - ">="
96
110
  - !ruby/object:Gem::Version
97
- version: 0.7.0
111
+ version: '0'
98
112
  - !ruby/object:Gem::Dependency
99
- name: database_cleaner
113
+ name: timecop
100
114
  requirement: !ruby/object:Gem::Requirement
101
115
  requirements:
102
116
  - - "~>"
103
117
  - !ruby/object:Gem::Version
104
- version: 1.3.0
118
+ version: 0.7.0
105
119
  type: :development
106
120
  prerelease: false
107
121
  version_requirements: !ruby/object:Gem::Requirement
108
122
  requirements:
109
123
  - - "~>"
110
124
  - !ruby/object:Gem::Version
111
- version: 1.3.0
125
+ version: 0.7.0
112
126
  description: Doorkeeper is an OAuth 2 provider for Rails and Grape.
113
127
  email:
114
128
  - tutecosta@gmail.com
@@ -216,12 +230,12 @@ files:
216
230
  - lib/doorkeeper/validations.rb
217
231
  - lib/doorkeeper/version.rb
218
232
  - lib/generators/doorkeeper/application_owner_generator.rb
219
- - lib/generators/doorkeeper/application_scopes_generator.rb
220
233
  - lib/generators/doorkeeper/install_generator.rb
221
234
  - lib/generators/doorkeeper/migration_generator.rb
235
+ - lib/generators/doorkeeper/previous_refresh_token_generator.rb
222
236
  - lib/generators/doorkeeper/templates/README
223
237
  - lib/generators/doorkeeper/templates/add_owner_to_application_migration.rb
224
- - lib/generators/doorkeeper/templates/add_scopes_to_oauth_applications.rb
238
+ - lib/generators/doorkeeper/templates/add_previous_refresh_token_to_access_tokens.rb
225
239
  - lib/generators/doorkeeper/templates/initializer.rb
226
240
  - lib/generators/doorkeeper/templates/migration.rb
227
241
  - lib/generators/doorkeeper/views_generator.rb
@@ -249,6 +263,7 @@ files:
249
263
  - spec/dummy/config/environments/development.rb
250
264
  - spec/dummy/config/environments/production.rb
251
265
  - spec/dummy/config/environments/test.rb
266
+ - spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb
252
267
  - spec/dummy/config/initializers/backtrace_silencers.rb
253
268
  - spec/dummy/config/initializers/doorkeeper.rb
254
269
  - spec/dummy/config/initializers/secret_token.rb
@@ -258,9 +273,9 @@ files:
258
273
  - spec/dummy/config/routes.rb
259
274
  - spec/dummy/db/migrate/20111122132257_create_users.rb
260
275
  - spec/dummy/db/migrate/20120312140401_add_password_to_users.rb
261
- - spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb
262
- - spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb
263
- - spec/dummy/db/migrate/20141209001746_add_scopes_to_oauth_applications.rb
276
+ - spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb
277
+ - spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb
278
+ - spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb
264
279
  - spec/dummy/db/schema.rb
265
280
  - spec/dummy/public/404.html
266
281
  - spec/dummy/public/422.html
@@ -290,6 +305,7 @@ files:
290
305
  - spec/lib/oauth/client_credentials_request_spec.rb
291
306
  - spec/lib/oauth/client_spec.rb
292
307
  - spec/lib/oauth/code_request_spec.rb
308
+ - spec/lib/oauth/code_response_spec.rb
293
309
  - spec/lib/oauth/error_response_spec.rb
294
310
  - spec/lib/oauth/error_spec.rb
295
311
  - spec/lib/oauth/forbidden_token_response_spec.rb
@@ -336,6 +352,7 @@ files:
336
352
  - spec/support/helpers/model_helper.rb
337
353
  - spec/support/helpers/request_spec_helper.rb
338
354
  - spec/support/helpers/url_helper.rb
355
+ - spec/support/http_method_shim.rb
339
356
  - spec/support/orm/active_record.rb
340
357
  - spec/support/shared/controllers_shared_context.rb
341
358
  - spec/support/shared/models_shared_examples.rb
@@ -361,7 +378,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
361
378
  version: '0'
362
379
  requirements: []
363
380
  rubyforge_project:
364
- rubygems_version: 2.5.1
381
+ rubygems_version: 2.6.2
365
382
  signing_key:
366
383
  specification_version: 4
367
384
  summary: OAuth 2 provider for Rails and Grape
@@ -390,6 +407,7 @@ test_files:
390
407
  - spec/dummy/config/environments/development.rb
391
408
  - spec/dummy/config/environments/production.rb
392
409
  - spec/dummy/config/environments/test.rb
410
+ - spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb
393
411
  - spec/dummy/config/initializers/backtrace_silencers.rb
394
412
  - spec/dummy/config/initializers/doorkeeper.rb
395
413
  - spec/dummy/config/initializers/secret_token.rb
@@ -399,9 +417,9 @@ test_files:
399
417
  - spec/dummy/config/routes.rb
400
418
  - spec/dummy/db/migrate/20111122132257_create_users.rb
401
419
  - spec/dummy/db/migrate/20120312140401_add_password_to_users.rb
402
- - spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb
403
- - spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb
404
- - spec/dummy/db/migrate/20141209001746_add_scopes_to_oauth_applications.rb
420
+ - spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb
421
+ - spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb
422
+ - spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb
405
423
  - spec/dummy/db/schema.rb
406
424
  - spec/dummy/public/404.html
407
425
  - spec/dummy/public/422.html
@@ -431,6 +449,7 @@ test_files:
431
449
  - spec/lib/oauth/client_credentials_request_spec.rb
432
450
  - spec/lib/oauth/client_spec.rb
433
451
  - spec/lib/oauth/code_request_spec.rb
452
+ - spec/lib/oauth/code_response_spec.rb
434
453
  - spec/lib/oauth/error_response_spec.rb
435
454
  - spec/lib/oauth/error_spec.rb
436
455
  - spec/lib/oauth/forbidden_token_response_spec.rb
@@ -477,6 +496,7 @@ test_files:
477
496
  - spec/support/helpers/model_helper.rb
478
497
  - spec/support/helpers/request_spec_helper.rb
479
498
  - spec/support/helpers/url_helper.rb
499
+ - spec/support/http_method_shim.rb
480
500
  - spec/support/orm/active_record.rb
481
501
  - spec/support/shared/controllers_shared_context.rb
482
502
  - spec/support/shared/models_shared_examples.rb
@@ -1,34 +0,0 @@
1
- require 'rails/generators/active_record'
2
-
3
- class Doorkeeper::ApplicationScopesGenerator < Rails::Generators::Base
4
- include Rails::Generators::Migration
5
- source_root File.expand_path('../templates', __FILE__)
6
- desc 'Copies ActiveRecord migrations to handle upgrade to doorkeeper 2'
7
-
8
- def self.next_migration_number(path)
9
- ActiveRecord::Generators::Base.next_migration_number(path)
10
- end
11
-
12
- def application_scopes
13
- if oauth_applications_exists? && !scopes_column_exists?
14
- migration_template(
15
- 'add_scopes_to_oauth_applications.rb',
16
- 'db/migrate/add_scopes_to_oauth_applications.rb'
17
- )
18
- end
19
- end
20
-
21
- private
22
-
23
- def scopes_column_exists?
24
- ActiveRecord::Base.connection.column_exists?(
25
- :oauth_applications,
26
- :scopes
27
- )
28
- end
29
-
30
- # Might be running this before install
31
- def oauth_applications_exists?
32
- ActiveRecord::Base.connection.table_exists? :oauth_applications
33
- end
34
- end
@@ -1,5 +0,0 @@
1
- class AddScopesToOauthApplications < ActiveRecord::Migration
2
- def change
3
- add_column :oauth_applications, :scopes, :string, null: false, default: ''
4
- end
5
- end
@@ -1,5 +0,0 @@
1
- class AddScopesToOauthApplications < ActiveRecord::Migration
2
- def change
3
- add_column :oauth_applications, :scopes, :string, null: false, default: ''
4
- end
5
- end