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



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

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

Instance Attribute Details

#allowed_sasl_mechanismsObject

Returns the value of attribute allowed_sasl_mechanisms.



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

def allowed_sasl_mechanisms
  @allowed_sasl_mechanisms
end

#passwordObject

Returns the value of attribute password.



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

def password
  @password
end

#usernameObject

Returns the value of attribute username.



20
21
22
# File 'lib/couchbase/authenticator.rb', line 20

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:



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

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