comparison mod_http_oauth2/mod_http_oauth2.lua @ 4670:1b81b7269858

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.
author Kim Alvefur <zash@zash.se>
date Thu, 02 Sep 2021 23:06:58 +0200
parents d3434fd151b5
children 5ab134b7e510
comparison
equal deleted inserted replaced
4669:d3434fd151b5 4670:1b81b7269858
100 end 100 end
101 101
102 local granted_scopes = filter_scopes(granted_jid, params.scope); 102 local granted_scopes = filter_scopes(granted_jid, params.scope);
103 103
104 local code = uuid.generate(); 104 local code = uuid.generate();
105 assert(codes:set(params.client_id .. "#" .. code, { 105 local ok = codes:set(params.client_id .. "#" .. code, {
106 issued = os.time(); 106 issued = os.time();
107 granted_jid = granted_jid; 107 granted_jid = granted_jid;
108 granted_scopes = granted_scopes; 108 granted_scopes = granted_scopes;
109 })); 109 });
110 if not ok then
111 return {status_code = 429};
112 end
110 113
111 local redirect = url.parse(params.redirect_uri); 114 local redirect = url.parse(params.redirect_uri);
112 local query = http.formdecode(redirect.query or ""); 115 local query = http.formdecode(redirect.query or "");
113 if type(query) ~= "table" then query = {}; end 116 if type(query) ~= "table" then query = {}; end
114 table.insert(query, { name = "code", value = code }) 117 table.insert(query, { name = "code", value = code })