Comparison

plugins/mod_tokenauth.lua @ 12996:e8716515405e

mod_tokenauth: return error if storage of new token fails
author Matthew Wild <mwild1@gmail.com>
date Sun, 26 Mar 2023 15:53:27 +0100
parent 12980:6ebad8e16b3b
child 12997:0a56b84ec4ad
comparison
equal deleted inserted replaced
12995:e385f3a06673 12996:e8716515405e
52 data = token_data; 52 data = token_data;
53 }; 53 };
54 54
55 local token_secret = random.bytes(18); 55 local token_secret = random.bytes(18);
56 local token = "secret-token:"..base64.encode("2;"..token_id..";"..token_secret..";"..jid.join(token_username, token_host)); 56 local token = "secret-token:"..base64.encode("2;"..token_id..";"..token_secret..";"..jid.join(token_username, token_host));
57 token_store:set(token_username, token_id, { 57 local ok, err = token_store:set(token_username, token_id, {
58 secret_sha256 = hashes.sha256(token_secret, true); 58 secret_sha256 = hashes.sha256(token_secret, true);
59 token_info = token_info 59 token_info = token_info
60 }); 60 });
61 if not ok then
62 return nil, err;
63 end
61 64
62 return token, token_info; 65 return token, token_info;
63 end 66 end
64 67
65 local function parse_token(encoded_token) 68 local function parse_token(encoded_token)