Module: Datadog::AppSec::Contrib::Devise::Patcher

Includes:
Patcher
Defined in:
lib/datadog/appsec/contrib/devise/patcher.rb,
lib/datadog/appsec/contrib/devise/patcher/rememberable_patch.rb,
lib/datadog/appsec/contrib/devise/patcher/authenticatable_patch.rb,
lib/datadog/appsec/contrib/devise/patcher/registration_controller_patch.rb

Overview

Patcher for AppSec on Devise

Defined Under Namespace

Modules: AuthenticatablePatch, RegistrationControllerPatch, RememberablePatch

Class Method Summary collapse

Class Method Details

.patchObject



26
27
28
29
30
31
32
# File 'lib/datadog/appsec/contrib/devise/patcher.rb', line 26

def patch
  patch_authenticatable_strategy
  patch_rememberable_strategy
  patch_registration_controller

  Patcher.instance_variable_set(:@patched, true)
end

.patch_authenticatable_strategyObject



34
35
36
# File 'lib/datadog/appsec/contrib/devise/patcher.rb', line 34

def patch_authenticatable_strategy
  ::Devise::Strategies::Authenticatable.prepend(AuthenticatablePatch)
end

.patch_registration_controllerObject



46
47
48
49
50
# File 'lib/datadog/appsec/contrib/devise/patcher.rb', line 46

def patch_registration_controller
  ::ActiveSupport.on_load(:after_initialize) do
    ::Devise::RegistrationsController.prepend(RegistrationControllerPatch)
  end
end

.patch_rememberable_strategyObject



38
39
40
41
42
43
44
# File 'lib/datadog/appsec/contrib/devise/patcher.rb', line 38

def patch_rememberable_strategy
  return unless ::Devise::STRATEGIES.include?(:rememberable)

  # Rememberable strategy is required in autoloaded Rememberable model
  ::Devise::Models::Rememberable # rubocop:disable Lint/Void
  ::Devise::Strategies::Rememberable.prepend(RememberablePatch)
end

.patched?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/datadog/appsec/contrib/devise/patcher.rb', line 18

def patched?
  Patcher.instance_variable_get(:@patched)
end

.target_versionObject



22
23
24
# File 'lib/datadog/appsec/contrib/devise/patcher.rb', line 22

def target_version
  Integration.version
end