Parse Headers in OpenResty?

734 Views Asked by At

I have a script in Lua for implementing Google OAuth.

I am currently working on adding another branch of logic which bypasses OAuth:

local auth_header = ngx.header["Authorization"] or "UNSET"
-- if a valid API key exists, use it rather than the OAuth login flow
ngx.log(ngx.ERR, "DEBUG: " .. auth_header)
if api_key ~= "UNSET" and auth_header == api_key then
  return
end

However, it appears that the header is always set to blank:

2017/09/12 01:33:28 [error] 16494#16494: *109 [lua] google_oauth.lua:57: DEBUG: UNSET, client: 1.2.3.4, server: resty, request: "GET /images/favicon.ico?1487269154 HTTP/1.1", host: "resty", referrer: "https://resty/sessions/new"

Am I missing something? Is there another way to access headers in OpenResty that I'm unaware of?

0

There are 0 best solutions below