123456789_123456789_123456789_123456789_123456789_

Class: Net::IMAP::PlainAuthenticator

Relationships & Source Files
Inherits: Object
Defined in: lib/net/imap/authenticators/plain.rb

Overview

Authenticator for the “PLAINSASL mechanism, specified in RFC4616. See #authenticate.

PLAIN 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. PLAIN can be secured by TLS encryption.

Constant Summary

Class Method Summary

Instance Method Summary

Constructor Details

.new(username, password, authzid: nil) ⇒ PlainAuthenticator (private)

username is the authentication identity, the identity whose password is used. username is referred to as authcid by RFC4616.

authzid is the authorization identity (identity to act as). It can usually be left blank. When authzid is left blank (nil or empty string) the server will derive an identity from the credentials and use that as the authorization identity.

Raises:

  • (ArgumentError)
[ GitHub ]

  
# File 'lib/net/imap/authenticators/plain.rb', line 31

def initialize(username, password, authzid: nil)
  raise ArgumentError, "username contains NULL" if username&.include?(NULL)
  raise ArgumentError, "password contains NULL" if password&.include?(NULL)
  raise ArgumentError, "authzid  contains NULL" if authzid&.include?(NULL)
  @username = username
  @password = password
  @authzid  = authzid
end

Instance Method Details

#process(data)

[ GitHub ]

  
# File 'lib/net/imap/authenticators/plain.rb', line 14

def process(data)
  return "#@authzid\0#@username\0#@password"
end