method

filter_parameter_logging

Importance_2
Ruby on Rails latest stable (v7.1.3.2) - 0 notes - Class: ActionController::Base

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2.3.8) is shown here.

filter_parameter_logging(*filter_words, &block) public

Replace sensitive parameter data from the request log. Filters parameters that have any of the arguments as a substring. Looks in all subhashes of the param hash for keys to filter. If a block is given, each key and value of the parameter hash and all subhashes is passed to it, the value or key can be replaced using String#replace or similar method.

Examples:

  filter_parameter_logging
  => Does nothing, just slows the logging process down

  filter_parameter_logging :password
  => replaces the value to all keys matching /password/i with "[FILTERED]"

  filter_parameter_logging :foo, "bar"
  => replaces the value to all keys matching /foo|bar/i with "[FILTERED]"

  filter_parameter_logging { |k,v| v.reverse! if k =~ /secret/i }
  => reverses the value to all keys matching /secret/i

  filter_parameter_logging(:foo, "bar") { |k,v| v.reverse! if k =~ /secret/i }
  => reverses the value to all keys matching /secret/i, and
     replaces the value to all keys matching /foo|bar/i with "[FILTERED]"
Show source
Register or log in to add new notes.