Software /
code /
prosody
Comparison
util/sasl/plain.lua @ 3095:3e0d9ed57283
util.sasl.plain: Removing plain_hashed authentication provider. Just do hashing and comparison yourself in a plain_test authentication provider.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Fri, 21 May 2010 23:40:29 +0200 |
parent | 3094:5f625411b463 |
child | 3080:8e842989ced2 |
comparison
equal
deleted
inserted
replaced
3094:5f625411b463 | 3095:3e0d9ed57283 |
---|---|
30 | 30 |
31 plain-test: | 31 plain-test: |
32 function(username, realm, password) | 32 function(username, realm, password) |
33 return true or false, state; | 33 return true or false, state; |
34 end | 34 end |
35 | |
36 plain-hashed: | |
37 function(username, realm) | |
38 return hashed_password, hash_function, state; | |
39 end | |
40 ]] | 35 ]] |
41 | 36 |
42 local function plain(self, message) | 37 local function plain(self, message) |
43 if not message then | 38 if not message then |
44 return "failure", "malformed-request"; | 39 return "failure", "malformed-request"; |
64 local correct_password; | 59 local correct_password; |
65 correct_password, state = self.profile.plain(authentication, self.realm); | 60 correct_password, state = self.profile.plain(authentication, self.realm); |
66 if correct_password == password then correct = true; else correct = false; end | 61 if correct_password == password then correct = true; else correct = false; end |
67 elseif self.profile.plain_test then | 62 elseif self.profile.plain_test then |
68 correct, state = self.profile.plain_test(authentication, self.realm, password); | 63 correct, state = self.profile.plain_test(authentication, self.realm, password); |
69 elseif self.profile.plain_hashed then | |
70 local hashed_password, hash_f; | |
71 hashed_password, hash_f, state = self.profile.plain_hashed(authentication, self.realm); | |
72 if hashed_password == hash_f(password) then correct = true; else correct = false; end | |
73 end | 64 end |
74 | 65 |
75 self.username = authentication | 66 self.username = authentication |
76 if not state then | 67 if not state then |
77 return "failure", "account-disabled"; | 68 return "failure", "account-disabled"; |
83 return "failure", "not-authorized", "Unable to authorize you with the authentication credentials you've sent."; | 74 return "failure", "not-authorized", "Unable to authorize you with the authentication credentials you've sent."; |
84 end | 75 end |
85 end | 76 end |
86 | 77 |
87 function init(registerMechanism) | 78 function init(registerMechanism) |
88 registerMechanism("PLAIN", {"plain", "plain_test", "plain_hashed"}, plain); | 79 registerMechanism("PLAIN", {"plain", "plain_test"}, plain); |
89 end | 80 end |
90 | 81 |
91 return _M; | 82 return _M; |