141 |
141 |
142 self.state["servernonce"] = generate_uuid(); |
142 self.state["servernonce"] = generate_uuid(); |
143 |
143 |
144 -- retreive credentials |
144 -- retreive credentials |
145 if self.profile.plain then |
145 if self.profile.plain then |
146 local password, state = self.profile.plain(self.state.name, self.realm) |
146 local password, state = self.profile.plain(self, self.state.name, self.realm) |
147 if state == nil then return "failure", "not-authorized" |
147 if state == nil then return "failure", "not-authorized" |
148 elseif state == false then return "failure", "account-disabled" end |
148 elseif state == false then return "failure", "account-disabled" end |
149 |
149 |
150 password = saslprep(password); |
150 password = saslprep(password); |
151 if not password then |
151 if not password then |
161 if not succ then |
161 if not succ then |
162 log("error", "Generating authentication database failed. Reason: %s", self.state.stored_key); |
162 log("error", "Generating authentication database failed. Reason: %s", self.state.stored_key); |
163 return "failure", "temporary-auth-failure"; |
163 return "failure", "temporary-auth-failure"; |
164 end |
164 end |
165 elseif self.profile["scram_"..hashprep(hash_name)] then |
165 elseif self.profile["scram_"..hashprep(hash_name)] then |
166 local stored_key, server_key, iteration_count, salt, state = self.profile["scram_"..hashprep(hash_name)](self.state.name, self.realm); |
166 local stored_key, server_key, iteration_count, salt, state = self.profile["scram_"..hashprep(hash_name)](self, self.state.name, self.realm); |
167 if state == nil then return "failure", "not-authorized" |
167 if state == nil then return "failure", "not-authorized" |
168 elseif state == false then return "failure", "account-disabled" end |
168 elseif state == false then return "failure", "account-disabled" end |
169 |
169 |
170 self.state.stored_key = stored_key; |
170 self.state.stored_key = stored_key; |
171 self.state.server_key = server_key; |
171 self.state.server_key = server_key; |