Skip to content

Commit 6292c21

Browse files
committed
Fix require_success ignoring body active value
1 parent 9134f79 commit 6292c21

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ Plugin is protecting Kong API service/route with introspection of Oauth2.0 JWT a
1515
| `config.client_id` | | **Required**. Client ID |
1616
| `config.client_secret` | | **Required**. Client secret |
1717
| `config.token_header` | Authorization | Name of api-request header containing access token |
18-
| `config.token_query` | token | Name of query parameter containing access token |
18+
| `config.token_query` | token | Name of query parameter containing access token, only if `token_header` value was missing |
1919
| `config.require_success` | true | Require a successful introspection before proxying the request, if false `token_header` existance will not be required |
2020
| `config.token_cache_time` | 0 | Cache TTL for every token introspection result(0 - no cache) |
2121
| `config.introspection_map` | | External introspection response `body` and `headers` mapped to request headers, also `static` for fixed strings |
2222

2323
## How to install
2424

25-
**1.1.0** `luarocks install https://raw.githubusercontent.com/medwing/kong-token-introspection/master/access-token-introspection-1.1.0-0.rockspec`
25+
**1.1.0** `luarocks install https://raw.githubusercontent.com/medwing/kong-token-introspection/v1.1.0/access-token-introspection-1.1.0-0.rockspec`
26+
27+
**1.1.1** `luarocks install https://raw.githubusercontent.com/medwing/kong-token-introspection/v1.1.1/access-token-introspection-1.1.1-0.rockspec`

access-token-introspection-1.1.0-0.rockspec access-token-introspection-1.1.1-0.rockspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package = "access-token-introspection"
2-
version = "1.1.0-0"
2+
version = "1.1.1-0"
33

44
source = {
55
url = "git://github.com/medwing/kong-token-introspection",
6-
tag = "v1.1.0"
6+
tag = "v1.1.1"
77
}
88

99
description = {

kong/plugins/access-token-introspection/access.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function _M.introspect_access_token_req(access_token)
2424
})
2525

2626
if not res then
27-
return { status = 0 }
27+
return nil
2828
end
2929

3030
return {
@@ -45,8 +45,7 @@ function _M.introspect_access_token(access_token)
4545
_M.error_response("Unexpected error: " .. err, ngx.HTTP_INTERNAL_SERVER_ERROR)
4646
end
4747
-- not 200 response status isn't valid for normal caching
48-
-- TODO:optimisation
49-
if res.status ~= 200 then
48+
if not res or res.status ~= 200 then
5049
kong.cache:invalidate(cache_id)
5150
end
5251

@@ -81,7 +80,7 @@ function _M.run(conf)
8180
_M.error_response("Authorization server error.", ngx.HTTP_INTERNAL_SERVER_ERROR)
8281
end
8382

84-
if _M.conf.require_success and res.status ~= 200 then
83+
if _M.conf.require_success and (res.status ~= 200 or res.body["active"] ~= true) then
8584
_M.error_response("The resource owner or authorization server denied the request.", ngx.HTTP_UNAUTHORIZED)
8685
end
8786

0 commit comments

Comments
 (0)