From 46b4cdf0bf4efe339cc5e16d7a7e25589f31bd29 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Wed, 19 Jan 2022 17:21:47 +0100 Subject: [PATCH] fix empty check on nginx sourced env variable --- docker/nginx/libs/skynet/utils.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docker/nginx/libs/skynet/utils.lua b/docker/nginx/libs/skynet/utils.lua index 0ab54c22..adee23b2 100644 --- a/docker/nginx/libs/skynet/utils.lua +++ b/docker/nginx/libs/skynet/utils.lua @@ -4,8 +4,7 @@ function _M.authorization_header() -- read api password from env variable local apipassword = os.getenv("SIA_API_PASSWORD") -- if api password is not available as env variable, read it from disk - if not apipassword then - local b64 = require("ngx.base64") + if apipassword == nil or apipassword == "" then -- open apipassword file for reading (b flag is required for some reason) -- (file /etc/.sia/apipassword has to be mounted from the host system) local apipassword_file = io.open("/data/sia/apipassword", "rb") @@ -16,7 +15,7 @@ function _M.authorization_header() end -- encode the user:password authorization string -- (in our case user is empty so it is just :password) - local content = b64.encode_base64url(":" .. apipassword) + local content = require("ngx.base64").encode_base64url(":" .. apipassword) -- set authorization header with proper base64 encoded string return "Basic " .. content end