Comparison

mod_http_oauth2/mod_http_oauth2.lua @ 5341:dcb93ffe64ae

mod_http_oauth2: Fix error due to reference loop when using refresh token
author Kim Alvefur <zash@zash.se>
date Wed, 12 Apr 2023 11:24:06 +0200
parent 5340:cd195283127f
child 5354:39d59d857bfb
comparison
equal deleted inserted replaced
5340:cd195283127f 5341:dcb93ffe64ae
174 -- Create refresh token for the grant if desired 174 -- Create refresh token for the grant if desired
175 refresh_token = refresh_token_info ~= false and tokens.create_token(token_jid, grant, nil, nil, "oauth2-refresh"); 175 refresh_token = refresh_token_info ~= false and tokens.create_token(token_jid, grant, nil, nil, "oauth2-refresh");
176 else 176 else
177 -- Grant exists, reuse existing refresh token 177 -- Grant exists, reuse existing refresh token
178 refresh_token = refresh_token_info.token; 178 refresh_token = refresh_token_info.token;
179
180 refresh_token_info.grant = nil; -- Prevent reference loop
179 end 181 end
180 182
181 local access_token, access_token_info = tokens.create_token(token_jid, grant, role, default_access_ttl, "oauth2"); 183 local access_token, access_token_info = tokens.create_token(token_jid, grant, role, default_access_ttl, "oauth2");
182 184
183 local expires_at = access_token_info.expires; 185 local expires_at = access_token_info.expires;