Class: Net::SASL::CramMD5Authenticator

Inherits:
Authenticator show all
Defined in:
lib/net/sasl/cram_md5_authenticator.rb

Overview

Authenticator for the “CRAM-MD5” SASL mechanism, specified in RFC2195.

Deprecated

CRAM-MD5 is obsolete. It is included for compatibility with existing servers. draft-ietf-sasl-crammd5-to-historic recommends using SCRAM-* or PLAIN protected by TLS instead.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Authenticator

#supports_initial_response?

Constructor Details

#initialize(username, password, **_options) ⇒ CramMD5Authenticator

Provide the username and password credentials for authentication.

CRAM-MD5 doesn’t support authzid, and an ArgumentError will be raised if a third positional parameter is passed.

This should generally be instantiated via Net::SASL.authenticator.



31
32
33
34
35
36
# File 'lib/net/sasl/cram_md5_authenticator.rb', line 31

def initialize(username, password, **_options)
  super
  @username = username
  @password = password
  @done = false
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



20
21
22
# File 'lib/net/sasl/cram_md5_authenticator.rb', line 20

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



20
21
22
# File 'lib/net/sasl/cram_md5_authenticator.rb', line 20

def username
  @username
end

Instance Method Details

#process(challenge) ⇒ Object

responds to the server’s challenge using the HMAC-MD5 algorithm.



39
40
41
42
# File 'lib/net/sasl/cram_md5_authenticator.rb', line 39

def process(challenge)
  digest = hmac_md5(challenge, password)
  "#{username} #{digest}"
end