Skip to content

Commit dd4c3c6

Browse files
authored
Merge pull request #1438 from 3scale/THREESCALE-10591-token-introspection-deprecated-api
THREESCALE-10591 token instrospection field removed
2 parents c38418c + ed8ba2a commit dd4c3c6

File tree

3 files changed

+461
-142
lines changed

3 files changed

+461
-142
lines changed

gateway/src/apicast/policy/token_introspection/token_introspection.lua

+15-6
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,30 @@ function _M:access(context)
9494

9595
local components = resty_url.parse(context.service.oidc.issuer_endpoint)
9696
self.credential = create_credential(components.user, components.password)
97-
self.introspection_url = context.proxy.oauth.config.token_introspection_endpoint
97+
local oauth_config = context.proxy.oauth.config
98+
-- token_introspection_endpoint being deprecated in RH SSO 7.4 and removed in 7.5
99+
-- https://access.redhat.com/documentation/en-us/red_hat_single_sign-on/7.5/html-single/upgrading_guide/index#non_standard_token_introspection_endpoint_removed
100+
self.introspection_url = oauth_config.introspection_endpoint or oauth_config.token_introspection_endpoint
98101
end
99102

100103
if self.introspection_url then
101104
local authorization = http_authorization.new(ngx.var.http_authorization)
102105
local access_token = authorization.token
103106
--- Introspection Response must have an "active" boolean value.
104107
-- https://tools.ietf.org/html/rfc7662#section-2.2
105-
if not introspect_token(self, access_token).active == true then
106-
ngx.log(ngx.INFO, 'token introspection for access token ', access_token, ': token not active')
107-
ngx.status = context.service.auth_failed_status
108-
ngx.say(context.service.error_auth_failed)
109-
return ngx.exit(ngx.status)
108+
if introspect_token(self, access_token).active == true then
109+
-- access granted
110+
return
110111
end
112+
113+
ngx.log(ngx.INFO, 'token introspection for access token ', access_token, ': token not active')
114+
else
115+
ngx.log(ngx.WARN, 'token instropection cannot be performed as introspection endpoint is not available')
111116
end
117+
118+
ngx.status = context.service.auth_failed_status
119+
ngx.say(context.service.error_auth_failed)
120+
return ngx.exit(ngx.status)
112121
end
113122

114123
return _M

0 commit comments

Comments
 (0)