Module: Mongo::Auth::StringPrep Private

Extended by:
StringPrep
Included in:
StringPrep
Defined in:
build/ruby-driver-v2.19/lib/mongo/auth/stringprep.rb,
build/ruby-driver-v2.19/lib/mongo/auth/stringprep/tables.rb,
build/ruby-driver-v2.19/lib/mongo/auth/stringprep/profiles/sasl.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

This namespace contains all behavior related to string preparation (RFC 3454). It’s used to implement SCRAM-SHA-256 authentication, which is available in MongoDB server versions 4.0 and later.

Since:

  • 2.6.0

Defined Under Namespace

Modules: Profiles, Tables

Instance Method Summary collapse

Instance Method Details

#prepare(data, mappings, prohibited, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Prepare a string given a set of mappings and prohibited character tables.

Examples:

Prepare a string.

StringPrep.prepare("some string",
                   StringPrep::Profiles::SASL::MAPPINGS,
                   StringPrep::Profiles::SASL::PROHIBITED,
                   normalize: true, bidi: true)

Parameters:

  • data (String)

    The string to prepare.

  • mappings (Array)

    A list of mappings to apply to the data.

  • prohibited (Array)

    A list of prohibited character lists to ensure the data doesn’t contain after mapping and normalizing the data.

  • options (Hash) (defaults to: {})

    Optional operations to perform during string preparation.

Options Hash (options):

  • :normalize (Boolean)

    Whether or not to apply Unicode normalization to the data.

  • :bidi (Boolean)

    Whether or not to ensure that the data contains valid bidirectional input.

Raises:

Since:

  • 2.6.0



54
55
56
57
58
59
60
# File 'build/ruby-driver-v2.19/lib/mongo/auth/stringprep.rb', line 54

def prepare(data, mappings, prohibited, options = {})
  apply_maps(data, mappings).tap do |mapped|
    normalize!(mapped) if options[:normalize]
    check_prohibited!(mapped, prohibited)
    check_bidi!(mapped) if options[:bidi]
  end
end