mod_http_oauth2: Gracefully handle cache write failure
Would previously have thrown an error and probably returned a traceback.
This would only happen if a *lot* of authorization codes were requested
in a short interval.
--- a/mod_http_oauth2/mod_http_oauth2.lua Thu Sep 02 23:03:41 2021 +0200
+++ b/mod_http_oauth2/mod_http_oauth2.lua Thu Sep 02 23:06:58 2021 +0200
@@ -102,11 +102,14 @@
local granted_scopes = filter_scopes(granted_jid, params.scope);
local code = uuid.generate();
- assert(codes:set(params.client_id .. "#" .. code, {
+ local ok = codes:set(params.client_id .. "#" .. code, {
issued = os.time();
granted_jid = granted_jid;
granted_scopes = granted_scopes;
- }));
+ });
+ if not ok then
+ return {status_code = 429};
+ end
local redirect = url.parse(params.redirect_uri);
local query = http.formdecode(redirect.query or "");