Comparison

mod_sasl2_fast/mod_sasl2_fast.lua @ 5070:5cc6f3749376

mod_sasl2_fast: Fix make_token() to return appropriate result
author Matthew Wild <mwild1@gmail.com>
date Sat, 15 Oct 2022 19:41:33 +0100
parent 5069:e8342ae5ae12
child 5071:bc983da908e6
comparison
equal deleted inserted replaced
5069:e8342ae5ae12 5070:5cc6f3749376
15 15
16 local function make_token(username, client_id, mechanism) 16 local function make_token(username, client_id, mechanism)
17 local new_token = "secret-token:fast-"..id.long(); 17 local new_token = "secret-token:fast-"..id.long();
18 local key = hash.sha256(client_id, true).."-new"; 18 local key = hash.sha256(client_id, true).."-new";
19 local issued_at = now(); 19 local issued_at = now();
20 token_store:set(username, key, { 20 local token_info = {
21 mechanism = mechanism; 21 mechanism = mechanism;
22 secret = new_token; 22 secret = new_token;
23 issued_at = issued_at; 23 issued_at = issued_at;
24 expires_at = issued_at + fast_token_ttl; 24 expires_at = issued_at + fast_token_ttl;
25 }); 25 };
26 if not token_store:set(username, key, token_info) then
27 return nil;
28 end
29 return token_info;
26 end 30 end
27 31
28 local function new_token_tester(username, hmac_f) 32 local function new_token_tester(username, hmac_f)
29 return function (mechanism, client_id, token_hash, cb_data) 33 return function (mechanism, client_id, token_hash, cb_data)
30 local tried_current_token = false; 34 local tried_current_token = false;