Module: Auth::Sanitizer

Defined in:
lib/auth/sanitizer.rb,
lib/auth/sanitizer/version.rb,
lib/auth/sanitizer/thing_filter.rb,
lib/auth/sanitizer/sanitized_logger.rb,
lib/auth/sanitizer/filtered_attributes.rb

Defined Under Namespace

Modules: FilteredAttributes, Version Classes: Error, SanitizedLogger, ThingFilter

Constant Summary collapse

DEFAULT_FILTERED_KEYS =

Default keys filtered from debug log output.

%w[
  access_token
  refresh_token
  id_token
  client_secret
  assertion
  code_verifier
  token
].freeze
DEFAULT_FILTERED_LABEL =

Default replacement label for redacted values.

"[FILTERED]"
DEFAULT_FILTERED_LABEL_PROVIDER =

Default callable used to provide the filtered replacement label.

-> { DEFAULT_FILTERED_LABEL }
VERSION =

Traditional Constant Location

Version::VERSION

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_filtered_keysArray<String>

Returns the default set of key names filtered from debug log output.

Host gems may override this by passing ‘filtered_keys:` directly to Auth::Sanitizer::SanitizedLogger#initialize.

Returns:

  • (Array<String>)


72
73
74
# File 'lib/auth/sanitizer.rb', line 72

def default_filtered_keys
  DEFAULT_FILTERED_KEYS
end

Instance Method Details

#filtered_labelString

Returns the current filtered label by calling the installed provider.

Host gems may install a provider that reads from their own config by calling #filtered_label_provider=.

Returns:

  • (String)


43
44
45
# File 'lib/auth/sanitizer.rb', line 43

define_singleton_method(:filtered_label) do
  filtered_label_provider_mutex.synchronize { filtered_label_provider }.call
end

#filtered_label_provider=void

This method returns an undefined value.

Install a custom provider for the filtered label.

The provider is called each time a new FilteredAttributes- or SanitizedLogger-bearing object is initialized, allowing the label to track a host gem’s live configuration while still being snapshotted per object instance.

Examples:

Delegate to a host gem’s config

Auth::Sanitizer.filtered_label_provider = -> { MyGem.config[:filtered_label] }

Parameters:

  • provider (#call)

    A callable that returns the label string



59
60
61
62
63
# File 'lib/auth/sanitizer.rb', line 59

define_singleton_method(:filtered_label_provider=) do |provider|
  filtered_label_provider_mutex.synchronize do
    filtered_label_provider = provider
  end
end