comparison plugins/mod_auth_internal_hashed.lua @ 8060:71bdfdf6565d

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Tue, 04 Apr 2017 01:41:09 +0200
parents cacf14c218ab
children 4354f556c5db
comparison
equal deleted inserted replaced
8051:b2681397bafa 8060:71bdfdf6565d
99 end 99 end
100 local salt = generate_uuid(); 100 local salt = generate_uuid();
101 local valid, stored_key, server_key = getAuthenticationDatabaseSHA1(password, salt, default_iteration_count); 101 local valid, stored_key, server_key = getAuthenticationDatabaseSHA1(password, salt, default_iteration_count);
102 local stored_key_hex = to_hex(stored_key); 102 local stored_key_hex = to_hex(stored_key);
103 local server_key_hex = to_hex(server_key); 103 local server_key_hex = to_hex(server_key);
104 return accounts:set(username, {stored_key = stored_key_hex, server_key = server_key_hex, salt = salt, iteration_count = default_iteration_count}); 104 return accounts:set(username, {
105 stored_key = stored_key_hex, server_key = server_key_hex,
106 salt = salt, iteration_count = default_iteration_count
107 });
105 end 108 end
106 109
107 function provider.delete_user(username) 110 function provider.delete_user(username)
108 return accounts:set(username, nil); 111 return accounts:set(username, nil);
109 end 112 end
110 113
111 function provider.get_sasl_handler() 114 function provider.get_sasl_handler()
112 local testpass_authentication_profile = { 115 local testpass_authentication_profile = {
113 plain_test = function(sasl, username, password, realm) 116 plain_test = function(_, username, password, realm)
114 return usermanager.test_password(username, realm, password), true; 117 return usermanager.test_password(username, realm, password), true;
115 end, 118 end,
116 scram_sha_1 = function(sasl, username, realm) 119 scram_sha_1 = function(_, username)
117 local credentials = accounts:get(username); 120 local credentials = accounts:get(username);
118 if not credentials then return; end 121 if not credentials then return; end
119 if credentials.password then 122 if credentials.password then
120 usermanager.set_password(username, credentials.password, host); 123 usermanager.set_password(username, credentials.password, host);
121 credentials = accounts:get(username); 124 credentials = accounts:get(username);
122 if not credentials then return; end 125 if not credentials then return; end
123 end 126 end
124 127
125 local stored_key, server_key, iteration_count, salt = credentials.stored_key, credentials.server_key, credentials.iteration_count, credentials.salt; 128 local stored_key, server_key = credentials.stored_key, credentials.server_key;
129 local iteration_count, salt = credentials.iteration_count, credentials.salt;
126 stored_key = stored_key and from_hex(stored_key); 130 stored_key = stored_key and from_hex(stored_key);
127 server_key = server_key and from_hex(server_key); 131 server_key = server_key and from_hex(server_key);
128 return stored_key, server_key, iteration_count, salt, true; 132 return stored_key, server_key, iteration_count, salt, true;
129 end 133 end
130 }; 134 };