Class: Couchbase::PasswordAuthenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/authenticator.rb

Overview

Authenticator for username/password credentials

Constant Summary collapse

DEFAULT_SASL_MECHANISMS =
[:scram_sha512, :scram_sha256, :scram_sha1].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ PasswordAuthenticator

Creates a new password authenticator with the default settings.

Parameters:

  • password (String)

    the username to use for all authentication requests

  • username (String)

    the password



30
31
32
33
# File 'lib/couchbase/authenticator.rb', line 30

def initialize(username, password)
  @username = username
  @password = password
end

Instance Attribute Details

#allowed_sasl_mechanismsObject

Returns the value of attribute allowed_sasl_mechanisms.



24
25
26
# File 'lib/couchbase/authenticator.rb', line 24

def allowed_sasl_mechanisms
  @allowed_sasl_mechanisms
end

#passwordObject

Returns the value of attribute password.



23
24
25
# File 'lib/couchbase/authenticator.rb', line 23

def password
  @password
end

#usernameObject

Returns the value of attribute username.



22
23
24
# File 'lib/couchbase/authenticator.rb', line 22

def username
  @username
end

Class Method Details

.ldap_compatible(username, password) ⇒ PasswordAuthenticator

Creates a LDAP compatible password authenticator which is INSECURE if not used with TLS.

Please note that this is INSECURE and will leak user credentials on the wire to eavesdroppers. This should only be enabled in trusted environments.

Parameters:

  • username (String)

    the username to use for all authentication.

  • password (String)

    the password to use alongside the username.

Returns:



43
44
45
46
47
# File 'lib/couchbase/authenticator.rb', line 43

def self.ldap_compatible(username, password)
  new(username, password).tap do |auth|
    auth.allowed_sasl_mechanisms = [:plain]
  end
end