util/sasl.lua

changeset 50
56272224ca4c
parent 38
3fdfd6e0cb4e
child 276
30893439d5d1
equal deleted inserted replaced
49:1cd2a8db392d 50:56272224ca4c
17 if stanza.attr.xmlns ~= "urn:ietf:params:xml:ns:xmpp-sasl" then self.onFail("invalid-stanza-namespace") end 17 if stanza.attr.xmlns ~= "urn:ietf:params:xml:ns:xmpp-sasl" then self.onFail("invalid-stanza-namespace") end
18 local response = base64.decode(stanza[1]) 18 local response = base64.decode(stanza[1])
19 local authorization = s_match(response, "([^&%z]+)") 19 local authorization = s_match(response, "([^&%z]+)")
20 local authentication = s_match(response, "%z([^&%z]+)%z") 20 local authentication = s_match(response, "%z([^&%z]+)%z")
21 local password = s_match(response, "%z[^&%z]+%z([^&%z]+)") 21 local password = s_match(response, "%z[^&%z]+%z([^&%z]+)")
22 if self.onAuth(authorization, password) == true then 22 if self.onAuth(authentication, password) == true then
23 self.onWrite(st.stanza("success", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"})) 23 self.onWrite(st.stanza("success", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"}))
24 self.onSuccess(authentication) 24 self.onSuccess(authentication)
25 else 25 else
26 self.onWrite(st.stanza("failure", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"}):tag("temporary-auth-failure")); 26 self.onWrite(st.stanza("failure", {xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"}):tag("temporary-auth-failure"));
27 end 27 end

mercurial