7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/vines/backdoor/auth.rb', line 7
def auth(node)
raise StreamErrors::NotAuthorized unless auth?(node)
node = node.xpath('ns:auth', 'ns' => NS).first
if node.text.empty?
send_auth_fail(SaslErrors::MalformedRequest.new)
elsif stream.authentication_mechanisms.include?(node[MECHANISM])
if node[MECHANISM] == INTERNAL
stream.user = authenticate(node.text) or raise StreamErrors::NotAuthorized
end
else
send_auth_fail(SaslErrors::InvalidMechanism.new)
end
end
|