Sha256: df5e8b045d8099fad0ab9bac48f9af740639a7aabde157fed7a17f371a064b71

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

# Authenticator for the "+LOGIN+" SASL mechanism.  See Net::IMAP#authenticate.
#
# +LOGIN+ authentication sends the password in cleartext.
# RFC3501[https://tools.ietf.org/html/rfc3501] encourages servers to disable
# cleartext authentication until after TLS has been negotiated.
# RFC8314[https://tools.ietf.org/html/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}[https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml]
# marks "LOGIN" as obsoleted in favor of "PLAIN".  It is included here for
# compatibility with existing servers.  See
# {draft-murchison-sasl-login}[https://www.iana.org/go/draft-murchison-sasl-login]
# for both specification and deprecation.
class Net::IMAP::LoginAuthenticator
  def process(data)
    case @state
    when STATE_USER
      @state = STATE_PASSWORD
      return @user
    when STATE_PASSWORD
      return @password
    end
  end

  private

  STATE_USER = :USER
  STATE_PASSWORD = :PASSWORD

  def initialize(user, password)
    @user = user
    @password = password
    @state = STATE_USER
  end

  Net::IMAP.add_authenticator "LOGIN", self
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
net-imap-0.2.4 lib/net/imap/authenticators/login.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/net-imap-0.2.3/lib/net/imap/authenticators/login.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/net-imap-0.2.3/lib/net/imap/authenticators/login.rb
net-imap-0.2.3 lib/net/imap/authenticators/login.rb
net-imap-0.2.2 lib/net/imap/authenticators/login.rb