Mercurial > prosody-hg
comparison plugins/mod_auth_internal_hashed.lua @ 12674:72f431b4dc2c
Merge role-auth->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 22 Aug 2022 13:53:35 +0100 |
| parents | aed38948791f |
| children | 5484debdfdfe |
comparison
equal
deleted
inserted
replaced
| 12639:6d9ee0a3eb4b | 12674:72f431b4dc2c |
|---|---|
| 84 | 84 |
| 85 account.stored_key = stored_key_hex | 85 account.stored_key = stored_key_hex |
| 86 account.server_key = server_key_hex | 86 account.server_key = server_key_hex |
| 87 | 87 |
| 88 account.password = nil; | 88 account.password = nil; |
| 89 account.updated = os.time(); | |
| 89 return accounts:set(username, account); | 90 return accounts:set(username, account); |
| 90 end | 91 end |
| 91 return nil, "Account not available."; | 92 return nil, "Account not available."; |
| 93 end | |
| 94 | |
| 95 function provider.get_account_info(username) | |
| 96 local account = accounts:get(username); | |
| 97 if not account then return nil, "Account not available"; end | |
| 98 return { | |
| 99 created = account.created; | |
| 100 password_updated = account.updated; | |
| 101 }; | |
| 92 end | 102 end |
| 93 | 103 |
| 94 function provider.user_exists(username) | 104 function provider.user_exists(username) |
| 95 local account = accounts:get(username); | 105 local account = accounts:get(username); |
| 96 if not account then | 106 if not account then |
| 103 function provider.users() | 113 function provider.users() |
| 104 return accounts:users(); | 114 return accounts:users(); |
| 105 end | 115 end |
| 106 | 116 |
| 107 function provider.create_user(username, password) | 117 function provider.create_user(username, password) |
| 118 local now = os.time(); | |
| 108 if password == nil then | 119 if password == nil then |
| 109 return accounts:set(username, {}); | 120 return accounts:set(username, { created = now; updated = now; disabled = true }); |
| 110 end | 121 end |
| 111 local salt = generate_uuid(); | 122 local salt = generate_uuid(); |
| 112 local valid, stored_key, server_key = get_auth_db(password, salt, default_iteration_count); | 123 local valid, stored_key, server_key = get_auth_db(password, salt, default_iteration_count); |
| 113 if not valid then | 124 if not valid then |
| 114 return valid, stored_key; | 125 return valid, stored_key; |
| 115 end | 126 end |
| 116 local stored_key_hex = to_hex(stored_key); | 127 local stored_key_hex = to_hex(stored_key); |
| 117 local server_key_hex = to_hex(server_key); | 128 local server_key_hex = to_hex(server_key); |
| 118 return accounts:set(username, { | 129 return accounts:set(username, { |
| 119 stored_key = stored_key_hex, server_key = server_key_hex, | 130 stored_key = stored_key_hex, server_key = server_key_hex, |
| 120 salt = salt, iteration_count = default_iteration_count | 131 salt = salt, iteration_count = default_iteration_count, |
| 132 created = now, updated = now; | |
| 121 }); | 133 }); |
| 122 end | 134 end |
| 123 | 135 |
| 124 function provider.delete_user(username) | 136 function provider.delete_user(username) |
| 125 return accounts:set(username, nil); | 137 return accounts:set(username, nil); |
