doorkeeper-mongodb 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/doorkeeper/orm/mongoid9/access_grant.rb +26 -0
- data/lib/doorkeeper/orm/mongoid9/access_token.rb +38 -0
- data/lib/doorkeeper/orm/mongoid9/application.rb +43 -0
- data/lib/doorkeeper/orm/mongoid9/stale_records_cleaner.rb +11 -0
- data/lib/doorkeeper/orm/mongoid9.rb +50 -0
- data/lib/doorkeeper-mongodb/mixins/mongoid/access_grant_mixin.rb +6 -2
- data/lib/doorkeeper-mongodb/mixins/mongoid/access_token_mixin.rb +1 -1
- data/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb +2 -2
- data/lib/doorkeeper-mongodb/version.rb +1 -1
- data/lib/doorkeeper-mongodb.rb +1 -0
- data/spec/dummy/config/mongoid8.yml +1 -1
- data/spec/dummy/config/mongoid9.yml +19 -0
- data/spec/support/orm/mongoid9.rb +6 -0
- metadata +11 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 31397e2cb87670cde0c3c5eb8bd487a864e14c11dfcedc868c5fd1e2b4683e87
         | 
| 4 | 
            +
              data.tar.gz: 534a2ce1dd42bc361839b31e96a54491b2142b1366a46590a719ee071b835b36
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2debfbe47ca1743bae09ae241245438a56454b4850cf6d833c337fe8e1e79a21e396fbaaafd52ec7eb14c49a7342c573f45d4e2feac4ca8ebdb2cddb285dfadb
         | 
| 7 | 
            +
              data.tar.gz: 5a74a5c8666980b4af1c88427ab692d2aecb049fe918605558223eee48a3b9df1403ab13a3b3448c8645804ec46c67966f0e07e0925bb99ce92fb9ca1cf4830d
         | 
    
        data/README.md
    CHANGED
    
    
| @@ -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,50 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require "active_support/lazy_load_hooks"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Doorkeeper
         | 
| 6 | 
            +
              module Orm
         | 
| 7 | 
            +
                module Mongoid9
         | 
| 8 | 
            +
                  def self.run_hooks
         | 
| 9 | 
            +
                    lazy_load do
         | 
| 10 | 
            +
                      require "doorkeeper/orm/mongoid9/access_grant"
         | 
| 11 | 
            +
                      require "doorkeeper/orm/mongoid9/access_token"
         | 
| 12 | 
            +
                      require "doorkeeper/orm/mongoid9/application"
         | 
| 13 | 
            +
                      require "doorkeeper/orm/mongoid9/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/mongoid9/access_grant"
         | 
| 26 | 
            +
                      require "doorkeeper/orm/mongoid9/access_token"
         | 
| 27 | 
            +
                      require "doorkeeper/orm/mongoid9/application"
         | 
| 28 | 
            +
                      require "doorkeeper/orm/mongoid9/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
         | 
| @@ -27,13 +27,17 @@ module DoorkeeperMongodb | |
| 27 27 | 
             
                        belongs_to_opts[:class_name] = Doorkeeper.config.application_class
         | 
| 28 28 | 
             
                      end
         | 
| 29 29 |  | 
| 30 | 
            -
                      # optional associations added in Mongoid 6
         | 
| 30 | 
            +
                      # optional associations added in Mongoid 6+
         | 
| 31 31 | 
             
                      belongs_to_opts[:optional] = true if ::Mongoid::VERSION[0].to_i >= 6
         | 
| 32 32 |  | 
| 33 33 | 
             
                      belongs_to :application, belongs_to_opts
         | 
| 34 34 |  | 
| 35 35 | 
             
                      if Doorkeeper.configuration.try(:polymorphic_resource_owner?)
         | 
| 36 | 
            -
                         | 
| 36 | 
            +
                        opts = { polymorphic: true }
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                        opts[:optional] = true if ::Mongoid::VERSION[0].to_i >= 6
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                        belongs_to :resource_owner, opts
         | 
| 37 41 | 
             
                      end
         | 
| 38 42 |  | 
| 39 43 | 
             
                      validates_presence_of :resource_owner_id, :application_id, :token,
         | 
| @@ -28,7 +28,7 @@ module DoorkeeperMongodb | |
| 28 28 | 
             
                        belongs_to_opts[:class_name] = Doorkeeper.config.application_class
         | 
| 29 29 | 
             
                      end
         | 
| 30 30 |  | 
| 31 | 
            -
                      # optional associations added in Mongoid 6
         | 
| 31 | 
            +
                      # optional associations added in Mongoid 6+
         | 
| 32 32 | 
             
                      belongs_to_opts[:optional] = true if ::Mongoid::VERSION[0].to_i >= 6
         | 
| 33 33 |  | 
| 34 34 | 
             
                      belongs_to :application, belongs_to_opts
         | 
| @@ -14,10 +14,10 @@ module DoorkeeperMongodb | |
| 14 14 | 
             
                    included do
         | 
| 15 15 | 
             
                      has_many_options = {
         | 
| 16 16 | 
             
                        dependent: :delete,
         | 
| 17 | 
            -
             | 
| 17 | 
            +
                        inverse_of: :application,
         | 
| 18 18 | 
             
                      }
         | 
| 19 19 |  | 
| 20 | 
            -
                      # Mongoid7  | 
| 20 | 
            +
                      # Mongoid7+ uses :delete_all instead of :delete
         | 
| 21 21 | 
             
                      has_many_options[:dependent] = :delete_all if ::Mongoid::VERSION[0].to_i >= 7
         | 
| 22 22 |  | 
| 23 23 | 
             
                      # Doorkeeper 5.3 has custom classes for defining OAuth roles
         | 
    
        data/lib/doorkeeper-mongodb.rb
    CHANGED
    
    
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            development:
         | 
| 2 | 
            +
              clients:
         | 
| 3 | 
            +
                default:
         | 
| 4 | 
            +
                  database: doorkeeper-mongoid9-development
         | 
| 5 | 
            +
                  hosts:
         | 
| 6 | 
            +
                    - localhost:27017
         | 
| 7 | 
            +
                  options:
         | 
| 8 | 
            +
                    write:
         | 
| 9 | 
            +
                      w: 1
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            test:
         | 
| 12 | 
            +
              clients:
         | 
| 13 | 
            +
                default:
         | 
| 14 | 
            +
                  database: doorkeeper-mongoid9-test
         | 
| 15 | 
            +
                  hosts:
         | 
| 16 | 
            +
                    - localhost:27017
         | 
| 17 | 
            +
                  options:
         | 
| 18 | 
            +
                    write:
         | 
| 19 | 
            +
                      w: 1
         | 
    
        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. | 
| 4 | 
            +
              version: 5.5.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:  | 
| 12 | 
            +
            date: 2025-10-30 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: doorkeeper
         | 
| @@ -205,6 +205,11 @@ files: | |
| 205 205 | 
             
            - lib/doorkeeper/orm/mongoid8/access_token.rb
         | 
| 206 206 | 
             
            - lib/doorkeeper/orm/mongoid8/application.rb
         | 
| 207 207 | 
             
            - lib/doorkeeper/orm/mongoid8/stale_records_cleaner.rb
         | 
| 208 | 
            +
            - lib/doorkeeper/orm/mongoid9.rb
         | 
| 209 | 
            +
            - lib/doorkeeper/orm/mongoid9/access_grant.rb
         | 
| 210 | 
            +
            - lib/doorkeeper/orm/mongoid9/access_token.rb
         | 
| 211 | 
            +
            - lib/doorkeeper/orm/mongoid9/application.rb
         | 
| 212 | 
            +
            - lib/doorkeeper/orm/mongoid9/stale_records_cleaner.rb
         | 
| 208 213 | 
             
            - spec/dummy/Rakefile
         | 
| 209 214 | 
             
            - spec/dummy/app/assets/config/manifest.js
         | 
| 210 215 | 
             
            - spec/dummy/app/controllers/application_controller.rb
         | 
| @@ -237,6 +242,7 @@ files: | |
| 237 242 | 
             
            - spec/dummy/config/mongoid6.yml
         | 
| 238 243 | 
             
            - spec/dummy/config/mongoid7.yml
         | 
| 239 244 | 
             
            - spec/dummy/config/mongoid8.yml
         | 
| 245 | 
            +
            - spec/dummy/config/mongoid9.yml
         | 
| 240 246 | 
             
            - spec/dummy/config/routes.rb
         | 
| 241 247 | 
             
            - spec/dummy/db/migrate/20111122132257_create_users.rb
         | 
| 242 248 | 
             
            - spec/dummy/db/migrate/20120312140401_add_password_to_users.rb
         | 
| @@ -288,6 +294,7 @@ files: | |
| 288 294 | 
             
            - spec/support/orm/mongoid6.rb
         | 
| 289 295 | 
             
            - spec/support/orm/mongoid7.rb
         | 
| 290 296 | 
             
            - spec/support/orm/mongoid8.rb
         | 
| 297 | 
            +
            - spec/support/orm/mongoid9.rb
         | 
| 291 298 | 
             
            - spec/support/render_with_matcher.rb
         | 
| 292 299 | 
             
            homepage: http://github.com/doorkeeper-gem/doorkeeper-mongodb
         | 
| 293 300 | 
             
            licenses:
         | 
| @@ -352,6 +359,7 @@ test_files: | |
| 352 359 | 
             
            - spec/dummy/config/mongo.yml
         | 
| 353 360 | 
             
            - spec/dummy/config/mongoid6.yml
         | 
| 354 361 | 
             
            - spec/dummy/config/boot.rb
         | 
| 362 | 
            +
            - spec/dummy/config/mongoid9.yml
         | 
| 355 363 | 
             
            - spec/dummy/config/environments/development.rb
         | 
| 356 364 | 
             
            - spec/dummy/config/environments/production.rb
         | 
| 357 365 | 
             
            - spec/dummy/config/environments/test.rb
         | 
| @@ -394,6 +402,7 @@ test_files: | |
| 394 402 | 
             
            - spec/support/orm/mongoid4.rb
         | 
| 395 403 | 
             
            - spec/support/orm/mongoid8.rb
         | 
| 396 404 | 
             
            - spec/support/orm/mongoid.rb
         | 
| 405 | 
            +
            - spec/support/orm/mongoid9.rb
         | 
| 397 406 | 
             
            - spec/support/orm/mongoid5.rb
         | 
| 398 407 | 
             
            - spec/support/doorkeeper_rspec.rb
         | 
| 399 408 | 
             
            - spec/support/render_with_matcher.rb
         |