Skip to content

Commit 89535da

Browse files
committed
Make auth local cache ttl configurable
1 parent 28a853f commit 89535da

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/lua/api-gateway/validation/oauth2/oauthTokenValidator.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ end
116116

117117
function _M:storeTokenInCache(cacheLookupKey, cachingObj, expire_at_ms_utc)
118118
local expires_in_s = self:getExpiresIn(expire_at_ms_utc)
119+
if ngx.var.max_auth_local_cache_ttl ~= nil and ngx.var.max_auth_local_cache_ttl ~= '' then
120+
expires_in_s = math.min(expires_in_s, ngx.var.max_auth_local_cache_ttl)
121+
end
119122
if (expires_in_s <= 0) then
120123
ngx.log(ngx.DEBUG, "OAuth Token was not persisted in the cache as it has expired at:" .. tostring(expire_at_ms_utc) .. ", while now is:" .. tostring(ngx.time() * 1000) .. " ms.")
121124
return nil

0 commit comments

Comments
 (0)