Skip to content

Commit

Permalink
🚨 SASL: add_authenticator warns on reassignment [🚧WIP: no test]
Browse files Browse the repository at this point in the history
  • Loading branch information
nevans committed Jun 12, 2023
1 parent bf4bee6 commit 078ea33
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/net/imap/authenticators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ module Net::IMAP::Authenticators
# {SASL mechanism}[https://www.iana.org/assignments/sasl-mechanisms/sasl-mechanisms.xhtml]
# implemented by +authenticator+ (for instance, <tt>"PLAIN"</tt>).
#
# If +mechanism+ refers to an existing authenticator, a warning will be
# printed and the old authenticator will be replaced.
#
# The +authenticator+ must respond to +#new+ (or #call), receiving the
# authenticator configuration and return a configured authentication session.
# The authenticator session must respond to +#process+, receiving the server's
# challenge and returning the client's response.
#
# See PlainAuthenticator, XOauth2Authenticator, and DigestMD5Authenticator for
# examples.
def add_authenticator(auth_type, authenticator)
authenticators[auth_type] = authenticator
def add_authenticator(mechanism, authenticator, warn_overwrite: true)
if warn_overwrite && (original = authenticators[mechanism])
warn("%p: replacing %p authenticator: %p" % [ self, mechanism, original],
uplevel: 1)
end
authenticators[mechanism] = authenticator
end

# :call-seq:
Expand Down

0 comments on commit 078ea33

Please sign in to comment.