doorkeeper 2.1.4 → 3.1.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 (135) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +4 -0
  3. data/.travis.yml +5 -24
  4. data/CONTRIBUTING.md +23 -13
  5. data/Gemfile +3 -7
  6. data/{CHANGELOG.md → NEWS.md} +137 -42
  7. data/README.md +60 -46
  8. data/RELEASING.md +5 -3
  9. data/app/assets/stylesheets/doorkeeper/admin/application.css +1 -5
  10. data/app/controllers/doorkeeper/applications_controller.rb +2 -2
  11. data/app/helpers/doorkeeper/dashboard_helper.rb +1 -1
  12. data/app/validators/redirect_uri_validator.rb +1 -1
  13. data/app/views/doorkeeper/applications/_form.html.erb +13 -2
  14. data/app/views/doorkeeper/applications/show.html.erb +3 -2
  15. data/app/views/doorkeeper/authorizations/new.html.erb +1 -1
  16. data/app/views/layouts/doorkeeper/admin.html.erb +5 -2
  17. data/config/locales/en.yml +4 -32
  18. data/doorkeeper.gemspec +4 -8
  19. data/lib/doorkeeper/config.rb +20 -29
  20. data/lib/doorkeeper/engine.rb +7 -1
  21. data/lib/doorkeeper/errors.rb +12 -0
  22. data/lib/doorkeeper/grape/helpers.rb +1 -1
  23. data/lib/doorkeeper/helpers/controller.rb +6 -0
  24. data/lib/doorkeeper/models/access_grant_mixin.rb +3 -2
  25. data/lib/doorkeeper/models/access_token_mixin.rb +12 -4
  26. data/lib/doorkeeper/models/application_mixin.rb +11 -18
  27. data/lib/doorkeeper/models/concerns/revocable.rb +2 -2
  28. data/lib/doorkeeper/oauth/authorization/token.rb +15 -6
  29. data/lib/doorkeeper/oauth/authorization_code_request.rb +10 -5
  30. data/lib/doorkeeper/oauth/client.rb +9 -8
  31. data/lib/doorkeeper/oauth/client_credentials/creator.rb +3 -4
  32. data/lib/doorkeeper/oauth/error.rb +5 -1
  33. data/lib/doorkeeper/oauth/helpers/scope_checker.rb +1 -1
  34. data/lib/doorkeeper/oauth/refresh_token_request.rb +17 -7
  35. data/lib/doorkeeper/orm/active_record/access_grant.rb +2 -2
  36. data/lib/doorkeeper/orm/active_record/access_token.rb +2 -2
  37. data/lib/doorkeeper/orm/active_record/application.rb +2 -2
  38. data/lib/doorkeeper/orm/active_record.rb +22 -0
  39. data/lib/doorkeeper/rails/helpers.rb +19 -29
  40. data/lib/doorkeeper/request/authorization_code.rb +10 -15
  41. data/lib/doorkeeper/request/client_credentials.rb +9 -15
  42. data/lib/doorkeeper/request/code.rb +7 -13
  43. data/lib/doorkeeper/request/password.rb +10 -15
  44. data/lib/doorkeeper/request/refresh_token.rb +11 -13
  45. data/lib/doorkeeper/request/strategy.rb +17 -0
  46. data/lib/doorkeeper/request/token.rb +7 -13
  47. data/lib/doorkeeper/request.rb +18 -8
  48. data/lib/doorkeeper/server.rb +2 -2
  49. data/lib/doorkeeper/version.rb +1 -1
  50. data/lib/doorkeeper.rb +0 -4
  51. data/lib/generators/doorkeeper/templates/README +0 -20
  52. data/lib/generators/doorkeeper/templates/initializer.rb +5 -3
  53. data/lib/generators/doorkeeper/templates/migration.rb +8 -0
  54. data/spec/controllers/applications_controller_spec.rb +0 -1
  55. data/spec/controllers/protected_resources_controller_spec.rb +115 -14
  56. data/spec/controllers/token_info_controller_spec.rb +0 -4
  57. data/spec/controllers/tokens_controller_spec.rb +34 -3
  58. data/spec/dummy/app/models/user.rb +2 -24
  59. data/spec/dummy/config/application.rb +2 -1
  60. data/spec/dummy/config/initializers/doorkeeper.rb +0 -2
  61. data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +24 -0
  62. data/spec/lib/config_spec.rb +20 -4
  63. data/spec/lib/models/revocable_spec.rb +2 -2
  64. data/spec/lib/oauth/authorization_code_request_spec.rb +1 -1
  65. data/spec/lib/oauth/client/credentials_spec.rb +2 -2
  66. data/spec/lib/oauth/client_credentials/creator_spec.rb +25 -1
  67. data/spec/lib/oauth/error_response_spec.rb +7 -7
  68. data/spec/lib/oauth/error_spec.rb +9 -5
  69. data/spec/lib/oauth/helpers/scope_checker_spec.rb +3 -3
  70. data/spec/lib/oauth/password_access_token_request_spec.rb +1 -1
  71. data/spec/lib/oauth/pre_authorization_spec.rb +9 -10
  72. data/spec/lib/oauth/refresh_token_request_spec.rb +26 -6
  73. data/spec/lib/oauth/scopes_spec.rb +1 -1
  74. data/spec/lib/oauth/token_request_spec.rb +6 -3
  75. data/spec/lib/request/strategy_spec.rb +53 -0
  76. data/spec/lib/server_spec.rb +4 -2
  77. data/spec/models/doorkeeper/access_grant_spec.rb +5 -5
  78. data/spec/models/doorkeeper/access_token_spec.rb +102 -5
  79. data/spec/models/doorkeeper/application_spec.rb +13 -16
  80. data/spec/requests/applications/applications_request_spec.rb +1 -1
  81. data/spec/requests/endpoints/authorization_spec.rb +2 -1
  82. data/spec/requests/endpoints/token_spec.rb +9 -9
  83. data/spec/requests/flows/authorization_code_errors_spec.rb +4 -4
  84. data/spec/requests/flows/authorization_code_spec.rb +36 -2
  85. data/spec/requests/flows/implicit_grant_spec.rb +14 -5
  86. data/spec/requests/flows/password_spec.rb +14 -20
  87. data/spec/requests/flows/refresh_token_spec.rb +15 -7
  88. data/spec/requests/flows/revoke_token_spec.rb +9 -31
  89. data/spec/requests/protected_resources/metal_spec.rb +3 -3
  90. data/spec/requests/protected_resources/private_api_spec.rb +11 -0
  91. data/spec/routing/custom_controller_routes_spec.rb +1 -2
  92. data/spec/routing/default_routes_spec.rb +1 -2
  93. data/spec/routing/scoped_routes_spec.rb +0 -1
  94. data/spec/spec_helper_integration.rb +10 -7
  95. data/spec/support/helpers/access_token_request_helper.rb +1 -1
  96. data/spec/support/helpers/authorization_request_helper.rb +1 -1
  97. data/spec/support/helpers/config_helper.rb +1 -1
  98. data/spec/support/helpers/model_helper.rb +1 -1
  99. data/spec/support/helpers/request_spec_helper.rb +1 -1
  100. data/spec/support/helpers/url_helper.rb +1 -1
  101. data/spec/support/shared/models_shared_examples.rb +1 -1
  102. data/spec/validators/redirect_uri_validator_spec.rb +5 -0
  103. metadata +127 -98
  104. data/gemfiles/Gemfile.common.rb +0 -14
  105. data/gemfiles/Gemfile.mongo_mapper.rb +0 -5
  106. data/gemfiles/Gemfile.mongoid2.rb +0 -5
  107. data/gemfiles/Gemfile.mongoid3.rb +0 -4
  108. data/gemfiles/Gemfile.mongoid4.rb +0 -5
  109. data/lib/doorkeeper/generators/doorkeeper/mongo_mapper/indexes_generator.rb +0 -12
  110. data/lib/doorkeeper/generators/doorkeeper/mongo_mapper/templates/indexes.rb +0 -3
  111. data/lib/doorkeeper/orm/mongo_mapper/access_grant.rb +0 -24
  112. data/lib/doorkeeper/orm/mongo_mapper/access_token.rb +0 -43
  113. data/lib/doorkeeper/orm/mongo_mapper/application.rb +0 -29
  114. data/lib/doorkeeper/orm/mongo_mapper.rb +0 -11
  115. data/lib/doorkeeper/orm/mongoid2/access_grant.rb +0 -22
  116. data/lib/doorkeeper/orm/mongoid2/access_token.rb +0 -37
  117. data/lib/doorkeeper/orm/mongoid2/application.rb +0 -25
  118. data/lib/doorkeeper/orm/mongoid2/concerns/scopes.rb +0 -30
  119. data/lib/doorkeeper/orm/mongoid2.rb +0 -11
  120. data/lib/doorkeeper/orm/mongoid3/access_grant.rb +0 -22
  121. data/lib/doorkeeper/orm/mongoid3/access_token.rb +0 -37
  122. data/lib/doorkeeper/orm/mongoid3/application.rb +0 -25
  123. data/lib/doorkeeper/orm/mongoid3/concerns/scopes.rb +0 -30
  124. data/lib/doorkeeper/orm/mongoid3.rb +0 -11
  125. data/lib/doorkeeper/orm/mongoid4/access_grant.rb +0 -22
  126. data/lib/doorkeeper/orm/mongoid4/access_token.rb +0 -37
  127. data/lib/doorkeeper/orm/mongoid4/application.rb +0 -25
  128. data/lib/doorkeeper/orm/mongoid4/concerns/scopes.rb +0 -17
  129. data/lib/doorkeeper/orm/mongoid4.rb +0 -11
  130. data/spec/dummy/config/mongo.yml +0 -11
  131. data/spec/dummy/config/mongoid2.yml +0 -9
  132. data/spec/dummy/config/mongoid3.yml +0 -18
  133. data/spec/dummy/config/mongoid4.yml +0 -19
  134. data/spec/support/orm/mongo_mapper.rb +0 -10
  135. data/spec/support/orm/mongoid.rb +0 -10
@@ -1,37 +0,0 @@
1
- require 'doorkeeper/orm/mongoid3/concerns/scopes'
2
-
3
- module Doorkeeper
4
- class AccessToken
5
- include Mongoid::Document
6
- include Mongoid::Timestamps
7
-
8
- include AccessTokenMixin
9
- include Models::Mongoid3::Scopes
10
-
11
- self.store_in collection: :oauth_access_tokens
12
-
13
- field :resource_owner_id, type: Moped::BSON::ObjectId
14
- field :application_id, type: Moped::BSON::ObjectId
15
- field :token, type: String
16
- field :refresh_token, type: String
17
- field :expires_in, type: Integer
18
- field :revoked_at, type: DateTime
19
-
20
- index({ token: 1 }, { unique: true })
21
- index({ refresh_token: 1 }, { unique: true, sparse: true })
22
-
23
- def self.delete_all_for(application_id, resource_owner)
24
- where(application_id: application_id,
25
- resource_owner_id: resource_owner.id).delete_all
26
- end
27
- private_class_method :delete_all_for
28
-
29
- def self.order_method
30
- :order_by
31
- end
32
-
33
- def self.created_at_desc
34
- [:created_at, :desc]
35
- end
36
- end
37
- end
@@ -1,25 +0,0 @@
1
- module Doorkeeper
2
- class Application
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
- include Models::Mongoid3::Scopes
6
-
7
- include ApplicationMixin
8
-
9
- self.store_in collection: :oauth_applications
10
-
11
- field :name, type: String
12
- field :uid, type: String
13
- field :secret, type: String
14
- field :redirect_uri, type: String
15
-
16
- index({ uid: 1 }, { unique: true })
17
-
18
- has_many :authorized_tokens, class_name: 'Doorkeeper::AccessToken'
19
-
20
- def self.authorized_for(resource_owner)
21
- ids = AccessToken.where(resource_owner_id: resource_owner.id, revoked_at: nil).map(&:application_id)
22
- find(ids)
23
- end
24
- end
25
- end
@@ -1,30 +0,0 @@
1
- module Doorkeeper
2
- module Models
3
- module Mongoid3
4
- module Scopes
5
- extend ActiveSupport::Concern
6
-
7
- # It's strange that if not define these after included will raise error
8
- # in Mongoid 2 and 3, but 4 works well see:
9
- # https://travis-ci.org/jasl/doorkeeper/builds/31586902
10
- included do
11
- def scopes
12
- OAuth::Scopes.from_string(self[:scopes])
13
- end
14
-
15
- def scopes_string
16
- self[:scopes]
17
- end
18
-
19
- def includes_scope?(*required_scopes)
20
- required_scopes.blank? || required_scopes.any? { |s| scopes.exists?(s.to_s) }
21
- end
22
-
23
- def scopes=(value)
24
- write_attribute :scopes, value if value.present?
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,11 +0,0 @@
1
- module Doorkeeper
2
- module Orm
3
- module Mongoid3
4
- def self.initialize_models!
5
- require 'doorkeeper/orm/mongoid3/access_grant'
6
- require 'doorkeeper/orm/mongoid3/access_token'
7
- require 'doorkeeper/orm/mongoid3/application'
8
- end
9
- end
10
- end
11
- end
@@ -1,22 +0,0 @@
1
- require 'doorkeeper/orm/mongoid4/concerns/scopes'
2
-
3
- module Doorkeeper
4
- class AccessGrant
5
- include Mongoid::Document
6
- include Mongoid::Timestamps
7
-
8
- include AccessGrantMixin
9
- include Models::Mongoid4::Scopes
10
-
11
- self.store_in collection: :oauth_access_grants
12
-
13
- field :resource_owner_id, type: BSON::ObjectId
14
- field :application_id, type: BSON::ObjectId
15
- field :token, type: String
16
- field :expires_in, type: Integer
17
- field :redirect_uri, type: String
18
- field :revoked_at, type: DateTime
19
-
20
- index({ token: 1 }, { unique: true })
21
- end
22
- end
@@ -1,37 +0,0 @@
1
- require 'doorkeeper/orm/mongoid4/concerns/scopes'
2
-
3
- module Doorkeeper
4
- class AccessToken
5
- include Mongoid::Document
6
- include Mongoid::Timestamps
7
-
8
- include AccessTokenMixin
9
- include Models::Mongoid4::Scopes
10
-
11
- self.store_in collection: :oauth_access_tokens
12
-
13
- field :resource_owner_id, type: BSON::ObjectId
14
- field :application_id, type: BSON::ObjectId
15
- field :token, type: String
16
- field :refresh_token, type: String
17
- field :expires_in, type: Integer
18
- field :revoked_at, type: DateTime
19
-
20
- index({ token: 1 }, { unique: true })
21
- index({ refresh_token: 1 }, { unique: true, sparse: true })
22
-
23
- def self.delete_all_for(application_id, resource_owner)
24
- where(application_id: application_id,
25
- resource_owner_id: resource_owner.id).delete_all
26
- end
27
- private_class_method :delete_all_for
28
-
29
- def self.order_method
30
- :order_by
31
- end
32
-
33
- def self.created_at_desc
34
- [:created_at, :desc]
35
- end
36
- end
37
- end
@@ -1,25 +0,0 @@
1
- module Doorkeeper
2
- class Application
3
- include Mongoid::Document
4
- include Mongoid::Timestamps
5
- include Models::Mongoid4::Scopes
6
-
7
- include ApplicationMixin
8
-
9
- self.store_in collection: :oauth_applications
10
-
11
- field :name, type: String
12
- field :uid, type: String
13
- field :secret, type: String
14
- field :redirect_uri, type: String
15
-
16
- index({ uid: 1 }, { unique: true })
17
-
18
- has_many :authorized_tokens, class_name: 'Doorkeeper::AccessToken'
19
-
20
- def self.authorized_for(resource_owner)
21
- ids = AccessToken.where(resource_owner_id: resource_owner.id, revoked_at: nil).map(&:application_id)
22
- find(ids)
23
- end
24
- end
25
- end
@@ -1,17 +0,0 @@
1
- module Doorkeeper
2
- module Models
3
- module Mongoid4
4
- module Scopes
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- field :scopes, type: String
9
- end
10
-
11
- def scopes=(value)
12
- write_attribute :scopes, value if value.present?
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,11 +0,0 @@
1
- module Doorkeeper
2
- module Orm
3
- module Mongoid4
4
- def self.initialize_models!
5
- require 'doorkeeper/orm/mongoid4/access_grant'
6
- require 'doorkeeper/orm/mongoid4/access_token'
7
- require 'doorkeeper/orm/mongoid4/application'
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- defaults: &defaults
2
- host: 127.0.0.1
3
- port: 27017
4
-
5
- development:
6
- <<: *defaults
7
- database: doorkeeper-mongomapper-development
8
-
9
- test:
10
- <<: *defaults
11
- database: doorkeeper-mongomapper-test-suite
@@ -1,9 +0,0 @@
1
- development:
2
- database: doorkeeper-development
3
- persist_in_safe_mode: true
4
- autocreate_indexes: true
5
-
6
- test:
7
- database: doorkeeper-mongoid2-test
8
- persist_in_safe_mode: true
9
- autocreate_indexes: true
@@ -1,18 +0,0 @@
1
- development:
2
- sessions:
3
- default:
4
- database: doorkeeper-mongoid3-development
5
- hosts:
6
- - localhost:27017
7
- options:
8
- consistency: :strong
9
- safe: true
10
- test:
11
- sessions:
12
- default:
13
- database: doorkeeper-mongoid3-test
14
- hosts:
15
- - localhost:27017
16
- options:
17
- consistency: :strong
18
- safe: true
@@ -1,19 +0,0 @@
1
- development:
2
- sessions:
3
- default:
4
- database: doorkeeper-mongoid4-development
5
- hosts:
6
- - localhost:27017
7
- options:
8
- write:
9
- w: 1
10
-
11
- test:
12
- sessions:
13
- default:
14
- database: doorkeeper-mongoid4-test
15
- hosts:
16
- - localhost:27017
17
- options:
18
- write:
19
- w: 1
@@ -1,10 +0,0 @@
1
- DatabaseCleaner[:mongo_mapper].strategy = :truncation
2
- DatabaseCleaner[:mongo_mapper].clean_with :truncation
3
-
4
- RSpec.configure do |config|
5
- config.before :suite do
6
- Doorkeeper::Application.create_indexes
7
- Doorkeeper::AccessGrant.create_indexes
8
- Doorkeeper::AccessToken.create_indexes
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- DatabaseCleaner[:mongoid].strategy = :truncation
2
- DatabaseCleaner[:mongoid].clean_with :truncation
3
-
4
- RSpec.configure do |config|
5
- config.before do
6
- Doorkeeper::Application.create_indexes
7
- Doorkeeper::AccessGrant.create_indexes
8
- Doorkeeper::AccessToken.create_indexes
9
- end
10
- end