-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The client should raise an error if the command completes successfully but "done?" returns false. Also move to sasl dir and SASL module.
- Loading branch information
Showing
4 changed files
with
64 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
|
||
module Net | ||
class IMAP < Protocol | ||
module SASL | ||
|
||
# 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 LoginAuthenticator | ||
|
||
STATE_USER = :USER | ||
STATE_PASSWORD = :PASSWORD | ||
STATE_DONE = :DONE | ||
private_constant :STATE_USER, :STATE_PASSWORD, :STATE_DONE | ||
|
||
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 | ||
|
||
def process(data) | ||
case @state | ||
when STATE_USER | ||
@state = STATE_PASSWORD | ||
@user | ||
when STATE_PASSWORD | ||
@state = STATE_DONE | ||
@password | ||
when STATE_DONE | ||
raise ResponseParseError, data | ||
end | ||
end | ||
|
||
def done?; @state == STATE_DONE end | ||
end | ||
end | ||
|
||
LoginAuthenticator = SASL::LoginAuthenticator # :nodoc: | ||
deprecate_constant :LoginAuthenticator | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters