module Pakyow::Security::Behavior::Disabling

Public Class Methods

disable_protection(type, only: [], except: []) click to toggle source
# File lib/pakyow/security/behavior/disabling.rb, line 13
def self.disable_protection(type, only: [], except: [])
  if type.to_sym == :csrf
    if only.any? || except.any?
      Pipelines::CSRF.__pipeline.actions.each do |action|
        if only.any?
          skip action.target, only: only
        end

        if except.any?
          action action.target, only: except
        end
      end
    else
      exclude_pipeline Pipelines::CSRF
    end
  else
    raise ArgumentError, "Unknown protection type `#{type}'"
  end
end