comparison mod_http_oauth2/mod_http_oauth2.lua @ 4272:91b951fb3018

mod_http_oauth2: Periodically trim unused authorization codes
author Kim Alvefur <zash@zash.se>
date Sun, 22 Nov 2020 19:11:42 +0100
parents 9623b99bb8d2
children ec33b3b1136c
comparison
equal deleted inserted replaced
4271:9623b99bb8d2 4272:91b951fb3018
20 20
21 local codes = cache.new(10000, function (_, code) 21 local codes = cache.new(10000, function (_, code)
22 return code_expired(code) 22 return code_expired(code)
23 end); 23 end);
24 24
25 module:add_timer(900, function()
26 local k, code = codes:tail();
27 while code and code_expired(code) do
28 codes:set(k, nil);
29 k, code = codes:tail();
30 end
31 return 900;
32 end)
33
25 local function oauth_error(err_name, err_desc) 34 local function oauth_error(err_name, err_desc)
26 return errors.new({ 35 return errors.new({
27 type = "modify"; 36 type = "modify";
28 condition = "bad-request"; 37 condition = "bad-request";
29 code = err_name == "invalid_client" and 401 or 400; 38 code = err_name == "invalid_client" and 401 or 400;