Software / code / prosody
Comparison
util/sasl.lua @ 1725:fb3137652ea6
Uncertain merge with 0.5's SASL
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Thu, 20 Aug 2009 13:57:50 +0100 |
| parent | 1657:1fe566011e2b |
| parent | 1724:7682a34c13d0 |
| child | 2078:a5f154548154 |
comparison
equal
deleted
inserted
replaced
| 1719:cf103398e643 | 1725:fb3137652ea6 |
|---|---|
| 36 local function new_plain(realm, credentials_handler) | 36 local function new_plain(realm, credentials_handler) |
| 37 local object = { mechanism = "PLAIN", realm = realm, credentials_handler = credentials_handler} | 37 local object = { mechanism = "PLAIN", realm = realm, credentials_handler = credentials_handler} |
| 38 function object.feed(self, message) | 38 function object.feed(self, message) |
| 39 if message == "" or message == nil then return "failure", "malformed-request" end | 39 if message == "" or message == nil then return "failure", "malformed-request" end |
| 40 local response = message | 40 local response = message |
| 41 local authorization = s_match(response, "([^&%z]+)") | 41 local authorization = s_match(response, "([^%z]+)") |
| 42 local authentication = s_match(response, "%z([^&%z]+)%z") | 42 local authentication = s_match(response, "%z([^%z]+)%z") |
| 43 local password = s_match(response, "%z[^&%z]+%z([^&%z]+)") | 43 local password = s_match(response, "%z[^%z]+%z([^%z]+)") |
| 44 | 44 |
| 45 if authentication == nil or password == nil then return "failure", "malformed-request" end | 45 if authentication == nil or password == nil then return "failure", "malformed-request" end |
| 46 self.username = authentication | 46 self.username = authentication |
| 47 local auth_success = self.credentials_handler("PLAIN", self.username, self.realm, password) | 47 local auth_success = self.credentials_handler("PLAIN", self.username, self.realm, password) |
| 48 | 48 |
| 126 end | 126 end |
| 127 end | 127 end |
| 128 return t_concat(p); | 128 return t_concat(p); |
| 129 end | 129 end |
| 130 local function parse(data) | 130 local function parse(data) |
| 131 message = {} | 131 local message = {} |
| 132 for k, v in gmatch(data, [[([%w%-]+)="?([^",]*)"?,?]]) do -- FIXME The hacky regex makes me shudder | 132 for k, v in gmatch(data, [[([%w%-]+)="?([^",]*)"?,?]]) do -- FIXME The hacky regex makes me shudder |
| 133 message[k] = v; | 133 message[k] = v; |
| 134 end | 134 end |
| 135 return message; | 135 return message; |
| 136 end | 136 end |