module Groat::SMTPD::Extensions::Authentication::Login

Public Class Methods

included(mod) click to toggle source
Calls superclass method
# File lib/groat/smtpd/extensions/mechanism-login.rb, line 26
def self.included mod
  puts "Included Non-standard LOGIN Authentication Mechanism"
  raise SMTPExtensionError.new("LOGIN auth mechanism requires AUTH") unless mod.ehlo_keyword_known? :auth
  mod.auth_mechanism :login, :auth_mech_login, :secure?
  super
end

Public Instance Methods

auth_mech_login(arg) click to toggle source
# File lib/groat/smtpd/extensions/mechanism-login.rb, line 37
def auth_mech_login(arg)
  response_bad_command_parameter(:message => "Encrypted session required", 
                                 :terminate => false) unless secure?
  check_command_group
  unless arg.nil?
    response_syntax_error(:message => "LOGIN does not allow initial response")
  end
  # Outlook requires "Username:" (vs the draft which says "User Name")
  toclient "334 " + Base64.encode64("Username:").strip + "\r\n"
  r = fromclient.chomp
  if r.eql? '*'
    response_syntax_error(:message => "Authentication Quit")
  end
  if r !~ BASE64_VALID
    response_syntax_error(:message => "Bad response")
  end
  username = Base64.decode64(r) 
  # Outlook requires "Password:" (vs the draft which says "Password")
  toclient "334 " + Base64.encode64("Password:").strip + "\r\n"
  r = fromclient.chomp
  if r.eql? '*'
    response_syntax_error(:message => "Authentication Quit")
  end
  if r !~ BASE64_VALID
    response_syntax_error(:message => "Bad response")
  end
  password = Base64.decode64(r) 
  res = validate_auth_login(username, password)
  if res
    @authenticated = true
    response_auth_ok
  end
end
validate_auth_login(user, pass) click to toggle source
# File lib/groat/smtpd/extensions/mechanism-login.rb, line 33
def validate_auth_login(user, pass)
  response_auth_temp_fail
end