doorkeeper-mongodb 5.2.2 → 5.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -27
  3. data/lib/doorkeeper/orm/concerns/mongoid/ownership.rb +1 -1
  4. data/lib/doorkeeper/orm/concerns/mongoid/resource_ownerable.rb +1 -1
  5. data/lib/doorkeeper/orm/mongoid4.rb +18 -0
  6. data/lib/doorkeeper/orm/mongoid5.rb +18 -0
  7. data/lib/doorkeeper/orm/mongoid6.rb +18 -0
  8. data/lib/doorkeeper/orm/mongoid7.rb +18 -0
  9. data/lib/doorkeeper-mongodb/mixins/mongoid/access_grant_mixin.rb +6 -6
  10. data/lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb +7 -5
  11. data/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb +6 -5
  12. data/lib/doorkeeper-mongodb/version.rb +1 -1
  13. data/spec/controllers/application_metal_controller_spec.rb +0 -0
  14. data/spec/controllers/applications_controller_spec.rb +0 -0
  15. data/spec/controllers/authorizations_controller_spec.rb +0 -0
  16. data/spec/controllers/protected_resources_controller_spec.rb +0 -0
  17. data/spec/controllers/token_info_controller_spec.rb +0 -0
  18. data/spec/controllers/tokens_controller_spec.rb +0 -0
  19. data/spec/doorkeeper/redirect_uri_validator_spec.rb +0 -0
  20. data/spec/doorkeeper/server_spec.rb +0 -0
  21. data/spec/doorkeeper/stale_records_cleaner_spec.rb +0 -0
  22. data/spec/doorkeeper/version_spec.rb +0 -0
  23. data/spec/dummy/app/assets/config/manifest.js +0 -0
  24. data/spec/dummy/app/controllers/application_controller.rb +0 -0
  25. data/spec/dummy/app/controllers/custom_authorizations_controller.rb +0 -0
  26. data/spec/dummy/app/controllers/full_protected_resources_controller.rb +0 -0
  27. data/spec/dummy/app/controllers/home_controller.rb +0 -0
  28. data/spec/dummy/app/controllers/metal_controller.rb +0 -0
  29. data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +0 -0
  30. data/spec/dummy/app/helpers/application_helper.rb +0 -0
  31. data/spec/dummy/app/models/user.rb +0 -1
  32. data/spec/dummy/app/views/home/index.html.erb +0 -0
  33. data/spec/dummy/app/views/layouts/application.html.erb +0 -0
  34. data/spec/dummy/config/application.rb +0 -0
  35. data/spec/dummy/config/boot.rb +0 -0
  36. data/spec/dummy/config/database.yml +0 -0
  37. data/spec/dummy/config/environment.rb +0 -0
  38. data/spec/dummy/config/environments/development.rb +0 -0
  39. data/spec/dummy/config/environments/production.rb +0 -0
  40. data/spec/dummy/config/environments/test.rb +0 -0
  41. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -0
  42. data/spec/dummy/config/initializers/doorkeeper.rb +0 -0
  43. data/spec/dummy/config/initializers/secret_token.rb +0 -0
  44. data/spec/dummy/config/initializers/session_store.rb +0 -0
  45. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -0
  46. data/spec/dummy/config/locales/doorkeeper.en.yml +0 -0
  47. data/spec/dummy/config/mongo.yml +2 -2
  48. data/spec/dummy/config/routes.rb +0 -0
  49. data/spec/dummy/config.ru +0 -0
  50. data/spec/dummy/db/migrate/20111122132257_create_users.rb +0 -0
  51. data/spec/dummy/db/migrate/20120312140401_add_password_to_users.rb +0 -0
  52. data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +0 -0
  53. data/spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb +0 -0
  54. data/spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb +0 -0
  55. data/spec/dummy/db/migrate/20170822064514_enable_pkce.rb +0 -0
  56. data/spec/dummy/db/migrate/20180210183654_add_confidential_to_applications.rb +0 -0
  57. data/spec/dummy/db/schema.rb +0 -0
  58. data/spec/dummy/public/404.html +0 -0
  59. data/spec/dummy/public/422.html +0 -0
  60. data/spec/dummy/public/500.html +0 -0
  61. data/spec/dummy/public/favicon.ico +0 -0
  62. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/-o/-ofn45zIfO5vx4VD6m6NXesLf6da5usA-Sbw2SVju3o.cache +0 -0
  63. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/0_/0_ouGcG_o_1zmVmBe-tdQYk594LBwVa1bumjrKtdfEw.cache +0 -0
  64. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/2X/2XMMcHbyTSRqh1GkV0xzyIETNtt-zgN6iniziShaKmQ.cache +0 -0
  65. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/4Q/4QQw-pMQ98JIj3xdcFhGBQdysdGPY9rWffRqWMmyjew.cache +0 -0
  66. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/7H/7HjRsym0tTpXFCVhWt6kteMs_-CozKVbr9s5syHm8es.cache +0 -0
  67. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8B/8BxJyv22HPFHu1se_l2J8qW1N9NzZ16UOWOy1YMSgs4.cache +0 -0
  68. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/8D/8DJG7JfPvShfLLyeSom6NZ_TcQc6QH27tJ7prEWZPfI.cache +0 -0
  69. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/9x/9xjtGv-yKjj62x9uFwBZg8pTSh9ERPAgANwNo9uwIaA.cache +0 -0
  70. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Bt/BtXO7f0PZ8DNt3TMLYM-zY7LkbWa_KgyB0v1V98M1CQ.cache +0 -0
  71. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/E0/E02f1Q2tutWumMulGCFNfqQNjvEP_hMAK_5E83eWepI.cache +0 -0
  72. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/EZ/EZGpd6pUEJZxO6uT2yIS4Fpn5KX7VDgC9VB3AaemF5Q.cache +0 -0
  73. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/FJ/FJlQpfMtpRbrM5P8A7d2FAelFKwo6GrVs2xks8z5GKU.cache +0 -0
  74. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/L8/L8mOWakJlWKr6MU85rj0V7yGFfNyIR6vE6YXtqArPGw.cache +0 -0
  75. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Lk/LklIq5hrBAPESXVUpFMwQ9L-1qTj90sPVi6U19_Xi-Q.cache +0 -0
  76. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/MB/MBWRxa9S470ee8suxVKp0jYgv6K6FQOqKGV0kPGQNMs.cache +0 -0
  77. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ma/MaK3K1AoZZ4xM5fOOifhROd73hfZJpP4yGbkGdoYtEk.cache +0 -0
  78. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/PA/PAH_jI20wRw12tngeJ-V619c30avNLDu5U9Z-9Pc5SQ.cache +0 -0
  79. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Ph/Ph7RtH_NvG2I8XpTa8mA8SBQXZDzBPVIh4CH6g7OXJ0.cache +0 -0
  80. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Pm/PmheG0PGFqDws1qgFOxOyIL-gpMof3Ar9eSRKVLYuik.cache +0 -0
  81. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Pn/PnXU_mkG2fLZFm9BwiZ03BZdBTjKuInP-cRXjHS7yJo.cache +0 -0
  82. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Qs/QsVgO6vM5Yn9oeYTYlrqtyVnK6sdVDWDa083N7zpfHw.cache +0 -0
  83. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/So/So59ksdx2dw-_A3-zFZ6Palr7fROjm7_0JDZb04temw.cache +0 -0
  84. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/Wt/WtXL_iDofLeTH_v0Yf3PM421r9b1V0g-VBvMPeu9KA0.cache +0 -0
  85. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/b6/b6QRH6ZdCc0e6bUWu4qni_kZmptaMgWciO8Jl9q6_p8.cache +0 -0
  86. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/dX/dX6FDdUIy8yBCOoaoXcjf71rX9N_bpiXGJ4Urt32NTk.cache +0 -0
  87. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/jC/jCTZ1jAldKBn4OTANBBmCKzxLrDgok1ur4meoTqlDNg.cache +0 -0
  88. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/qT/qTQIQsmS0Wbbg2JxNn9rxdI5qVOTg5SfyQdaTvr9vLo.cache +0 -0
  89. data/spec/dummy/tmp/cache/assets/sprockets/v4.0.0/yN/yNOFGOsnHmxXNMkuEAWuL1u3jlmdvrdeoTx6DDJ1in8.cache +0 -0
  90. data/spec/factories.rb +0 -0
  91. data/spec/grape/grape_integration_spec.rb +0 -0
  92. data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +0 -0
  93. data/spec/lib/config_spec.rb +0 -0
  94. data/spec/lib/doorkeeper_spec.rb +0 -0
  95. data/spec/lib/models/expirable_spec.rb +0 -0
  96. data/spec/lib/models/reusable_spec.rb +0 -0
  97. data/spec/lib/models/revocable_spec.rb +0 -0
  98. data/spec/lib/models/scopes_spec.rb +0 -0
  99. data/spec/lib/models/secret_storable_spec.rb +0 -0
  100. data/spec/lib/oauth/authorization/uri_builder_spec.rb +0 -0
  101. data/spec/lib/oauth/authorization_code_request_spec.rb +0 -0
  102. data/spec/lib/oauth/base_request_spec.rb +0 -0
  103. data/spec/lib/oauth/base_response_spec.rb +0 -0
  104. data/spec/lib/oauth/client/credentials_spec.rb +0 -0
  105. data/spec/lib/oauth/client_credentials/creator_spec.rb +0 -0
  106. data/spec/lib/oauth/client_credentials/issuer_spec.rb +0 -0
  107. data/spec/lib/oauth/client_credentials/validation_spec.rb +0 -0
  108. data/spec/lib/oauth/client_credentials_integration_spec.rb +0 -0
  109. data/spec/lib/oauth/client_credentials_request_spec.rb +0 -0
  110. data/spec/lib/oauth/client_spec.rb +0 -0
  111. data/spec/lib/oauth/code_request_spec.rb +0 -0
  112. data/spec/lib/oauth/code_response_spec.rb +0 -0
  113. data/spec/lib/oauth/error_response_spec.rb +0 -0
  114. data/spec/lib/oauth/error_spec.rb +0 -0
  115. data/spec/lib/oauth/forbidden_token_response_spec.rb +0 -0
  116. data/spec/lib/oauth/helpers/scope_checker_spec.rb +0 -0
  117. data/spec/lib/oauth/helpers/unique_token_spec.rb +0 -0
  118. data/spec/lib/oauth/helpers/uri_checker_spec.rb +0 -0
  119. data/spec/lib/oauth/invalid_request_response_spec.rb +0 -0
  120. data/spec/lib/oauth/invalid_token_response_spec.rb +0 -0
  121. data/spec/lib/oauth/password_access_token_request_spec.rb +0 -0
  122. data/spec/lib/oauth/pre_authorization_spec.rb +0 -0
  123. data/spec/lib/oauth/refresh_token_request_spec.rb +0 -0
  124. data/spec/lib/oauth/scopes_spec.rb +0 -0
  125. data/spec/lib/oauth/token_request_spec.rb +0 -0
  126. data/spec/lib/oauth/token_response_spec.rb +0 -0
  127. data/spec/lib/oauth/token_spec.rb +0 -0
  128. data/spec/lib/option_spec.rb +0 -0
  129. data/spec/lib/request/strategy_spec.rb +0 -0
  130. data/spec/lib/secret_storing/base_spec.rb +0 -0
  131. data/spec/lib/secret_storing/bcrypt_spec.rb +0 -0
  132. data/spec/lib/secret_storing/plain_spec.rb +0 -0
  133. data/spec/lib/secret_storing/sha256_hash_spec.rb +0 -0
  134. data/spec/models/doorkeeper/access_grant_spec.rb +0 -0
  135. data/spec/models/doorkeeper/access_token_spec.rb +0 -0
  136. data/spec/models/doorkeeper/application_spec.rb +0 -0
  137. data/spec/requests/applications/applications_request_spec.rb +0 -0
  138. data/spec/requests/applications/authorized_applications_spec.rb +0 -0
  139. data/spec/requests/endpoints/authorization_spec.rb +0 -0
  140. data/spec/requests/endpoints/token_spec.rb +0 -0
  141. data/spec/requests/flows/authorization_code_errors_spec.rb +0 -0
  142. data/spec/requests/flows/authorization_code_spec.rb +0 -0
  143. data/spec/requests/flows/client_credentials_spec.rb +0 -0
  144. data/spec/requests/flows/implicit_grant_errors_spec.rb +0 -0
  145. data/spec/requests/flows/implicit_grant_spec.rb +0 -0
  146. data/spec/requests/flows/password_spec.rb +0 -0
  147. data/spec/requests/flows/refresh_token_spec.rb +0 -0
  148. data/spec/requests/flows/revoke_token_spec.rb +0 -0
  149. data/spec/requests/flows/skip_authorization_spec.rb +0 -0
  150. data/spec/requests/protected_resources/metal_spec.rb +0 -0
  151. data/spec/requests/protected_resources/private_api_spec.rb +0 -0
  152. data/spec/routing/custom_controller_routes_spec.rb +0 -0
  153. data/spec/routing/default_routes_spec.rb +0 -0
  154. data/spec/routing/scoped_routes_spec.rb +0 -0
  155. data/spec/spec_helper.rb +0 -0
  156. data/spec/spec_helper_integration.rb +0 -0
  157. data/spec/support/dependencies/factory_bot.rb +0 -0
  158. data/spec/support/doorkeeper_rspec.rb +0 -0
  159. data/spec/support/helpers/access_token_request_helper.rb +0 -0
  160. data/spec/support/helpers/authorization_request_helper.rb +0 -0
  161. data/spec/support/helpers/config_helper.rb +0 -0
  162. data/spec/support/helpers/model_helper.rb +0 -0
  163. data/spec/support/helpers/request_spec_helper.rb +0 -0
  164. data/spec/support/helpers/url_helper.rb +0 -0
  165. data/spec/support/orm/active_record.rb +0 -0
  166. data/spec/support/orm/mongoid4.rb +1 -1
  167. data/spec/support/orm/mongoid5.rb +1 -1
  168. data/spec/support/orm/mongoid6.rb +1 -1
  169. data/spec/support/orm/mongoid7.rb +1 -1
  170. data/spec/support/shared/controllers_shared_context.rb +0 -0
  171. data/spec/support/shared/hashing_shared_context.rb +0 -0
  172. data/spec/support/shared/models_shared_examples.rb +0 -0
  173. metadata +148 -164
  174. data/spec/dummy/log/test.log +0 -6144
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ca032c54f4098b2652bde530b4cc204b124d76e5d066ddd04d302302dd854b7
4
- data.tar.gz: 24fe8d9ad134bcd6eba2b8f9ae8e76b956d0e5eabe527ecece33c8ed51211049
3
+ metadata.gz: f2798483ff1a989a1b8cefc2e94771e735c08f52879675c69b1808a912e2f730
4
+ data.tar.gz: ee24b6384a5378b6353a0a9006648feea656ab9d2c17d5fd596f6bf8637cadc9
5
5
  SHA512:
6
- metadata.gz: 3ff745bcac86d2cc5c10d8e7548c487fce3626e9570da0f66e1fc47de25bf5f5b323dd650512b14b4e248567e278a66707a1d2af52e0e15f5d9f14af9eda68e8
7
- data.tar.gz: 7cdb26333c287aa9731561a4b9e59dd9115a1205be92e6e1a4e2686bcfb5d5d67b77609ec3aeff94a00dc2f96decce40ce7f55d748cc461c709b35a4fa6cedee
6
+ metadata.gz: 260955b7a8b92403cf62913ee6eea0cd230b7f19cb030d8432a04916c821e392609641fc13f080e097703a1c96a8139df6e1800034e499b342c53940fdf40054
7
+ data.tar.gz: 3c79d4fdfbc2968716d2940c5f732a3476950cb5bcbc4120b040538fbd246299e398069a81fc5b2a001277af0fe2d4e48dcd08d0a7fc9a972de2e3e0ac82817d
data/README.md CHANGED
@@ -9,26 +9,15 @@ of doorkeeper-mongodb you are using in: https://github.com/doorkeeper-gem/doorke
9
9
 
10
10
  ## Installation
11
11
 
12
- `doorkeeper-mongodb` provides [Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper) support to [Mongoid](https://github.com/mongodb/mongoid)
13
- (2, 3, 4 and 5 for doorkeeper-mongodb `3.0` and 4, 5, 6 and 7 for version `4.0` and higher). To start using it, add
14
- to your Gemfile:
12
+ `doorkeeper-mongodb` provides [Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper) support
13
+ for [Mongoid](https://github.com/mongodb/mongoid) versions 6 and later. Earlier versions of Mongoid
14
+ are supported on earlier versions of `doorkeeper-mongodb`.
15
15
 
16
- ``` ruby
17
- # For Doorkeeper >= 5.2
18
- gem 'doorkeeper', '~> 5.2'
19
- gem 'doorkeeper-mongodb', '~> 5.2'
16
+ To start using it, add both `doorkeeper` and `doorkeeper-mongodb` to your Gemfile:
20
17
 
21
- # For Doorkeeper >= 5.0
22
- gem 'doorkeeper', '~> 5.0'
23
- gem 'doorkeeper-mongodb', '~> 5.0'
24
-
25
- # For Doorkeeper >= 4.4 && < 5.0
26
- gem 'doorkeeper', '~> 4.4'
27
- gem 'doorkeeper-mongodb', '~> 4.2'
28
-
29
- # For Doorkeeper < 4.4
30
- gem 'doorkeeper', '~> 4.3'
31
- gem 'doorkeeper-mongodb', '~> 4.1.0'
18
+ ```ruby
19
+ gem 'doorkeeper'
20
+ gem 'doorkeeper-mongodb'
32
21
 
33
22
  # or if you want to use cutting edge version:
34
23
  # gem 'doorkeeper-mongodb', github: 'doorkeeper-gem/doorkeeper-mongodb'
@@ -36,7 +25,9 @@ gem 'doorkeeper-mongodb', '~> 4.1.0'
36
25
 
37
26
  Run [doorkeeper’s installation generator]:
38
27
 
39
- rails generate doorkeeper:install
28
+ ```bash
29
+ $ rails generate doorkeeper:install
30
+ ```
40
31
 
41
32
  [doorkeeper’s installation generator]: https://github.com/doorkeeper-gem/doorkeeper#installation
42
33
 
@@ -45,20 +36,14 @@ This will install the doorkeeper initializer into
45
36
 
46
37
  Set the ORM configuration:
47
38
 
48
- ``` ruby
39
+ ```ruby
49
40
  Doorkeeper.configure do
50
41
  orm :mongoid7 # or any other version of mongoid
51
42
  end
52
43
  ```
53
44
 
54
- ## MongoMapper
55
-
56
- **NOTE**: Support of MongoMapper gem was dropped.
57
-
58
45
  ## Indexes
59
46
 
60
- ### Mongoid
61
-
62
47
  Make sure you create indexes for doorkeeper models. You can do this either by
63
48
  running `rake db:mongoid:create_indexes` or (if you're using Mongoid 2) by
64
49
  adding `autocreate_indexes: true` to your `config/mongoid.yml`
@@ -71,7 +56,7 @@ variables defined in `.travis.yml` file.
71
56
 
72
57
  To run locally, you need to choose a gemfile, with a command similar to:
73
58
 
74
- ```
59
+ ```bash
75
60
  $ export RAILS=5.1
76
61
  $ export BUNDLE_GEMFILE=$PWD/gemfiles/Gemfile.mongoid6.rb
77
62
  ```
@@ -13,7 +13,7 @@ module Doorkeeper
13
13
  belongs_to_options[:optional] = true if ::Mongoid::VERSION[0].to_i >= 6
14
14
 
15
15
  belongs_to :owner, belongs_to_options
16
- validates :owner, presence: true, if: :validate_owner?
16
+ validates_presence_of :owner, if: :validate_owner?
17
17
  end
18
18
 
19
19
  def validate_owner?
@@ -19,7 +19,7 @@ module Doorkeeper
19
19
  #
20
20
  def by_resource_owner(resource_owner)
21
21
  if DoorkeeperMongodb.doorkeeper_version?(5, 3) &&
22
- Doorkeeper.configuration.try(:polymorphic_resource_owner?)
22
+ Doorkeeper.configuration.try(:polymorphic_resource_owner?)
23
23
  where(resource_owner: resource_owner)
24
24
  else
25
25
  where(resource_owner_id: resource_owner_id_for(resource_owner))
@@ -5,7 +5,22 @@ require "active_support/lazy_load_hooks"
5
5
  module Doorkeeper
6
6
  module Orm
7
7
  module Mongoid4
8
+ def self.run_hooks
9
+ lazy_load do
10
+ require "doorkeeper/orm/mongoid4/access_grant"
11
+ require "doorkeeper/orm/mongoid4/access_token"
12
+ require "doorkeeper/orm/mongoid4/application"
13
+ require "doorkeeper/orm/mongoid4/stale_records_cleaner"
14
+ require "doorkeeper/orm/concerns/mongoid/ownership"
15
+ Doorkeeper::Application.include Doorkeeper::Orm::Concerns::Mongoid::Ownership
16
+ end
17
+ @initialized_hooks = true
18
+ end
19
+
20
+ # @deprecated
8
21
  def self.initialize_models!
22
+ return if @initialized_hooks
23
+
9
24
  lazy_load do
10
25
  require "doorkeeper/orm/mongoid4/access_grant"
11
26
  require "doorkeeper/orm/mongoid4/access_token"
@@ -14,7 +29,10 @@ module Doorkeeper
14
29
  end
15
30
  end
16
31
 
32
+ # @deprecated
17
33
  def self.initialize_application_owner!
34
+ return if @initialized_hooks
35
+
18
36
  lazy_load do
19
37
  require "doorkeeper/orm/concerns/mongoid/ownership"
20
38
 
@@ -5,7 +5,22 @@ require "active_support/lazy_load_hooks"
5
5
  module Doorkeeper
6
6
  module Orm
7
7
  module Mongoid5
8
+ def self.run_hooks
9
+ lazy_load do
10
+ require "doorkeeper/orm/mongoid5/access_grant"
11
+ require "doorkeeper/orm/mongoid5/access_token"
12
+ require "doorkeeper/orm/mongoid5/application"
13
+ require "doorkeeper/orm/mongoid5/stale_records_cleaner"
14
+ require "doorkeeper/orm/concerns/mongoid/ownership"
15
+ Doorkeeper::Application.include Doorkeeper::Orm::Concerns::Mongoid::Ownership
16
+ end
17
+ @initialized_hooks = true
18
+ end
19
+
20
+ # @deprecated
8
21
  def self.initialize_models!
22
+ return if @initialized_hooks
23
+
9
24
  lazy_load do
10
25
  require "doorkeeper/orm/mongoid5/access_grant"
11
26
  require "doorkeeper/orm/mongoid5/access_token"
@@ -14,7 +29,10 @@ module Doorkeeper
14
29
  end
15
30
  end
16
31
 
32
+ # @deprecated
17
33
  def self.initialize_application_owner!
34
+ return if @initialized_hooks
35
+
18
36
  lazy_load do
19
37
  require "doorkeeper/orm/concerns/mongoid/ownership"
20
38
 
@@ -5,7 +5,22 @@ require "active_support/lazy_load_hooks"
5
5
  module Doorkeeper
6
6
  module Orm
7
7
  module Mongoid6
8
+ def self.run_hooks
9
+ lazy_load do
10
+ require "doorkeeper/orm/mongoid6/access_grant"
11
+ require "doorkeeper/orm/mongoid6/access_token"
12
+ require "doorkeeper/orm/mongoid6/application"
13
+ require "doorkeeper/orm/mongoid6/stale_records_cleaner"
14
+ require "doorkeeper/orm/concerns/mongoid/ownership"
15
+ Doorkeeper::Application.include Doorkeeper::Orm::Concerns::Mongoid::Ownership
16
+ end
17
+ @initialized_hooks = true
18
+ end
19
+
20
+ # @deprecated
8
21
  def self.initialize_models!
22
+ return if @initialized_hooks
23
+
9
24
  lazy_load do
10
25
  require "doorkeeper/orm/mongoid6/access_grant"
11
26
  require "doorkeeper/orm/mongoid6/access_token"
@@ -14,7 +29,10 @@ module Doorkeeper
14
29
  end
15
30
  end
16
31
 
32
+ # @deprecated
17
33
  def self.initialize_application_owner!
34
+ return if @initialized_hooks
35
+
18
36
  lazy_load do
19
37
  require "doorkeeper/orm/concerns/mongoid/ownership"
20
38
 
@@ -5,7 +5,22 @@ require "active_support/lazy_load_hooks"
5
5
  module Doorkeeper
6
6
  module Orm
7
7
  module Mongoid7
8
+ def self.run_hooks
9
+ lazy_load do
10
+ require "doorkeeper/orm/mongoid7/access_grant"
11
+ require "doorkeeper/orm/mongoid7/access_token"
12
+ require "doorkeeper/orm/mongoid7/application"
13
+ require "doorkeeper/orm/mongoid7/stale_records_cleaner"
14
+ require "doorkeeper/orm/concerns/mongoid/ownership"
15
+ Doorkeeper::Application.include Doorkeeper::Orm::Concerns::Mongoid::Ownership
16
+ end
17
+ @initialized_hooks = true
18
+ end
19
+
20
+ # @deprecated
8
21
  def self.initialize_models!
22
+ return if @initialized_hooks
23
+
9
24
  lazy_load do
10
25
  require "doorkeeper/orm/mongoid7/access_grant"
11
26
  require "doorkeeper/orm/mongoid7/access_token"
@@ -14,7 +29,10 @@ module Doorkeeper
14
29
  end
15
30
  end
16
31
 
32
+ # @deprecated
17
33
  def self.initialize_application_owner!
34
+ return if @initialized_hooks
35
+
18
36
  lazy_load do
19
37
  require "doorkeeper/orm/concerns/mongoid/ownership"
20
38
 
@@ -36,8 +36,9 @@ module DoorkeeperMongodb
36
36
  belongs_to :resource_owner, polymorphic: true
37
37
  end
38
38
 
39
- validates :resource_owner_id, :application_id, :token, :expires_in, :redirect_uri, presence: true
40
- validates :token, uniqueness: true
39
+ validates_presence_of :resource_owner_id, :application_id, :token,
40
+ :expires_in, :redirect_uri
41
+ validates_uniqueness_of :token
41
42
 
42
43
  before_validation :generate_token, on: :create
43
44
  end
@@ -123,15 +124,14 @@ module DoorkeeperMongodb
123
124
 
124
125
  # @param code_verifier [#to_s] a one time use value (any object that responds to `#to_s`)
125
126
  #
126
- # @return [#to_s] An encoded code challenge based on the provided verifier suitable for PKCE validation
127
+ # @return [#to_s] An encoded code challenge based on the provided verifier suitable
128
+ # for PKCE validation
127
129
  def generate_code_challenge(code_verifier)
128
130
  padded_result = Base64.urlsafe_encode64(Digest::SHA256.digest(code_verifier))
129
131
  padded_result.split("=")[0] # Remove any trailing '='
130
132
  end
131
133
 
132
- def pkce_supported?
133
- new.pkce_supported?
134
- end
134
+ delegate :pkce_supported?, to: :new
135
135
 
136
136
  ##
137
137
  # Determines the secret storing transformer
@@ -41,8 +41,9 @@ module DoorkeeperMongodb
41
41
  belongs_to :resource_owner, opts
42
42
  end
43
43
 
44
- validates :token, presence: true, uniqueness: true
45
- validates :refresh_token, uniqueness: true, if: :use_refresh_token?
44
+ validates_presence_of :token
45
+ validates_uniqueness_of :token
46
+ validates_uniqueness_of :refresh_token, if: :use_refresh_token?
46
47
 
47
48
  # @attr_writer [Boolean, nil] use_refresh_token
48
49
  # indicates the possibility of using refresh token
@@ -368,10 +369,10 @@ module DoorkeeperMongodb
368
369
  # and clears `:previous_refresh_token` attribute.
369
370
  #
370
371
  def revoke_previous_refresh_token!
371
- return unless self.class.refresh_token_revoked_on_use?
372
+ return if !self.class.refresh_token_revoked_on_use? || previous_refresh_token.blank?
372
373
 
373
374
  old_refresh_token&.revoke
374
- update(previous_refresh_token: "")
375
+ update_attribute(:previous_refresh_token, "")
375
376
  end
376
377
 
377
378
  private
@@ -419,7 +420,8 @@ module DoorkeeperMongodb
419
420
 
420
421
  return generator if generator.respond_to?(:generate)
421
422
 
422
- raise Doorkeeper::Errors::UnableToGenerateToken, "#{generator} does not respond to `.generate`."
423
+ raise Doorkeeper::Errors::UnableToGenerateToken,
424
+ "#{generator} does not respond to `.generate`."
423
425
  rescue NameError
424
426
  raise Doorkeeper::Errors::TokenGeneratorNotFound, "#{generator_name} not found"
425
427
  end
@@ -36,8 +36,8 @@ module DoorkeeperMongodb
36
36
  has_many :access_grants, has_many_options.merge(class_name: access_grants_class_name)
37
37
  has_many :access_tokens, has_many_options.merge(class_name: access_tokens_class_name)
38
38
 
39
- validates :name, :secret, :uid, presence: true
40
- validates :uid, uniqueness: true
39
+ validates_presence_of :name, :secret, :uid
40
+ validates_uniqueness_of :uid
41
41
 
42
42
  # Before Doorkeeper 5.2.3
43
43
  if defined?(::RedirectUriValidator)
@@ -46,7 +46,7 @@ module DoorkeeperMongodb
46
46
  validates :redirect_uri, "doorkeeper/redirect_uri": true
47
47
  end
48
48
 
49
- validates :confidential, inclusion: { in: [true, false] }
49
+ validates_inclusion_of :confidential, in: [true, false]
50
50
 
51
51
  validate :scopes_match_configured, if: :enforce_scopes?
52
52
 
@@ -242,7 +242,7 @@ module DoorkeeperMongodb
242
242
  end
243
243
 
244
244
  def generate_secret
245
- return unless secret.blank?
245
+ return if secret.present?
246
246
 
247
247
  @raw_secret = UniqueToken.generate
248
248
  secret_strategy.store_secret(self, :secret, @raw_secret)
@@ -250,7 +250,8 @@ module DoorkeeperMongodb
250
250
 
251
251
  def scopes_match_configured
252
252
  if scopes.present? &&
253
- !ScopeChecker.valid?(scope_str: scopes.to_s, server_scopes: Doorkeeper.configuration.scopes)
253
+ !ScopeChecker.valid?(scope_str: scopes.to_s,
254
+ server_scopes: Doorkeeper.configuration.scopes,)
254
255
  errors.add(:scopes, :not_match_configured)
255
256
  end
256
257
  end
@@ -9,7 +9,7 @@ module DoorkeeperMongodb
9
9
  # Semver
10
10
  MAJOR = 5
11
11
  MINOR = 2
12
- TINY = 2
12
+ TINY = 3
13
13
 
14
14
  # Full version number
15
15
  STRING = [MAJOR, MINOR, TINY].compact.join(".")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # [NOTE] MongoMapper support was dropped, so now only Mongoid
4
3
  class User
5
4
  include Mongoid::Document
6
5
  include Mongoid::Timestamps
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -4,8 +4,8 @@ defaults: &defaults
4
4
 
5
5
  development:
6
6
  <<: *defaults
7
- database: doorkeeper-mongomapper-development
7
+ database: doorkeeper-mongoid-development
8
8
 
9
9
  test:
10
10
  <<: *defaults
11
- database: doorkeeper-mongomapper-test-suite
11
+ database: doorkeeper-mongoid-test
File without changes
data/spec/dummy/config.ru CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/spec/factories.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes