Skip to content

Commit

Permalink
🚨 SASL: add_authenticator warns on reassignment (🚧 ???)
Browse files Browse the repository at this point in the history
The question is: do we even want to this?
  • Loading branch information
nevans committed Jun 22, 2024
1 parent f675169 commit b398b46
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/net/imap/sasl/authenticators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def names; @authenticators.keys end
# When only a single argument is given, the authenticator class will be
# lazily loaded from <tt>Net::IMAP::SASL::#{name}Authenticator</tt> (case is
# preserved and non-alphanumeric characters are removed..
def add_authenticator(name, authenticator = nil)
def add_authenticator(name, authenticator = nil, warn_overwrite: true)
key = -name.to_s.upcase.tr(?_, ?-)
authenticator ||= begin
class_name = "#{name.gsub(/[^a-zA-Z0-9]/, "")}Authenticator".to_sym
Expand All @@ -74,6 +74,11 @@ def add_authenticator(name, authenticator = nil)
auth_class.new(*creds, **props, &block)
}
end
if warn_overwrite && (original = @authenticators[key])
warn("%p: replacing existing %p authenticator: %p" % [
self, key, original
], uplevel: 1)
end
@authenticators[key] = authenticator
end

Expand Down

0 comments on commit b398b46

Please sign in to comment.