net-imap 0.2.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ea332e9eb05f1d978f8071be747359ef37109b6250b63d2d7681ca13464447b
4
- data.tar.gz: 0f38117a229089826b847185734cc558d8c81410c4db67cc4b2e9c07218a339b
3
+ metadata.gz: a91d908ae16db12c507a6cf5c0e5eef57e18c97473b2a13a0ab14cf655e9bcb7
4
+ data.tar.gz: 1bdab36cf0779d14e2f414e00aee90d95d2584bfc8d591c11d5104b4071bebb8
5
5
  SHA512:
6
- metadata.gz: 39b06bd45b38bcb822e9a693ba6c7182bbf11c87f55805ab8a2e36fa357e53a2a6ac209eb348b37e3b56aa5c8dadb616570613f6b9f132249a7b94bb3a349073
7
- data.tar.gz: 59af9d5f203bb10bc5a4851718945d314827deae445468752d1bd5b5e93e250f054076cc8d6cb68edfce7a289db87597277ac8facc0e208556c7ea553d564bb8
6
+ metadata.gz: 65133026b0746efbdc55a64bd1091da0524e5b922672767f334cec1d0357b31b973380bc8e787ff2430b831375f52050004d718b6308fa9203c9f6710ac2444b
7
+ data.tar.gz: 7e5e9fcac352549585e38b5a86b0198cc1c5996ad129cf9e53ca92f2ef63ea4b37d26ab8c5efd641b19711b2ea04e42622ead203c3afcaa8d420ceaaaa9893c8
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'weekly'
@@ -7,7 +7,7 @@ jobs:
7
7
  name: build (${{ matrix.ruby }} / ${{ matrix.os }})
8
8
  strategy:
9
9
  matrix:
10
- ruby: [ head, '3.0', '2.7' ]
10
+ ruby: [ head, '3.1', '3.0', '2.7' ]
11
11
  os: [ ubuntu-latest, macos-latest ]
12
12
  experimental: [false]
13
13
  include:
@@ -20,7 +20,7 @@ jobs:
20
20
  runs-on: ${{ matrix.os }}
21
21
  continue-on-error: ${{ matrix.experimental }}
22
22
  steps:
23
- - uses: actions/checkout@v2
23
+ - uses: actions/checkout@v3
24
24
  - name: Set up Ruby
25
25
  uses: ruby/setup-ruby@v1
26
26
  with:
data/LICENSE.txt CHANGED
@@ -20,3 +20,65 @@ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
20
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
21
  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
22
  SUCH DAMAGE.
23
+
24
+ -------------------------------------------------------------------------
25
+
26
+ This software includes documentation which has been copied from the relevant
27
+ RFCs. The copied documentation is covered by the following licenses:
28
+
29
+ RFC 3501 (Editor: M. Crispin)
30
+ Full Copyright Statement
31
+
32
+ Copyright (C) The Internet Society (2003). All Rights Reserved.
33
+
34
+ This document and translations of it may be copied and furnished to
35
+ others, and derivative works that comment on or otherwise explain it
36
+ or assist in its implementation may be prepared, copied, published
37
+ and distributed, in whole or in part, without restriction of any
38
+ kind, provided that the above copyright notice and this paragraph are
39
+ included on all such copies and derivative works. However, this
40
+ document itself may not be modified in any way, such as by removing
41
+ the copyright notice or references to the Internet Society or other
42
+ Internet organizations, except as needed for the purpose of
43
+ developing Internet standards in which case the procedures for
44
+ copyrights defined in the Internet Standards process must be
45
+ followed, or as required to translate it into languages other than
46
+ English.
47
+
48
+ The limited permissions granted above are perpetual and will not be
49
+ revoked by the Internet Society or its successors or assigns. v This
50
+ document and the information contained herein is provided on an "AS
51
+ IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK
52
+ FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT
53
+ LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL
54
+ NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY
55
+ OR FITNESS FOR A PARTICULAR PURPOSE.
56
+
57
+
58
+ RFC9051 (Editors: A. Melnikov, B. Leiba)
59
+ Copyright Notice
60
+
61
+ Copyright (c) 2021 IETF Trust and the persons identified as the
62
+ document authors. All rights reserved.
63
+
64
+ This document is subject to BCP 78 and the IETF Trust's Legal
65
+ Provisions Relating to IETF Documents
66
+ (https://trustee.ietf.org/license-info) in effect on the date of
67
+ publication of this document. Please review these documents
68
+ carefully, as they describe your rights and restrictions with respect
69
+ to this document. Code Components extracted from this document must
70
+ include Simplified BSD License text as described in Section 4.e of
71
+ the Trust Legal Provisions and are provided without warranty as
72
+ described in the Simplified BSD License.
73
+
74
+ This document may contain material from IETF Documents or IETF
75
+ Contributions published or made publicly available before November
76
+ 10, 2008. The person(s) controlling the copyright in some of this
77
+ material may not have granted the IETF Trust the right to allow
78
+ modifications of such material outside the IETF Standards Process.
79
+ Without obtaining an adequate license from the person(s) controlling
80
+ the copyright in such materials, this document may not be modified
81
+ outside the IETF Standards Process, and derivative works of it may
82
+ not be created outside the IETF Standards Process, except to format
83
+ it for publication as an RFC or to translate it into languages other
84
+ than English.
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "digest/md5"
4
-
5
3
  # Authenticator for the "+CRAM-MD5+" SASL mechanism, specified in
6
4
  # RFC2195[https://tools.ietf.org/html/rfc2195]. See Net::IMAP#authenticate.
7
5
  #
@@ -23,7 +21,11 @@ class Net::IMAP::CramMD5Authenticator
23
21
 
24
22
  private
25
23
 
26
- def initialize(user, password)
24
+ def initialize(user, password, warn_deprecation: true, **_ignored)
25
+ if warn_deprecation
26
+ warn "WARNING: CRAM-MD5 mechanism is deprecated." # TODO: recommend SCRAM
27
+ end
28
+ require "digest/md5"
27
29
  @user = user
28
30
  @password = password
29
31
  end
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "digest/md5"
4
- require "strscan"
5
-
6
3
  # Net::IMAP authenticator for the "`DIGEST-MD5`" SASL mechanism type, specified
7
4
  # in RFC2831(https://tools.ietf.org/html/rfc2831). See Net::IMAP#authenticate.
8
5
  #
@@ -29,8 +26,8 @@ class Net::IMAP::DigestMD5Authenticator
29
26
  sparams[k] = v
30
27
  end
31
28
 
32
- raise DataFormatError, "Bad Challenge: '#{challenge}'" unless c.rest.size == 0
33
- raise Error, "Server does not support auth (qop = #{sparams['qop'].join(',')})" unless sparams['qop'].include?("auth")
29
+ raise Net::IMAP::DataFormatError, "Bad Challenge: '#{challenge}'" unless c.eos?
30
+ raise Net::IMAP::Error, "Server does not support auth (qop = #{sparams['qop'].join(',')})" unless sparams['qop'].include?("auth")
34
31
 
35
32
  response = {
36
33
  :nonce => sparams['nonce'],
@@ -77,11 +74,18 @@ class Net::IMAP::DigestMD5Authenticator
77
74
  end
78
75
  end
79
76
 
80
- def initialize(user, password, authname = nil)
77
+ def initialize(user, password, authname = nil, warn_deprecation: true)
78
+ if warn_deprecation
79
+ warn "WARNING: DIGEST-MD5 SASL mechanism was deprecated by RFC6331."
80
+ # TODO: recommend SCRAM instead.
81
+ end
82
+ require "digest/md5"
83
+ require "strscan"
81
84
  @user, @password, @authname = user, password, authname
82
85
  @nc, @stage = {}, STAGE_ONE
83
86
  end
84
87
 
88
+
85
89
  private
86
90
 
87
91
  STAGE_ONE = :stage_one
@@ -100,7 +104,7 @@ class Net::IMAP::DigestMD5Authenticator
100
104
  def qdval(k, v)
101
105
  return if k.nil? or v.nil?
102
106
  if %w"username authzid realm nonce cnonce digest-uri qop".include? k
103
- v.gsub!(/([\\"])/, "\\\1")
107
+ v = v.gsub(/([\\"])/, "\\\1")
104
108
  return '%s="%s"' % [k, v]
105
109
  else
106
110
  return '%s=%s' % [k, v]
@@ -33,7 +33,10 @@ class Net::IMAP::LoginAuthenticator
33
33
  STATE_USER = :USER
34
34
  STATE_PASSWORD = :PASSWORD
35
35
 
36
- def initialize(user, password)
36
+ def initialize(user, password, warn_deprecation: true, **_ignored)
37
+ if warn_deprecation
38
+ warn "WARNING: LOGIN SASL mechanism is deprecated. Use PLAIN instead."
39
+ end
37
40
  @user = user
38
41
  @password = password
39
42
  @state = STATE_USER
@@ -19,13 +19,15 @@ module Net::IMAP::Authenticators
19
19
 
20
20
  # Builds an authenticator for Net::IMAP#authenticate. +args+ will be passed
21
21
  # directly to the chosen authenticator's +#initialize+.
22
- def authenticator(auth_type, *args)
23
- auth_type = auth_type.upcase
24
- unless authenticators.has_key?(auth_type)
25
- raise ArgumentError,
26
- format('unknown auth type - "%s"', auth_type)
22
+ def authenticator(mechanism, *authargs, **properties, &callback)
23
+ authenticator = authenticators.fetch(mechanism.upcase) do
24
+ raise ArgumentError, 'unknown auth type - "%s"' % mechanism
25
+ end
26
+ if authenticator.respond_to?(:new)
27
+ authenticator.new(*authargs, **properties, &callback)
28
+ else
29
+ authenticator.call(*authargs, **properties, &callback)
27
30
  end
28
- authenticators[auth_type].new(*args)
29
31
  end
30
32
 
31
33
  private
@@ -38,7 +40,8 @@ end
38
40
 
39
41
  Net::IMAP.extend Net::IMAP::Authenticators
40
42
 
41
- require_relative "authenticators/login"
42
43
  require_relative "authenticators/plain"
44
+
45
+ require_relative "authenticators/login"
43
46
  require_relative "authenticators/cram_md5"
44
47
  require_relative "authenticators/digest_md5"
data/lib/net/imap.rb CHANGED
@@ -220,7 +220,7 @@ module Net
220
220
  # Unicode", RFC-2152[https://tools.ietf.org/html/rfc2152], May 1997.
221
221
  #
222
222
  class IMAP < Protocol
223
- VERSION = "0.2.4"
223
+ VERSION = "0.3.0"
224
224
 
225
225
  include MonitorMixin
226
226
  if defined?(OpenSSL::SSL)
@@ -378,28 +378,37 @@ module Net
378
378
  # Sends an AUTHENTICATE command to authenticate the client.
379
379
  # The +auth_type+ parameter is a string that represents
380
380
  # the authentication mechanism to be used. Currently Net::IMAP
381
- # supports the authentication mechanisms:
382
- #
383
- # LOGIN:: login using cleartext user and password.
384
- # CRAM-MD5:: login with cleartext user and encrypted password
385
- # (see [RFC-2195] for a full description). This
386
- # mechanism requires that the server have the user's
387
- # password stored in clear-text password.
388
- #
389
- # For both of these mechanisms, there should be two +args+: username
390
- # and (cleartext) password. A server may not support one or the other
391
- # of these mechanisms; check #capability for a capability of
392
- # the form "AUTH=LOGIN" or "AUTH=CRAM-MD5".
393
- #
394
- # Authentication is done using the appropriate authenticator object:
395
- # see +add_authenticator+ for more information on plugging in your own
396
- # authenticator.
381
+ # supports the following mechanisms:
382
+ #
383
+ # PLAIN:: Login using cleartext user and password. Secure with TLS.
384
+ # See Net::IMAP::PlainAuthenticator.
385
+ # CRAM-MD5:: DEPRECATED: Use PLAIN (or DIGEST-MD5) with TLS.
386
+ # DIGEST-MD5:: DEPRECATED by RFC6331. Must be secured using TLS.
387
+ # See Net::IMAP::DigestMD5Authenticator.
388
+ # LOGIN:: DEPRECATED: Use PLAIN.
389
+ #
390
+ # Most mechanisms require two args: authentication identity (e.g. username)
391
+ # and credentials (e.g. a password). But each mechanism requires and allows
392
+ # different arguments; please consult the documentation for the specific
393
+ # mechanisms you are using. <em>Several obsolete mechanisms are available
394
+ # for backwards compatibility. Using deprecated mechanisms will issue
395
+ # warnings.</em>
396
+ #
397
+ # Servers do not support all mechanisms and clients must not attempt to use
398
+ # a mechanism unless "AUTH=#{mechanism}" is listed as a #capability.
399
+ # Clients must not attempt to authenticate or #login when +LOGINDISABLED+ is
400
+ # listed with the capabilities. Server capabilities, especially auth
401
+ # mechanisms, do change after calling #starttls so they need to be checked
402
+ # again.
397
403
  #
398
404
  # For example:
399
405
  #
400
- # imap.authenticate('LOGIN', user, password)
406
+ # imap.authenticate('PLAIN', user, password)
401
407
  #
402
408
  # A Net::IMAP::NoResponseError is raised if authentication fails.
409
+ #
410
+ # See +Net::IMAP::Authenticators+ for more information on plugging in your
411
+ # own authenticator.
403
412
  def authenticate(auth_type, *args)
404
413
  authenticator = self.class.authenticator(auth_type, *args)
405
414
  send_command("AUTHENTICATE", auth_type) do |resp|
data/net-imap.gemspec CHANGED
@@ -10,8 +10,8 @@ end
10
10
  Gem::Specification.new do |spec|
11
11
  spec.name = name
12
12
  spec.version = version
13
- spec.authors = ["Shugo Maeda"]
14
- spec.email = ["shugo@ruby-lang.org"]
13
+ spec.authors = ["Shugo Maeda", "nicholas a. evans"]
14
+ spec.email = ["shugo@ruby-lang.org", "nick@ekenosen.net"]
15
15
 
16
16
  spec.summary = %q{Ruby client api for Internet Message Access Protocol}
17
17
  spec.description = %q{Ruby client api for Internet Message Access Protocol}
@@ -32,6 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.require_paths = ["lib"]
33
33
 
34
34
  spec.add_dependency "net-protocol"
35
- spec.add_dependency "digest"
36
- spec.add_dependency "strscan"
35
+ spec.add_development_dependency "digest"
36
+ spec.add_development_dependency "strscan"
37
37
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-imap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
8
+ - nicholas a. evans
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2024-01-05 00:00:00.000000000 Z
12
+ date: 2022-09-28 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: net-protocol
@@ -31,7 +32,7 @@ dependencies:
31
32
  - - ">="
32
33
  - !ruby/object:Gem::Version
33
34
  version: '0'
34
- type: :runtime
35
+ type: :development
35
36
  prerelease: false
36
37
  version_requirements: !ruby/object:Gem::Requirement
37
38
  requirements:
@@ -45,7 +46,7 @@ dependencies:
45
46
  - - ">="
46
47
  - !ruby/object:Gem::Version
47
48
  version: '0'
48
- type: :runtime
49
+ type: :development
49
50
  prerelease: false
50
51
  version_requirements: !ruby/object:Gem::Requirement
51
52
  requirements:
@@ -55,10 +56,12 @@ dependencies:
55
56
  description: Ruby client api for Internet Message Access Protocol
56
57
  email:
57
58
  - shugo@ruby-lang.org
59
+ - nick@ekenosen.net
58
60
  executables: []
59
61
  extensions: []
60
62
  extra_rdoc_files: []
61
63
  files:
64
+ - ".github/dependabot.yml"
62
65
  - ".github/workflows/test.yml"
63
66
  - ".gitignore"
64
67
  - Gemfile
@@ -100,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
103
  - !ruby/object:Gem::Version
101
104
  version: '0'
102
105
  requirements: []
103
- rubygems_version: 3.3.27
106
+ rubygems_version: 3.4.0.dev
104
107
  signing_key:
105
108
  specification_version: 4
106
109
  summary: Ruby client api for Internet Message Access Protocol