Skip to content

Commit

Permalink
Set a priority for authentication mechanisms (digest-md5, plain, anon…
Browse files Browse the repository at this point in the history
…ymous)

This way we don't have to worry about what order the mechanisms are in when
sent from the server.
  • Loading branch information
sprsquish committed Oct 30, 2009
1 parent 2715188 commit 6437415
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
@@ -1,3 +1,6 @@
v0.4.6
Bugfix: prioritize authentication mechanisms

v0.4.5
Bugfix: Change DSL#write to DSL#write_to_stream. Previous way was messing with YAML

Expand Down
2 changes: 1 addition & 1 deletion lib/blather/stream.rb
Expand Up @@ -80,7 +80,7 @@ def connection_completed # :nodoc:
# Called by EM with data from the wire
def receive_data(data) # :nodoc:
Blather.logger.debug "\n#{'-'*30}\n"
Blather.logger.debug "<< #{data}"
Blather.logger.debug "STREAM IN: #{data}"
@parser << data

rescue ParseError => e
Expand Down
9 changes: 8 additions & 1 deletion lib/blather/stream/features/sasl.rb
Expand Up @@ -6,6 +6,12 @@ class UnknownMechanism < BlatherError
register :sasl_unknown_mechanism
end

MECHANISMS = %w[
digest-md5
plain
anonymous
].freeze

SASL_NS = 'urn:ietf:params:xml:ns:xmpp-sasl'.freeze
register SASL_NS

Expand All @@ -20,7 +26,8 @@ def receive_data(stanza)
@node = stanza
case stanza.element_name
when 'mechanisms'
@mechanisms = stanza.children.map { |m| m.content.downcase }
available_mechanisms = stanza.children.map { |m| m.content.downcase }
@mechanisms = MECHANISMS.select { |m| available_mechanisms.include? m }
next!
when 'failure'
next!
Expand Down

0 comments on commit 6437415

Please sign in to comment.