@@ -57,7 +57,7 @@ local type = type
5757local ngx = ngx
5858
5959local openidc = {
60- _VERSION = " 1.3.2 "
60+ _VERSION = " 1.4.0 "
6161}
6262openidc .__index = openidc
6363
@@ -367,13 +367,13 @@ end
367367
368368-- get the Discovery metadata from the specified URL
369369local function openidc_discover (url , ssl_verify )
370- ngx .log (ngx .DEBUG , " In openidc_discover - URL is " .. url )
370+ ngx .log (ngx .DEBUG , " openidc_discover: URL is: " .. url )
371371
372372 local json , err
373373 local v = openidc_cache_get (" discovery" , url )
374374 if not v then
375375
376- ngx .log (ngx .DEBUG , " Discovery data not in cache. Making call to discovery endpoint" )
376+ ngx .log (ngx .DEBUG , " discovery data not in cache, making call to discovery endpoint" )
377377 -- make the call to the discovery endpoint
378378 local httpc = http .new ()
379379 local res , error = httpc :request_uri (url , {
@@ -383,7 +383,7 @@ local function openidc_discover(url, ssl_verify)
383383 err = " accessing discovery url (" .. url .. " ) failed: " .. error
384384 ngx .log (ngx .ERR , err )
385385 else
386- ngx .log (ngx .DEBUG , " Response data: " .. res .body )
386+ ngx .log (ngx .DEBUG , " response data: " .. res .body )
387387 json , err = openidc_parse_json_response (res )
388388 if json then
389389 if string.sub (url , 1 , string.len (json [' issuer' ])) == json [' issuer' ] then
@@ -405,7 +405,7 @@ local function openidc_discover(url, ssl_verify)
405405end
406406
407407local function openidc_jwks (url , ssl_verify )
408- ngx .log (ngx .DEBUG , " In openidc_jwks - URL is " .. url )
408+ ngx .log (ngx .DEBUG , " openidc_jwks: URL is: " .. url )
409409
410410 local json , err
411411 local v = openidc_cache_get (" jwks" , url )
@@ -421,7 +421,7 @@ local function openidc_jwks(url, ssl_verify)
421421 err = " accessing jwks url (" .. url .. " ) failed: " .. error
422422 ngx .log (ngx .ERR , err )
423423 else
424- ngx .log (ngx .DEBUG , " Response data: " .. res .body )
424+ ngx .log (ngx .DEBUG , " response data: " .. res .body )
425425 json , err = openidc_parse_json_response (res )
426426 if json then
427427 openidc_cache_set (" jwks" , url , cjson .encode (json ), 24 * 60 * 60 )
@@ -745,7 +745,7 @@ function openidc.introspect(opts)
745745 if not v then
746746
747747 -- assemble the parameters to the introspection (token) endpoint
748- local token_param_name = opts .introspection_token_param_name and opts .introspection_token_param_name or " access_token "
748+ local token_param_name = opts .introspection_token_param_name and opts .introspection_token_param_name or " token "
749749
750750 local body = {}
751751
@@ -768,12 +768,13 @@ function openidc.introspect(opts)
768768
769769 -- cache the results
770770 if json then
771- if json . active then
772- local expiry_claim = opts . expiry_claim or " expires_in "
773- local ttl = json [expiry_claim ]
774- if expiry_claim ~ = " exp" then -- https://tools.ietf.org/html/rfc7662#section-2.2
771+ local expiry_claim = opts . introspection_expiry_claim or " exp "
772+ if json . active or json [ expiry_claim ] then
773+ local ttl = json [expiry_claim ]
774+ if expiry_claim = = " exp" then -- https://tools.ietf.org/html/rfc7662#section-2.2
775775 ttl = ttl - ngx .time ()
776776 end
777+ ngx .log (ngx .DEBUG , " cache token ttl: " .. ttl )
777778 openidc_cache_set (" introspection" , access_token , cjson .encode (json ), ttl )
778779 else
779780 err = " invalid token"
0 commit comments