Sha256: 07ea9584ad7d7fa521e67af8308dbbad527d858d10235a7f2dc600df345e23ae

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

namespace :doorkeeper do
  namespace :db do
    desc 'Removes stale data from doorkeeper related database tables'
    task cleanup: [
      'doorkeeper:db:cleanup:revoked_tokens',
      'doorkeeper:db:cleanup:expired_tokens',
      'doorkeeper:db:cleanup:revoked_grants',
      'doorkeeper:db:cleanup:expired_grants'
    ]

    namespace :cleanup do
      desc 'Removes stale access tokens'
      task revoked_tokens: 'doorkeeper:setup' do
        cleaner = Doorkeeper::StaleRecordsCleaner.new(Doorkeeper::AccessToken)
        cleaner.clean_revoked
      end

      desc 'Removes expired (TTL passed) access tokens'
      task expired_tokens: 'doorkeeper:setup' do
        expirable_tokens = Doorkeeper::AccessToken.where(refresh_token: nil)
        cleaner = Doorkeeper::StaleRecordsCleaner.new(expirable_tokens)
        cleaner.clean_expired(Doorkeeper.configuration.access_token_expires_in)
      end

      desc 'Removes stale access grants'
      task revoked_grants: 'doorkeeper:setup' do
        cleaner = Doorkeeper::StaleRecordsCleaner.new(Doorkeeper::AccessGrant)
        cleaner.clean_revoked
      end

      desc 'Removes expired (TTL passed) access grants'
      task expired_grants: 'doorkeeper:setup' do
        cleaner = Doorkeeper::StaleRecordsCleaner.new(Doorkeeper::AccessGrant)
        cleaner.clean_expired(Doorkeeper.configuration.authorization_code_expires_in)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
doorkeeper-5.0.3 lib/doorkeeper/rake/db.rake
doorkeeper-5.1.0.rc2 lib/doorkeeper/rake/db.rake
doorkeeper-5.1.0.rc1 lib/doorkeeper/rake/db.rake
doorkeeper-5.0.2 lib/doorkeeper/rake/db.rake
doorkeeper-5.0.1 lib/doorkeeper/rake/db.rake