@@ -768,13 +768,12 @@ def disconnected?
768
768
# cached #capabilities are used without sending a new #capability command to
769
769
# the server.
770
770
#
771
- # <em>*NOTE:* Net::IMAP does not</em> currently <em> modify its behaviour
772
- # according to the server's advertised capabilities.</em>
771
+ # <em>*NOTE:* Most Net::IMAP methods do not _currently_ modify their
772
+ # behaviour according to the server's advertised # capabilities.</em>
773
773
#
774
774
# See Net::IMAP@Capabilities for more about \IMAP capabilities.
775
775
#
776
776
# Related: #auth_capable?, #capabilities, #capability, #enable
777
- #
778
777
def capable? ( capability ) capabilities . include? capability . to_s . upcase end
779
778
alias capability? capable?
780
779
@@ -783,12 +782,12 @@ def capable?(capability) capabilities.include? capability.to_s.upcase end
783
782
#
784
783
# To ensure a case-insensitive comparison, #capable? can be used instead.
785
784
#
786
- # <em>*NOTE:* Net::IMAP does not</em> currently <em> modify its behaviour
787
- # according to the server's advertised capabilities.</em>
785
+ # <em>*NOTE:* Most Net::IMAP methods do not _currently_ modify their
786
+ # behaviour according to the server's advertised # capabilities.</em>
788
787
#
789
788
# See Net::IMAP@Capabilities for more about \IMAP capabilities.
790
789
#
791
- # Related: #capable?, #auth_capable?, #capability
790
+ # Related: #capable?, #auth_capable?, #auth_mechanisms, # capability, #enable
792
791
def capabilities
793
792
@capabilities || capability
794
793
end
@@ -812,13 +811,7 @@ def capabilities
812
811
# imap.authenticate("XOAUTH2", username, oauth2_access_token)
813
812
# imap.auth_mechanisms # => []
814
813
#
815
- # <em>*NOTE:* Net::IMAP does not</em> currently <em>modify its behaviour
816
- # according to the server's advertised capabilities.</em>
817
- #
818
- # See Net::IMAP@Capabilities for more about \IMAP capabilities.
819
- #
820
- # Related: #auth_capable?, #capabilities
821
- #
814
+ # Related: #authenticate, #auth_capable?, #capabilities
822
815
def auth_mechanisms
823
816
capabilities
824
817
. grep ( /\A AUTH=/i )
@@ -835,12 +828,7 @@ def auth_mechanisms
835
828
# imap.auth_capable? "PLAIN" # => true
836
829
# imap.auth_capable? "blurdybloop" # => false
837
830
#
838
- # <em>*NOTE:* Net::IMAP does not</em> currently <em>modify its behaviour
839
- # according to the server's advertised capabilities.</em>
840
- #
841
- # See Net::IMAP@Capabilities for more about \IMAP capabilities.
842
- #
843
- # Related: #authenticate, #capable?, #capabilities
831
+ # Related: #authenticate, #auth_mechanisms, #capable?, #capabilities
844
832
def auth_capable? ( mechanism )
845
833
capable? "AUTH=#{ mechanism } "
846
834
end
@@ -875,8 +863,8 @@ def clear_cached_capabilities
875
863
# and returns an array of capabilities that are supported by the server.
876
864
# The result is stored for use by #capable? and #capabilities.
877
865
#
878
- # <em>*NOTE:* Net::IMAP does not</em> currently <em> modify its behaviour
879
- # according to the server's advertised capabilities.</em>
866
+ # <em>*NOTE:* Most Net::IMAP methods do not _currently_ modify their
867
+ # behaviour according to the server's advertised # capabilities.</em>
880
868
#
881
869
# Net::IMAP automatically stores and discards capability data according to
882
870
# the requirements and recommendations in
@@ -992,82 +980,76 @@ def starttls(options = {}, verify = true)
992
980
end
993
981
994
982
# :call-seq:
995
- # authenticate(mechanism, ...) -> ok_resp
996
- # authenticate(mech, *creds, sasl_ir: true, **attrs, &callback) -> ok_resp
983
+ # authenticate(mechanism, *, sasl_ir: true, **, &) -> ok_resp
997
984
#
998
985
# Sends an {AUTHENTICATE command [IMAP4rev1 §6.2.2]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.2.2]
999
986
# to authenticate the client. If successful, the connection enters the
1000
987
# "_authenticated_" state.
1001
988
#
1002
989
# +mechanism+ is the name of the \SASL authentication mechanism to be used.
990
+ #
1003
991
# +sasl_ir+ allows or disallows sending an "initial response" (see the
1004
- # +SASL-IR+ capability, below). All other arguments are forwarded to the
1005
- # registered SASL authenticator for the requested mechanism. <em>The
1006
- # documentation for each individual mechanism must be consulted for its
1007
- # specific parameters.</em>
992
+ # +SASL-IR+ capability, below).
1008
993
#
1009
- # An exception Net::IMAP::NoResponseError is raised if authentication fails.
994
+ # All other arguments are forwarded to the registered SASL authenticator for
995
+ # the requested mechanism. <em>The documentation for each individual
996
+ # mechanism must be consulted for its specific parameters.</em>
1010
997
#
1011
998
# Related: #login, #starttls, #auth_capable?, #auth_mechanisms
1012
999
#
1013
- # ==== Supported SASL Mechanisms
1000
+ # ==== Mechanisms
1014
1001
#
1015
- # +PLAIN+:: See PlainAuthenticator.
1016
- # Login using clear-text username and password.
1002
+ # Each mechanism has different properties and requirements. Please consult
1003
+ # the documentation for the specific mechanisms you are using:
1017
1004
#
1018
- # +XOAUTH2+:: See XOAuth2Authenticator.
1019
- # Login using a username and OAuth2 access token.
1020
- # Non-standard and obsoleted by +OAUTHBEARER+, but widely
1021
- # supported.
1005
+ # +PLAIN+::
1006
+ # See PlainAuthenticator[Net::IMAP::SASL::PlainAuthenticator].
1022
1007
#
1023
- # >>>
1024
- # *Deprecated:* <em>Obsolete mechanisms are available for backwards
1025
- # compatibility.</em>
1008
+ # Login using clear-text username and password.
1026
1009
#
1027
- # For +DIGEST-MD5+ see DigestMD5Authenticator.
1010
+ # +XOAUTH2+::
1011
+ # See XOAuth2Authenticator[Net::IMAP::SASL::XOAuth2Authenticator].
1028
1012
#
1029
- # For +LOGIN+, see LoginAuthenticator.
1013
+ # Login using a username and an OAuth2 access token. Non-standard and
1014
+ # obsoleted by +OAUTHBEARER+, but widely supported.
1030
1015
#
1031
- # For +CRAM-MD5+, see CramMD5Authenticator.
1016
+ # See the {SASL mechanism
1017
+ # registry}[https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml]
1018
+ # for a list of all SASL mechanisms and their specifications. To register
1019
+ # new authenticators, see Authenticators.
1032
1020
#
1033
- # <em>Using a deprecated mechanism will print a warning.</em>
1021
+ # ===== Deprecated mechanisms
1034
1022
#
1035
- # See Net::IMAP::Authenticators for information on plugging in
1036
- # authenticators for other mechanisms. See the {SASL mechanism
1037
- # registry}[https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml]
1038
- # for information on these and other SASL mechanisms.
1023
+ # <em>Obsolete mechanisms should be avoided, but are still available for
1024
+ # backwards compatibility. See</em> Net::IMAP::SASL@Deprecated+mechanisms.
1025
+ # <em>Using a deprecated mechanism will print a warning.</em>
1039
1026
#
1040
- # ===== Capabilities
1027
+ # ==== Capabilities
1041
1028
#
1042
- # The server should list <tt>"AUTH=#{mechanism}"</tt> capabilities for
1043
- # supported mechanisms. Check #auth_capable? or #auth_mechanisms before
1044
- # using a particular mechanism.
1029
+ # <tt>"AUTH=#{mechanism}"</tt> capabilities indicate server support for
1030
+ # mechanisms. Use #auth_capable? or #auth_mechanisms to check for support
1031
+ # before using a particular mechanism.
1045
1032
#
1046
1033
# if imap.auth_capable? "XOAUTH2"
1047
1034
# imap.authenticate "XOAUTH2", username, oauth2_access_token
1048
1035
# elsif imap.auth_capable? "PLAIN"
1049
1036
# imap.authenticate "PLAIN", username, password
1050
- # elsif imap.auth_capable? "DIGEST-MD5"
1051
- # imap.authenticate "DIGEST-MD5", username, password
1052
1037
# elsif !imap.capability? "LOGINDISABLED"
1053
1038
# imap.login username, password
1054
1039
# else
1055
1040
# raise "No acceptable authentication mechanism is available"
1056
1041
# end
1057
1042
#
1058
- # The SASL exchange provides a method for server challenges and client
1059
- # responses, but many mechanisms expect the client to "respond" first. When
1060
- # the server's capabilities include +SASL-IR+
1061
- # [RFC4959[https://tools.ietf.org/html/rfc4959]], this "initial response"
1062
- # may be sent as an argument to the +AUTHENTICATE+ command, saving a
1063
- # round-trip. The initial response will _only_ be sent when it is supported
1064
- # by both the mechanism and the server. Set +sasl_ir+ to +false+ to prevent
1065
- # sending an initial response, even when it is supported.
1043
+ # Although servers should list all supported \SASL mechanisms, they may
1044
+ # allow authentication with an unlisted +mechanism+.
1066
1045
#
1067
- # Although servers _should_ advertise all supported auth mechanisms, it is
1068
- # possible to attempt to authenticate with a +mechanism+ that isn't listed.
1069
- # However the initial response will not be sent unless the appropriate
1070
- # <tt>"AUTH=#{mechanism}"</tt> capability is also present.
1046
+ # If [SASL-IR[https://www.rfc-editor.org/rfc/rfc4959.html]] is supported
1047
+ # and the appropriate <tt>"AUTH=#{mechanism}"</tt> capability is present,
1048
+ # an "initial response" may be sent as an argument to the +AUTHENTICATE+
1049
+ # command, saving a round-trip. The SASL exchange allows for server
1050
+ # challenges and client responses, but many mechanisms expect the client to
1051
+ # "respond" first. The initial response will only be sent for
1052
+ # "client-first" mechanisms.
1071
1053
#
1072
1054
# Server capabilities may change after #starttls, #login, and #authenticate.
1073
1055
# Previously cached #capabilities will be cleared when this method
@@ -1098,8 +1080,10 @@ def authenticate(mechanism, *creds, sasl_ir: true, **props, &callback)
1098
1080
# this +user+. If successful, the connection enters the "_authenticated_"
1099
1081
# state.
1100
1082
#
1101
- # Using #authenticate is generally preferred over #login. The LOGIN command
1102
- # is not the same as #authenticate with the "LOGIN" +mechanism+.
1083
+ # Using #authenticate {should be
1084
+ # preferred}[https://www.rfc-editor.org/rfc/rfc9051.html#name-login-command]
1085
+ # over #login. The LOGIN command is not the same as #authenticate with the
1086
+ # "LOGIN" +mechanism+.
1103
1087
#
1104
1088
# A Net::IMAP::NoResponseError is raised if authentication fails.
1105
1089
#
0 commit comments