doorkeeper-mongodb 5.2.3 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2798483ff1a989a1b8cefc2e94771e735c08f52879675c69b1808a912e2f730
4
- data.tar.gz: ee24b6384a5378b6353a0a9006648feea656ab9d2c17d5fd596f6bf8637cadc9
3
+ metadata.gz: bdae346c1e6046eb82cbef6ae0156ba60f8c0317b8135038cc26abe6db11995a
4
+ data.tar.gz: d8ce523eb6a7326cd694ece68b1151268c2e93ff9e06162a52fd075046291d08
5
5
  SHA512:
6
- metadata.gz: 260955b7a8b92403cf62913ee6eea0cd230b7f19cb030d8432a04916c821e392609641fc13f080e097703a1c96a8139df6e1800034e499b342c53940fdf40054
7
- data.tar.gz: 3c79d4fdfbc2968716d2940c5f732a3476950cb5bcbc4120b040538fbd246299e398069a81fc5b2a001277af0fe2d4e48dcd08d0a7fc9a972de2e3e0ac82817d
6
+ metadata.gz: a839777bae4797e6355e3cc548d674ed2d3f6c87de6678b2e99b45ac243c59cdd2043fbbe557134aa4a7207bdac9cb5e07ceff6f7fa5718a9bc39f8c1d3e800e
7
+ data.tar.gz: b0ea7a54f37369afbfa5b94bc04327f61642154dadc9f937a9faef1a4859170a42fdfd923c52982117a2793a0c9a3bfd03d399d66781ffc74ac980042bb78932
data/README.md CHANGED
@@ -38,7 +38,7 @@ Set the ORM configuration:
38
38
 
39
39
  ```ruby
40
40
  Doorkeeper.configure do
41
- orm :mongoid7 # or any other version of mongoid
41
+ orm :mongoid8 # or any other version of mongoid
42
42
  end
43
43
  ```
44
44
 
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Doorkeeper
4
+ class AccessGrant
5
+ include Mongoid::Document
6
+ include Mongoid::Timestamps
7
+
8
+ include DoorkeeperMongodb::Compatible
9
+
10
+ include DoorkeeperMongodb::Shared::Scopes
11
+ include DoorkeeperMongodb::Mixins::Mongoid::AccessGrantMixin
12
+
13
+ store_in collection: :oauth_access_grants
14
+
15
+ field :resource_owner_id, type: BSON::ObjectId
16
+ field :resource_owner_type, type: String
17
+ field :token, type: String
18
+ field :expires_in, type: Integer
19
+ field :redirect_uri, type: String
20
+ field :revoked_at, type: DateTime
21
+ field :code_challenge, type: String
22
+ field :code_challenge_method, type: String
23
+
24
+ index({ token: 1 }, unique: true)
25
+ end
26
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Doorkeeper
4
+ class AccessToken
5
+ include Mongoid::Document
6
+ include Mongoid::Timestamps
7
+
8
+ include DoorkeeperMongodb::Compatible
9
+
10
+ include DoorkeeperMongodb::Shared::Scopes
11
+ include DoorkeeperMongodb::Mixins::Mongoid::AccessTokenMixin
12
+
13
+ store_in collection: :oauth_access_tokens
14
+
15
+ field :resource_owner_id, type: BSON::ObjectId
16
+ field :resource_owner_type, type: String
17
+ field :token, type: String
18
+ field :refresh_token, type: String
19
+ field :previous_refresh_token, type: String
20
+ field :expires_in, type: Integer
21
+ field :revoked_at, type: DateTime
22
+
23
+ index({ token: 1 }, unique: true)
24
+ index({ refresh_token: 1 }, unique: true, sparse: true)
25
+
26
+ def self.order_method
27
+ :order_by
28
+ end
29
+
30
+ def self.refresh_token_revoked_on_use?
31
+ fields.collect { |field| field[0] }.include?("previous_refresh_token")
32
+ end
33
+
34
+ def self.created_at_desc
35
+ %i[created_at desc]
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Doorkeeper
4
+ class Application
5
+ include Mongoid::Document
6
+ include Mongoid::Timestamps
7
+
8
+ include DoorkeeperMongodb::Compatible
9
+
10
+ include DoorkeeperMongodb::Shared::Scopes
11
+ include DoorkeeperMongodb::Mixins::Mongoid::ApplicationMixin
12
+
13
+ store_in collection: :oauth_applications
14
+
15
+ field :name, type: String
16
+ field :uid, type: String
17
+ field :secret, type: String
18
+ field :redirect_uri, type: String
19
+ field :confidential, type: Boolean, default: true
20
+
21
+ index({ uid: 1 }, unique: true)
22
+
23
+ has_many_opts = {
24
+ class_name: "Doorkeeper::AccessToken",
25
+ }
26
+
27
+ # Doorkeeper 5.3 has custom classes for defining OAuth roles
28
+ if DoorkeeperMongodb.doorkeeper_version?(5, 3)
29
+ has_many_opts[:class_name] = Doorkeeper.config.access_token_class
30
+ end
31
+
32
+ has_many :authorized_tokens, has_many_opts
33
+
34
+ def self.authorized_for(resource_owner)
35
+ ids = AccessToken.where(
36
+ resource_owner_id: resource_owner.id,
37
+ revoked_at: nil,
38
+ ).map(&:application_id)
39
+
40
+ find(ids)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Doorkeeper
4
+ module Orm
5
+ module Mongoid8
6
+ class StaleRecordsCleaner
7
+ include DoorkeeperMongodb::Mixins::Mongoid::StaleRecordsCleanerMixin
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/lazy_load_hooks"
4
+
5
+ module Doorkeeper
6
+ module Orm
7
+ module Mongoid8
8
+ def self.run_hooks
9
+ lazy_load do
10
+ require "doorkeeper/orm/mongoid8/access_grant"
11
+ require "doorkeeper/orm/mongoid8/access_token"
12
+ require "doorkeeper/orm/mongoid8/application"
13
+ require "doorkeeper/orm/mongoid8/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
21
+ def self.initialize_models!
22
+ return if @initialized_hooks
23
+
24
+ lazy_load do
25
+ require "doorkeeper/orm/mongoid8/access_grant"
26
+ require "doorkeeper/orm/mongoid8/access_token"
27
+ require "doorkeeper/orm/mongoid8/application"
28
+ require "doorkeeper/orm/mongoid8/stale_records_cleaner"
29
+ end
30
+ end
31
+
32
+ # @deprecated
33
+ def self.initialize_application_owner!
34
+ return if @initialized_hooks
35
+
36
+ lazy_load do
37
+ require "doorkeeper/orm/concerns/mongoid/ownership"
38
+
39
+ Doorkeeper::Application.include Doorkeeper::Orm::Concerns::Mongoid::Ownership
40
+ end
41
+ end
42
+
43
+ def self.check_requirements!(_config); end
44
+
45
+ def self.lazy_load(&block)
46
+ ActiveSupport.on_load(:mongoid, {}, &block)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -8,8 +8,8 @@ module DoorkeeperMongodb
8
8
  module VERSION
9
9
  # Semver
10
10
  MAJOR = 5
11
- MINOR = 2
12
- TINY = 3
11
+ MINOR = 3
12
+ TINY = 0
13
13
 
14
14
  # Full version number
15
15
  STRING = [MAJOR, MINOR, TINY].compact.join(".")
@@ -28,6 +28,7 @@ require "doorkeeper/orm/mongoid4"
28
28
  require "doorkeeper/orm/mongoid5"
29
29
  require "doorkeeper/orm/mongoid6"
30
30
  require "doorkeeper/orm/mongoid7"
31
+ require "doorkeeper/orm/mongoid8"
31
32
 
32
33
  module DoorkeeperMongodb
33
34
  def load_locales
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doorkeeper-mongodb
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.3
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-11-21 00:00:00.000000000 Z
12
+ date: 2023-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: doorkeeper
@@ -158,6 +158,11 @@ files:
158
158
  - lib/doorkeeper/orm/mongoid7/access_token.rb
159
159
  - lib/doorkeeper/orm/mongoid7/application.rb
160
160
  - lib/doorkeeper/orm/mongoid7/stale_records_cleaner.rb
161
+ - lib/doorkeeper/orm/mongoid8.rb
162
+ - lib/doorkeeper/orm/mongoid8/access_grant.rb
163
+ - lib/doorkeeper/orm/mongoid8/access_token.rb
164
+ - lib/doorkeeper/orm/mongoid8/application.rb
165
+ - lib/doorkeeper/orm/mongoid8/stale_records_cleaner.rb
161
166
  - spec/controllers/application_metal_controller_spec.rb
162
167
  - spec/controllers/applications_controller_spec.rb
163
168
  - spec/controllers/authorizations_controller_spec.rb
@@ -344,7 +349,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
344
349
  - !ruby/object:Gem::Version
345
350
  version: '0'
346
351
  requirements: []
347
- rubygems_version: 3.0.8
352
+ rubygems_version: 3.1.6
348
353
  signing_key:
349
354
  specification_version: 4
350
355
  summary: Doorkeeper Mongoid ORM extension