comparison mod_http_oauth2/mod_http_oauth2.lua @ 5354:39d59d857bfb

mod_http_oauth2: Use new mod_cron API for periodic cleanup Less frequent but this isn't that important after all since, as the comment states, expired codes are not usable anyway. They're also not that large so memory usage probably doesn't matter.
author Kim Alvefur <zash@zash.se>
date Sat, 22 Apr 2023 11:59:52 +0200
parents dcb93ffe64ae
children 41a418ebc60b
comparison
equal deleted inserted replaced
5353:14b6397cd6de 5354:39d59d857bfb
119 return code_expired(code) 119 return code_expired(code)
120 end); 120 end);
121 121
122 -- Periodically clear out unredeemed codes. Does not need to be exact, expired 122 -- Periodically clear out unredeemed codes. Does not need to be exact, expired
123 -- codes are rejected if tried. Mostly just to keep memory usage in check. 123 -- codes are rejected if tried. Mostly just to keep memory usage in check.
124 module:add_timer(900, function() 124 module:hourly("Clear expired authorization codes", function()
125 local k, code = codes:tail(); 125 local k, code = codes:tail();
126 while code and code_expired(code) do 126 while code and code_expired(code) do
127 codes:set(k, nil); 127 codes:set(k, nil);
128 k, code = codes:tail(); 128 k, code = codes:tail();
129 end 129 end
130 return code and code_expires_in(code) + 1 or 900;
131 end) 130 end)
132 131
133 local function get_issuer() 132 local function get_issuer()
134 return (module:http_url(nil, "/"):gsub("/$", "")); 133 return (module:http_url(nil, "/"):gsub("/$", ""));
135 end 134 end