Module: Auth::Sanitizer — Documentation by YARD 0.9.44

# Module: Auth::Sanitizer

Defined in:
  lib/auth/sanitizer/core.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

- .default_filtered_keys ⇒ Array<String>

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

## Instance Method Summary collapse

- #filtered_label ⇒ String

  Returns the current filtered label by calling the installed provider.

- #filtered_label_provider= ⇒ void

  Install a custom provider for the filtered label.

## Class Method Details

### .default_filtered_keys ⇒ `Array<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>`)

    68
    69
    70
    # File 'lib/auth/sanitizer/core.rb', line 68

    def default_filtered_keys
      DEFAULT_FILTERED_KEYS
    end

## Instance Method Details

### #filtered_label ⇒ `String`

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`)

    39
    40
    41
    # File 'lib/auth/sanitizer/core.rb', line 39

    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

    55
    56
    57
    58
    59
    # File 'lib/auth/sanitizer/core.rb', line 55

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