Skip to content

Commit

Permalink
🚧 Temporarily remove check_auth_method and check_auth_args [WIP]
Browse files Browse the repository at this point in the history
The problem is that not every SASL mechanism uses username and password
nor do they all authenticator take two positional parameters.  It's a
little more complicated to verify that 1) the authenticator exists, and
2) we've supplied all required parameters.

TODO: However, since we already know the authenticator arguments
up-front, we can simply create the authenticator object and rely on the
its initializer to raise ArgumentError for missing args.
  • Loading branch information
nevans committed Sep 28, 2023
1 parent 7ca1281 commit a9e10b0
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions lib/net/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,6 @@ def tcp_socket(address, port)

def do_start(helo_domain, user, secret, authtype)
raise IOError, 'SMTP session already started' if @started
if user or secret
check_auth_method(authtype || DEFAULT_AUTH_TYPE)
check_auth_args user, secret
end
s = Timeout.timeout(@open_timeout, Net::OpenTimeout) do
tcp_socket(@address, @port)
end
Expand Down Expand Up @@ -833,8 +829,6 @@ def open_message_stream(from_addr, *to_addrs, &block) # :yield: stream
DEFAULT_AUTH_TYPE = :plain

def authenticate(user, secret, authtype = DEFAULT_AUTH_TYPE)
check_auth_method authtype
check_auth_args user, secret
authenticator = Authenticator.auth_class(authtype).new(self)
critical { authenticator.auth(user, secret) }
end
Expand All @@ -859,27 +853,6 @@ def auth(*args, mechanism: nil, **kwargs, &block)
}
end

private

def check_auth_method(type)
unless Authenticator.auth_class(type)
raise ArgumentError, "wrong authentication type #{type}"
end
end

def auth_method(type)
"auth_#{type.to_s.downcase}".intern
end

def check_auth_args(user, secret, authtype = DEFAULT_AUTH_TYPE)
unless user
raise ArgumentError, 'SMTP-AUTH requested but missing user name'
end
unless secret
raise ArgumentError, 'SMTP-AUTH requested but missing secret phrase'
end
end

#
# SMTP command dispatcher
#
Expand Down

0 comments on commit a9e10b0

Please sign in to comment.