Class: Net::IMAP::SASL::LoginAuthenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/net/imap/sasl/login_authenticator.rb

Overview

Authenticator for the “LOGIN” SASL mechanism. See Net::IMAP#authenticate.

LOGIN authentication sends the password in cleartext. RFC3501 encourages servers to disable cleartext authentication until after TLS has been negotiated. RFC8314 recommends TLS version 1.2 or greater be used for all traffic, and deprecate cleartext access ASAP. LOGIN can be secured by TLS encryption.

Deprecated

The SASL mechanisms registry marks “LOGIN” as obsoleted in favor of “PLAIN”. It is included here for compatibility with existing servers. See draft-murchison-sasl-login for both specification and deprecation.

Instance Method Summary collapse

Constructor Details

#initialize(user, password, warn_deprecation: true, **_ignored) ⇒ LoginAuthenticator

Returns a new instance of LoginAuthenticator.



26
27
28
29
30
31
32
33
# File 'lib/net/imap/sasl/login_authenticator.rb', line 26

def initialize(user, password, warn_deprecation: true, **_ignored)
  if warn_deprecation
    warn "WARNING: LOGIN SASL mechanism is deprecated. Use PLAIN instead."
  end
  @user = user
  @password = password
  @state = STATE_USER
end

Instance Method Details

#done?Boolean

Returns:

  • (Boolean)


50
# File 'lib/net/imap/sasl/login_authenticator.rb', line 50

def done?; @state == STATE_DONE end

#initial_response?Boolean

Returns:

  • (Boolean)


35
# File 'lib/net/imap/sasl/login_authenticator.rb', line 35

def initial_response?; false end

#process(data) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/net/imap/sasl/login_authenticator.rb', line 37

def process(data)
  case @state
  when STATE_USER
    @state = STATE_PASSWORD
    return @user
  when STATE_PASSWORD
    @state = STATE_DONE
    return @password
  when STATE_DONE
    raise ResponseParseError, data
  end
end