Skip to content

Commit 1e2d705

Browse files
committed
release 1.4.0; support RFC7662-style introspection by default
- apply iat_slack also to openidc.jwt_verify; thanks @nielsole - properly deal with ngx.redirect's return value; thanks @bodewig - fix access token cache ttl; closes #76 Signed-off-by: Hans Zandbelt <[email protected]>
1 parent 3b6317a commit 1e2d705

File tree

5 files changed

+23
-19
lines changed

5 files changed

+23
-19
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sudo: false
44

55
env:
66
global:
7-
- VERSION=1.3.2-1
7+
- VERSION=1.4.0-1
88
- NAME=lua-resty-openidc
99
- ROCKSPEC=$NAME-$VERSION.rockspec
1010
- LUAROCKS=2.3.0

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
08/01/2017
2+
- apply iat_slack also to openidc.jwt_verify; thanks @nielsole
3+
- properly deal with ngx.redirect's return value; thanks @bodewig
4+
- fix access token cache ttl; closes #76
5+
- support RFC7662-style token introspection by default
6+
- release 1.4.0
7+
18
07/03/2017
29
- adding option to add id_token_hint to op logout request; thanks @pgp44
310

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,7 @@ http {
326326
access_by_lua '
327327
328328
local opts = {
329-
introspection_endpoint="https://localhost:9031/as/token.oauth2",
330-
introspection_token_param_name="token",
331-
introspection_params = {
332-
grant_type="urn:pingidentity.com:oauth2:grant_type:validate_bearer",
333-
},
329+
introspection_endpoint="https://localhost:9031/as/introspect.oauth2",
334330
client_id="rs_client",
335331
client_secret="2Federate",
336332
ssl_verify = "no",

lib/resty/openidc.lua

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ local type = type
5757
local ngx = ngx
5858

5959
local openidc = {
60-
_VERSION = "1.3.2"
60+
_VERSION = "1.4.0"
6161
}
6262
openidc.__index = openidc
6363

@@ -367,13 +367,13 @@ end
367367

368368
-- get the Discovery metadata from the specified URL
369369
local 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)
405405
end
406406

407407
local 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"

lua-resty-openidc-1.3.2-1.rockspec renamed to lua-resty-openidc-1.4.0-1.rockspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package = "lua-resty-openidc"
2-
version = "1.3.2-1"
2+
version = "1.4.0-1"
33
source = {
44
url = "git://github.com/pingidentity/lua-resty-openidc",
5-
tag = "v1.3.2",
5+
tag = "v1.4.0",
66
dir = "lua-resty-openidc"
77
}
88
description = {

0 commit comments

Comments
 (0)