net-imap 0.4.12 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -1
- data/README.md +10 -4
- data/docs/styles.css +75 -14
- data/lib/net/imap/authenticators.rb +2 -2
- data/lib/net/imap/command_data.rb +61 -48
- data/lib/net/imap/config/attr_accessors.rb +75 -0
- data/lib/net/imap/config/attr_inheritance.rb +90 -0
- data/lib/net/imap/config/attr_type_coercion.rb +61 -0
- data/lib/net/imap/config.rb +470 -0
- data/lib/net/imap/data_encoding.rb +3 -3
- data/lib/net/imap/data_lite.rb +226 -0
- data/lib/net/imap/deprecated_client_options.rb +8 -5
- data/lib/net/imap/errors.rb +6 -0
- data/lib/net/imap/esearch_result.rb +180 -0
- data/lib/net/imap/fetch_data.rb +126 -47
- data/lib/net/imap/response_data.rb +124 -237
- data/lib/net/imap/response_parser/parser_utils.rb +11 -6
- data/lib/net/imap/response_parser.rb +187 -34
- data/lib/net/imap/sasl/anonymous_authenticator.rb +3 -3
- data/lib/net/imap/sasl/authentication_exchange.rb +52 -20
- data/lib/net/imap/sasl/authenticators.rb +8 -4
- data/lib/net/imap/sasl/client_adapter.rb +77 -26
- data/lib/net/imap/sasl/cram_md5_authenticator.rb +4 -4
- data/lib/net/imap/sasl/digest_md5_authenticator.rb +218 -56
- data/lib/net/imap/sasl/external_authenticator.rb +2 -2
- data/lib/net/imap/sasl/gs2_header.rb +7 -7
- data/lib/net/imap/sasl/login_authenticator.rb +4 -3
- data/lib/net/imap/sasl/oauthbearer_authenticator.rb +6 -6
- data/lib/net/imap/sasl/plain_authenticator.rb +7 -7
- data/lib/net/imap/sasl/protocol_adapters.rb +60 -4
- data/lib/net/imap/sasl/scram_authenticator.rb +8 -8
- data/lib/net/imap/sasl.rb +7 -4
- data/lib/net/imap/sasl_adapter.rb +0 -1
- data/lib/net/imap/search_result.rb +2 -2
- data/lib/net/imap/sequence_set.rb +221 -82
- data/lib/net/imap/stringprep/nameprep.rb +1 -1
- data/lib/net/imap/stringprep/trace.rb +4 -4
- data/lib/net/imap/uidplus_data.rb +244 -0
- data/lib/net/imap/vanished_data.rb +56 -0
- data/lib/net/imap.rb +1010 -320
- data/net-imap.gemspec +3 -3
- data/rakelib/rfcs.rake +2 -0
- data/rakelib/string_prep_tables_generator.rb +2 -0
- metadata +12 -10
- data/.github/dependabot.yml +0 -6
- data/.github/workflows/pages.yml +0 -46
- data/.github/workflows/push_gem.yml +0 -48
- data/.github/workflows/test.yml +0 -31
- data/.gitignore +0 -12
- data/.mailmap +0 -13
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Authenticator for the "+PLAIN+" SASL mechanism, specified in
|
4
|
-
# RFC-4616[https://
|
4
|
+
# RFC-4616[https://www.rfc-editor.org/rfc/rfc4616]. See Net::IMAP#authenticate.
|
5
5
|
#
|
6
6
|
# +PLAIN+ authentication sends the password in cleartext.
|
7
|
-
# RFC-3501[https://
|
7
|
+
# RFC-3501[https://www.rfc-editor.org/rfc/rfc3501] encourages servers to disable
|
8
8
|
# cleartext authentication until after TLS has been negotiated.
|
9
|
-
# RFC-8314[https://
|
9
|
+
# RFC-8314[https://www.rfc-editor.org/rfc/rfc8314] recommends TLS version 1.2 or
|
10
10
|
# greater be used for all traffic, and deprecate cleartext access ASAP. +PLAIN+
|
11
11
|
# can be secured by TLS encryption.
|
12
12
|
class Net::IMAP::SASL::PlainAuthenticator
|
@@ -16,11 +16,11 @@ class Net::IMAP::SASL::PlainAuthenticator
|
|
16
16
|
|
17
17
|
# Authentication identity: the identity that matches the #password.
|
18
18
|
#
|
19
|
-
# RFC-2831[https://
|
19
|
+
# RFC-2831[https://www.rfc-editor.org/rfc/rfc2831] uses the term +username+.
|
20
20
|
# "Authentication identity" is the generic term used by
|
21
|
-
# RFC-4422[https://
|
22
|
-
# RFC-4616[https://
|
23
|
-
# this to +authcid+.
|
21
|
+
# RFC-4422[https://www.rfc-editor.org/rfc/rfc4422].
|
22
|
+
# RFC-4616[https://www.rfc-editor.org/rfc/rfc4616] and many later RFCs
|
23
|
+
# abbreviate this to +authcid+.
|
24
24
|
attr_reader :username
|
25
25
|
alias authcid username
|
26
26
|
|
@@ -4,16 +4,72 @@ module Net
|
|
4
4
|
class IMAP
|
5
5
|
module SASL
|
6
6
|
|
7
|
+
# SASL::ProtocolAdapters modules are meant to be used as mixins for
|
8
|
+
# SASL::ClientAdapter and its subclasses. Where the client adapter must
|
9
|
+
# be customized for each client library, the protocol adapter mixin
|
10
|
+
# handles \SASL requirements that are part of the protocol specification,
|
11
|
+
# but not specific to any particular client library. In particular, see
|
12
|
+
# {RFC4422 §4}[https://www.rfc-editor.org/rfc/rfc4422.html#section-4]
|
13
|
+
#
|
14
|
+
# === Interface
|
15
|
+
#
|
16
|
+
# >>>
|
17
|
+
# NOTE: This API is experimental, and may change.
|
18
|
+
#
|
19
|
+
# - {#command_name}[rdoc-ref:Generic#command_name] -- The name of the
|
20
|
+
# command used to to initiate an authentication exchange.
|
21
|
+
# - {#service}[rdoc-ref:Generic#service] -- The GSSAPI service name.
|
22
|
+
# - {#encode_ir}[rdoc-ref:Generic#encode_ir]--Encodes an initial response.
|
23
|
+
# - {#decode}[rdoc-ref:Generic#decode] -- Decodes a server challenge.
|
24
|
+
# - {#encode}[rdoc-ref:Generic#encode] -- Encodes a client response.
|
25
|
+
# - {#cancel_response}[rdoc-ref:Generic#cancel_response] -- The encoded
|
26
|
+
# client response used to cancel an authentication exchange.
|
27
|
+
#
|
28
|
+
# Other protocol requirements of the \SASL authentication exchange are
|
29
|
+
# handled by SASL::ClientAdapter.
|
30
|
+
#
|
31
|
+
# === Included protocol adapters
|
32
|
+
#
|
33
|
+
# - Generic -- a basic implementation of all of the methods listed above.
|
34
|
+
# - IMAP -- An adapter for the IMAP4 protocol.
|
35
|
+
# - SMTP -- An adapter for the \SMTP protocol with the +AUTH+ capability.
|
36
|
+
# - POP -- An adapter for the POP3 protocol with the +SASL+ capability.
|
7
37
|
module ProtocolAdapters
|
8
|
-
#
|
38
|
+
# See SASL::ProtocolAdapters@Interface.
|
9
39
|
module Generic
|
40
|
+
# The name of the protocol command used to initiate a \SASL
|
41
|
+
# authentication exchange.
|
42
|
+
#
|
43
|
+
# The generic implementation returns <tt>"AUTHENTICATE"</tt>.
|
10
44
|
def command_name; "AUTHENTICATE" end
|
11
|
-
|
12
|
-
|
13
|
-
|
45
|
+
|
46
|
+
# A service name from the {GSSAPI/Kerberos/SASL Service Names
|
47
|
+
# registry}[https://www.iana.org/assignments/gssapi-service-names/gssapi-service-names.xhtml].
|
48
|
+
#
|
49
|
+
# The generic implementation returns <tt>"host"</tt>, which is the
|
50
|
+
# generic GSSAPI host-based service name.
|
51
|
+
def service; "host" end
|
52
|
+
|
53
|
+
# Encodes an initial response string.
|
54
|
+
#
|
55
|
+
# The generic implementation returns the result of #encode, or returns
|
56
|
+
# <tt>"="</tt> when +string+ is empty.
|
14
57
|
def encode_ir(string) string.empty? ? "=" : encode(string) end
|
58
|
+
|
59
|
+
# Encodes a client response string.
|
60
|
+
#
|
61
|
+
# The generic implementation returns the Base64 encoding of +string+.
|
15
62
|
def encode(string) [string].pack("m0") end
|
63
|
+
|
64
|
+
# Decodes a server challenge string.
|
65
|
+
#
|
66
|
+
# The generic implementation returns the Base64 decoding of +string+.
|
16
67
|
def decode(string) string.unpack1("m0") end
|
68
|
+
|
69
|
+
# Returns the message used by the client to abort an authentication
|
70
|
+
# exchange.
|
71
|
+
#
|
72
|
+
# The generic implementation returns <tt>"*"</tt>.
|
17
73
|
def cancel_response; "*" end
|
18
74
|
end
|
19
75
|
|
@@ -11,7 +11,7 @@ module Net
|
|
11
11
|
module SASL
|
12
12
|
|
13
13
|
# Abstract base class for the "+SCRAM-*+" family of SASL mechanisms,
|
14
|
-
# defined in RFC5802[https://
|
14
|
+
# defined in RFC5802[https://www.rfc-editor.org/rfc/rfc5802]. Use via
|
15
15
|
# Net::IMAP#authenticate.
|
16
16
|
#
|
17
17
|
# Directly supported:
|
@@ -99,11 +99,11 @@ module Net
|
|
99
99
|
|
100
100
|
# Authentication identity: the identity that matches the #password.
|
101
101
|
#
|
102
|
-
# RFC-2831[https://
|
103
|
-
# "Authentication identity" is the generic term used by
|
104
|
-
# RFC-4422[https://
|
105
|
-
# RFC-4616[https://
|
106
|
-
# this to +authcid+.
|
102
|
+
# RFC-2831[https://www.rfc-editor.org/rfc/rfc2831] uses the term
|
103
|
+
# +username+. "Authentication identity" is the generic term used by
|
104
|
+
# RFC-4422[https://www.rfc-editor.org/rfc/rfc4422].
|
105
|
+
# RFC-4616[https://www.rfc-editor.org/rfc/rfc4616] and many later RFCs
|
106
|
+
# abbreviate this to +authcid+.
|
107
107
|
attr_reader :username
|
108
108
|
alias authcid username
|
109
109
|
|
@@ -263,7 +263,7 @@ module Net
|
|
263
263
|
end
|
264
264
|
|
265
265
|
# Authenticator for the "+SCRAM-SHA-1+" SASL mechanism, defined in
|
266
|
-
# RFC5802[https://
|
266
|
+
# RFC5802[https://www.rfc-editor.org/rfc/rfc5802].
|
267
267
|
#
|
268
268
|
# Uses the "SHA-1" digest algorithm from OpenSSL::Digest.
|
269
269
|
#
|
@@ -273,7 +273,7 @@ module Net
|
|
273
273
|
end
|
274
274
|
|
275
275
|
# Authenticator for the "+SCRAM-SHA-256+" SASL mechanism, defined in
|
276
|
-
# RFC7677[https://
|
276
|
+
# RFC7677[https://www.rfc-editor.org/rfc/rfc7677].
|
277
277
|
#
|
278
278
|
# Uses the "SHA-256" digest algorithm from OpenSSL::Digest.
|
279
279
|
#
|
data/lib/net/imap/sasl.rb
CHANGED
@@ -5,7 +5,7 @@ module Net
|
|
5
5
|
|
6
6
|
# Pluggable authentication mechanisms for protocols which support SASL
|
7
7
|
# (Simple Authentication and Security Layer), such as IMAP4, SMTP, LDAP, and
|
8
|
-
# XMPP. {RFC-4422}[https://
|
8
|
+
# XMPP. {RFC-4422}[https://www.rfc-editor.org/rfc/rfc4422] specifies the
|
9
9
|
# common \SASL framework:
|
10
10
|
# >>>
|
11
11
|
# SASL is conceptually a framework that provides an abstraction layer
|
@@ -114,8 +114,8 @@ module Net
|
|
114
114
|
# messages has not passed integrity checks.
|
115
115
|
AuthenticationFailed = Class.new(Error)
|
116
116
|
|
117
|
-
# Indicates that authentication cannot proceed because
|
118
|
-
#
|
117
|
+
# Indicates that authentication cannot proceed because the server ended
|
118
|
+
# authentication prematurely.
|
119
119
|
class AuthenticationIncomplete < AuthenticationFailed
|
120
120
|
# The success response from the server
|
121
121
|
attr_reader :response
|
@@ -159,7 +159,10 @@ module Net
|
|
159
159
|
# Returns the default global SASL::Authenticators instance.
|
160
160
|
def self.authenticators; @authenticators ||= Authenticators.new end
|
161
161
|
|
162
|
-
#
|
162
|
+
# Creates a new SASL authenticator, using SASL::Authenticators#new.
|
163
|
+
#
|
164
|
+
# +registry+ defaults to SASL.authenticators. All other arguments are
|
165
|
+
# forwarded to to <tt>registry.new</tt>.
|
163
166
|
def self.authenticator(*args, registry: authenticators, **kwargs, &block)
|
164
167
|
registry.new(*args, **kwargs, &block)
|
165
168
|
end
|
@@ -12,7 +12,6 @@ module Net
|
|
12
12
|
|
13
13
|
def response_errors; RESPONSE_ERRORS end
|
14
14
|
def sasl_ir_capable?; client.capable?("SASL-IR") end
|
15
|
-
def auth_capable?(mechanism); client.auth_capable?(mechanism) end
|
16
15
|
def drop_connection; client.logout! end
|
17
16
|
def drop_connection!; client.disconnect end
|
18
17
|
end
|
@@ -100,10 +100,10 @@ module Net
|
|
100
100
|
# data.to_s("SORT") # => "* SORT 2 8 32 128 256 512"
|
101
101
|
# data.to_s(nil) # => "2 8 32 128 256 512"
|
102
102
|
#
|
103
|
-
# data = Net::IMAP::SearchResult[1, 3, 16, 1024, modseq: 2048]
|
103
|
+
# data = Net::IMAP::SearchResult[1, 3, 16, 1024, modseq: 2048]
|
104
104
|
# data.to_s # => "* SEARCH 1 3 16 1024 (MODSEQ 2048)"
|
105
105
|
# data.to_s("SORT") # => "* SORT 1 3 16 1024 (MODSEQ 2048)"
|
106
|
-
# data.to_s
|
106
|
+
# data.to_s(nil) # => "1 3 16 1024 (MODSEQ 2048)"
|
107
107
|
#
|
108
108
|
def to_s(type = "SEARCH")
|
109
109
|
str = +""
|