Comparison

util/sasl/plain.lua @ 8095:57192cf193c7

util.sasl.plain,scram: Record username in sasl state earlier
author Kim Alvefur <zash@zash.se>
date Wed, 19 Apr 2017 06:47:02 +0200
parent 6777:5de6b93d0190
child 8555:4f0f5b49bb03
comparison
equal deleted inserted replaced
8094:dcda2ae4569d 8095:57192cf193c7
61 if not authentication or authentication == "" then 61 if not authentication or authentication == "" then
62 return "failure", "malformed-request", "Invalid username or password." 62 return "failure", "malformed-request", "Invalid username or password."
63 end 63 end
64 end 64 end
65 65
66 self.username = authentication
67
66 local correct, state = false, false; 68 local correct, state = false, false;
67 if self.profile.plain then 69 if self.profile.plain then
68 local correct_password; 70 local correct_password;
69 correct_password, state = self.profile.plain(self, authentication, self.realm); 71 correct_password, state = self.profile.plain(self, authentication, self.realm);
70 correct = (correct_password == password); 72 correct = (correct_password == password);
71 elseif self.profile.plain_test then 73 elseif self.profile.plain_test then
72 correct, state = self.profile.plain_test(self, authentication, password, self.realm); 74 correct, state = self.profile.plain_test(self, authentication, password, self.realm);
73 end 75 end
74 76
75 self.username = authentication
76 if state == false then 77 if state == false then
77 return "failure", "account-disabled"; 78 return "failure", "account-disabled";
78 elseif state == nil or not correct then 79 elseif state == nil or not correct then
79 return "failure", "not-authorized", "Unable to authorize you with the authentication credentials you've sent."; 80 return "failure", "not-authorized", "Unable to authorize you with the authentication credentials you've sent.";
80 end 81 end