net-imap 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/docs/styles.css +11 -1
- data/lib/net/imap/config.rb +5 -3
- data/lib/net/imap/data_lite.rb +11 -10
- data/lib/net/imap/fetch_data.rb +126 -47
- data/lib/net/imap/response_data.rb +118 -100
- data/lib/net/imap/response_parser.rb +13 -2
- data/lib/net/imap/sasl/anonymous_authenticator.rb +3 -3
- data/lib/net/imap/sasl/cram_md5_authenticator.rb +3 -3
- data/lib/net/imap/sasl/digest_md5_authenticator.rb +8 -8
- 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 +2 -2
- 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/scram_authenticator.rb +8 -8
- data/lib/net/imap/sasl.rb +1 -1
- data/lib/net/imap/search_result.rb +2 -2
- data/lib/net/imap/stringprep/nameprep.rb +1 -1
- data/lib/net/imap/stringprep/trace.rb +4 -4
- data/lib/net/imap.rb +162 -100
- data/rakelib/rfcs.rake +1 -0
- metadata +3 -6
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Authenticator for the "+CRAM-MD5+" SASL mechanism, specified in
|
4
|
-
# RFC2195[https://
|
4
|
+
# RFC2195[https://www.rfc-editor.org/rfc/rfc2195]. See Net::IMAP#authenticate.
|
5
5
|
#
|
6
6
|
# == Deprecated
|
7
7
|
#
|
8
8
|
# +CRAM-MD5+ is obsolete and insecure. It is included for compatibility with
|
9
9
|
# existing servers.
|
10
|
-
# {draft-ietf-sasl-crammd5-to-historic}[https://
|
10
|
+
# {draft-ietf-sasl-crammd5-to-historic}[https://www.rfc-editor.org/rfc/draft-ietf-sasl-crammd5-to-historic-00.html]
|
11
11
|
# recommends using +SCRAM-*+ or +PLAIN+ protected by TLS instead.
|
12
12
|
#
|
13
|
-
# Additionally, RFC8314[https://
|
13
|
+
# Additionally, RFC8314[https://www.rfc-editor.org/rfc/rfc8314] discourage the use
|
14
14
|
# of cleartext and recommends TLS version 1.2 or greater be used for all
|
15
15
|
# traffic. With TLS +CRAM-MD5+ is okay, but so is +PLAIN+
|
16
16
|
class Net::IMAP::SASL::CramMD5Authenticator
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Net::IMAP authenticator for the +DIGEST-MD5+ SASL mechanism type, specified
|
4
|
-
# in RFC-2831[https://
|
4
|
+
# in RFC-2831[https://www.rfc-editor.org/rfc/rfc2831]. See Net::IMAP#authenticate.
|
5
5
|
#
|
6
6
|
# == Deprecated
|
7
7
|
#
|
8
8
|
# "+DIGEST-MD5+" has been deprecated by
|
9
|
-
# RFC-6331[https://
|
9
|
+
# RFC-6331[https://www.rfc-editor.org/rfc/rfc6331] and should not be relied on for
|
10
10
|
# security. It is included for compatibility with existing servers.
|
11
11
|
class Net::IMAP::SASL::DigestMD5Authenticator
|
12
12
|
DataFormatError = Net::IMAP::DataFormatError
|
@@ -37,10 +37,10 @@ class Net::IMAP::SASL::DigestMD5Authenticator
|
|
37
37
|
|
38
38
|
# Authentication identity: the identity that matches the #password.
|
39
39
|
#
|
40
|
-
# RFC-2831[https://
|
40
|
+
# RFC-2831[https://www.rfc-editor.org/rfc/rfc2831] uses the term +username+.
|
41
41
|
# "Authentication identity" is the generic term used by
|
42
|
-
# RFC-4422[https://
|
43
|
-
# RFC-4616[https://
|
42
|
+
# RFC-4422[https://www.rfc-editor.org/rfc/rfc4422].
|
43
|
+
# RFC-4616[https://www.rfc-editor.org/rfc/rfc4616] and many later RFCs abbreviate
|
44
44
|
# this to +authcid+.
|
45
45
|
attr_reader :username
|
46
46
|
alias authcid username
|
@@ -85,7 +85,7 @@ class Net::IMAP::SASL::DigestMD5Authenticator
|
|
85
85
|
# must be set appropriately to use authenticators in other protocols.
|
86
86
|
#
|
87
87
|
# If an IANA-registered name isn't available, GSS-API
|
88
|
-
# (RFC-2743[https://
|
88
|
+
# (RFC-2743[https://www.rfc-editor.org/rfc/rfc2743]) allows the generic name
|
89
89
|
# "host".
|
90
90
|
attr_reader :service
|
91
91
|
|
@@ -93,7 +93,7 @@ class Net::IMAP::SASL::DigestMD5Authenticator
|
|
93
93
|
#
|
94
94
|
# +service_name+ will be ignored when it is +nil+ or identical to +host+.
|
95
95
|
#
|
96
|
-
# From RFC-2831[https://
|
96
|
+
# From RFC-2831[https://www.rfc-editor.org/rfc/rfc2831]:
|
97
97
|
# >>>
|
98
98
|
# The service is considered to be replicated if the client's
|
99
99
|
# service-location process involves resolution using standard DNS lookup
|
@@ -176,7 +176,7 @@ class Net::IMAP::SASL::DigestMD5Authenticator
|
|
176
176
|
@nc, @stage = {}, STAGE_ONE
|
177
177
|
end
|
178
178
|
|
179
|
-
# From RFC-2831[https://
|
179
|
+
# From RFC-2831[https://www.rfc-editor.org/rfc/rfc2831]:
|
180
180
|
# >>>
|
181
181
|
# Indicates the principal name of the service with which the client wishes
|
182
182
|
# to connect, formed from the serv-type, host, and serv-name. For
|
@@ -5,7 +5,7 @@ module Net
|
|
5
5
|
module SASL
|
6
6
|
|
7
7
|
# Authenticator for the "+EXTERNAL+" SASL mechanism, as specified by
|
8
|
-
# RFC-4422[https://
|
8
|
+
# RFC-4422[https://www.rfc-editor.org/rfc/rfc4422]. See
|
9
9
|
# Net::IMAP#authenticate.
|
10
10
|
#
|
11
11
|
# The EXTERNAL mechanism requests that the server use client credentials
|
@@ -33,7 +33,7 @@ module Net
|
|
33
33
|
# new(username = nil, **) -> authenticator
|
34
34
|
#
|
35
35
|
# Creates an Authenticator for the "+EXTERNAL+" SASL mechanism, as
|
36
|
-
# specified in RFC-4422[https://
|
36
|
+
# specified in RFC-4422[https://www.rfc-editor.org/rfc/rfc4422]. To use
|
37
37
|
# this, see Net::IMAP#authenticate or your client's authentication
|
38
38
|
# method.
|
39
39
|
#
|
@@ -5,15 +5,15 @@ module Net
|
|
5
5
|
module SASL
|
6
6
|
|
7
7
|
# Originally defined for the GS2 mechanism family in
|
8
|
-
# RFC5801[https://
|
8
|
+
# RFC5801[https://www.rfc-editor.org/rfc/rfc5801],
|
9
9
|
# several different mechanisms start with a GS2 header:
|
10
|
-
# * +GS2-*+ --- RFC5801[https://
|
11
|
-
# * +SCRAM-*+ --- RFC5802[https://
|
10
|
+
# * +GS2-*+ --- RFC5801[https://www.rfc-editor.org/rfc/rfc5801]
|
11
|
+
# * +SCRAM-*+ --- RFC5802[https://www.rfc-editor.org/rfc/rfc5802]
|
12
12
|
# (ScramAuthenticator)
|
13
|
-
# * +SAML20+ --- RFC6595[https://
|
14
|
-
# * +OPENID20+ --- RFC6616[https://
|
15
|
-
# * +OAUTH10A+ --- RFC7628[https://
|
16
|
-
# * +OAUTHBEARER+ --- RFC7628[https://
|
13
|
+
# * +SAML20+ --- RFC6595[https://www.rfc-editor.org/rfc/rfc6595]
|
14
|
+
# * +OPENID20+ --- RFC6616[https://www.rfc-editor.org/rfc/rfc6616]
|
15
|
+
# * +OAUTH10A+ --- RFC7628[https://www.rfc-editor.org/rfc/rfc7628]
|
16
|
+
# * +OAUTHBEARER+ --- RFC7628[https://www.rfc-editor.org/rfc/rfc7628]
|
17
17
|
# (OAuthBearerAuthenticator)
|
18
18
|
#
|
19
19
|
# Classes that include this module must implement +#authzid+.
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# Authenticator for the "+LOGIN+" SASL mechanism. See Net::IMAP#authenticate.
|
4
4
|
#
|
5
5
|
# +LOGIN+ authentication sends the password in cleartext.
|
6
|
-
# RFC3501[https://
|
6
|
+
# RFC3501[https://www.rfc-editor.org/rfc/rfc3501] encourages servers to disable
|
7
7
|
# cleartext authentication until after TLS has been negotiated.
|
8
|
-
# RFC8314[https://
|
8
|
+
# RFC8314[https://www.rfc-editor.org/rfc/rfc8314] recommends TLS version 1.2 or
|
9
9
|
# greater be used for all traffic, and deprecate cleartext access ASAP. +LOGIN+
|
10
10
|
# can be secured by TLS encryption.
|
11
11
|
#
|
@@ -7,7 +7,7 @@ module Net
|
|
7
7
|
module SASL
|
8
8
|
|
9
9
|
# Abstract base class for the SASL mechanisms defined in
|
10
|
-
# RFC7628[https://
|
10
|
+
# RFC7628[https://www.rfc-editor.org/rfc/rfc7628]:
|
11
11
|
# * OAUTHBEARER[rdoc-ref:OAuthBearerAuthenticator]
|
12
12
|
# (OAuthBearerAuthenticator)
|
13
13
|
# * OAUTH10A
|
@@ -52,7 +52,7 @@ module Net
|
|
52
52
|
# this may hold information about the failure reason, as JSON.
|
53
53
|
attr_reader :last_server_response
|
54
54
|
|
55
|
-
# Creates an RFC7628[https://
|
55
|
+
# Creates an RFC7628[https://www.rfc-editor.org/rfc/rfc7628] OAuth
|
56
56
|
# authenticator.
|
57
57
|
#
|
58
58
|
# ==== Parameters
|
@@ -126,12 +126,12 @@ module Net
|
|
126
126
|
end
|
127
127
|
|
128
128
|
# Authenticator for the "+OAUTHBEARER+" SASL mechanism, specified in
|
129
|
-
# RFC7628[https://
|
130
|
-
# 2.0 bearer tokens, as described in
|
131
|
-
# RFC6750[https://
|
129
|
+
# RFC7628[https://www.rfc-editor.org/rfc/rfc7628]. Authenticates using
|
130
|
+
# OAuth 2.0 bearer tokens, as described in
|
131
|
+
# RFC6750[https://www.rfc-editor.org/rfc/rfc6750]. Use via
|
132
132
|
# Net::IMAP#authenticate.
|
133
133
|
#
|
134
|
-
# RFC6750[https://
|
134
|
+
# RFC6750[https://www.rfc-editor.org/rfc/rfc6750] requires Transport Layer
|
135
135
|
# Security (TLS) to secure the protocol interaction between the client and
|
136
136
|
# the resource server. TLS _MUST_ be used for +OAUTHBEARER+ to protect
|
137
137
|
# the bearer token.
|
@@ -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
|
|
@@ -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
|
@@ -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 = +""
|
@@ -4,7 +4,7 @@ module Net
|
|
4
4
|
class IMAP
|
5
5
|
module StringPrep
|
6
6
|
|
7
|
-
# Defined in RFC3491[https://
|
7
|
+
# Defined in RFC3491[https://www.rfc-editor.org/rfc/rfc3491], the +nameprep+
|
8
8
|
# profile of "Stringprep" is:
|
9
9
|
# >>>
|
10
10
|
# used by the IDNA protocol for preparing domain names; it is not
|
@@ -4,11 +4,11 @@ module Net
|
|
4
4
|
class IMAP
|
5
5
|
module StringPrep
|
6
6
|
|
7
|
-
# Defined in RFC-4505[https://
|
7
|
+
# Defined in RFC-4505[https://www.rfc-editor.org/rfc/rfc4505] §3, The +trace+
|
8
8
|
# profile of \StringPrep is used by the +ANONYMOUS+ \SASL mechanism.
|
9
9
|
module Trace
|
10
10
|
|
11
|
-
# Defined in RFC-4505[https://
|
11
|
+
# Defined in RFC-4505[https://www.rfc-editor.org/rfc/rfc4505] §3.
|
12
12
|
STRINGPREP_PROFILE = "trace"
|
13
13
|
|
14
14
|
# >>>
|
@@ -23,7 +23,7 @@ module Net
|
|
23
23
|
# No Unicode normalization is required by this profile.
|
24
24
|
NORMALIZATION = nil
|
25
25
|
|
26
|
-
# From RFC-4505[https://
|
26
|
+
# From RFC-4505[https://www.rfc-editor.org/rfc/rfc4505] §3, The "trace"
|
27
27
|
# Profile of "Stringprep":
|
28
28
|
# >>>
|
29
29
|
# Characters from the following tables of [StringPrep] are prohibited:
|
@@ -47,7 +47,7 @@ module Net
|
|
47
47
|
|
48
48
|
module_function
|
49
49
|
|
50
|
-
# From RFC-4505[https://
|
50
|
+
# From RFC-4505[https://www.rfc-editor.org/rfc/rfc4505] §3, The "trace"
|
51
51
|
# Profile of "Stringprep":
|
52
52
|
# >>>
|
53
53
|
# The character repertoire of this profile is Unicode 3.2 [Unicode].
|