From ff3abb0d620c1a0b40e196c9328ca758c89175fd Mon Sep 17 00:00:00 2001 From: Roland Greim Date: Mon, 11 Oct 2021 11:34:51 +0200 Subject: [PATCH 1/2] :bug: Use wget instead of curl and remove openssl.pkey --- kong/plugins/jwt-firebase/handler.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kong/plugins/jwt-firebase/handler.lua b/kong/plugins/jwt-firebase/handler.lua index a9b2c12..417170f 100644 --- a/kong/plugins/jwt-firebase/handler.lua +++ b/kong/plugins/jwt-firebase/handler.lua @@ -1,7 +1,6 @@ local constants = require "kong.constants" local local_constants = require "kong.plugins.jwt-firebase.constants" local jwt_decoder = require "kong.plugins.jwt.jwt_parser" -local openssl_pkey = require "openssl.pkey" local shm = "/dev/shm/kong.jwt-firebase.pubkey" @@ -29,7 +28,7 @@ local function grab_public_key_bykid(t_kid) kong.log.debug("### Grabbing pubkey from google ..") local google_url = "https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com" local magic = " | cut -d \"\\\"\" -f4- | sed 's/\\\\n/\\n/g\' | sed 's/\"//g' | openssl x509 -pubkey -noout" - local cmd = "curl -s " .. google_url .. " | grep -i " .. t_kid .. magic + local cmd = "wget -qO - " .. google_url .. " | grep -i " .. t_kid .. magic kong.log.debug("### cmd: " .. cmd) local cmd_handle = io.popen(cmd) @@ -211,7 +210,7 @@ local function do_authentication(conf) -- -- -- -- assign this key to public_key local public_key = get_public_key_from_file(shm) kong.log.debug(public_key) - if not pcall(openssl_pkey.new, public_key) or public_key == nil then + if public_key == nil then kong.log.info("Public key in a file is empty or invalid") --local t_public_key = grab_1st_public_key() local t_public_key = grab_public_key_bykid(kid) From 6e6b34f59b78fd574db0af44a08eb7c7484b1b11 Mon Sep 17 00:00:00 2001 From: Roland Greim Date: Mon, 11 Oct 2021 11:35:48 +0200 Subject: [PATCH 2/2] :rotating_light: Make this variable local --- kong/plugins/jwt-firebase/handler.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kong/plugins/jwt-firebase/handler.lua b/kong/plugins/jwt-firebase/handler.lua index 417170f..80cd09c 100644 --- a/kong/plugins/jwt-firebase/handler.lua +++ b/kong/plugins/jwt-firebase/handler.lua @@ -63,7 +63,7 @@ local function get_public_key_from_file(dir) return nil end io.input(file) - content = io.read("*a") + local content = io.read("*a") io.close(file) return content end