This repository has been archived on 2022-10-07. You can view files and clone it, but cannot push or open issues or pull requests.
2021-06-04 11:23:07 +00:00
|
|
|
# register the registry access in accounts service (cookies should contain jwt)
|
|
|
|
log_by_lua_block {
|
|
|
|
-- this block runs only when accounts are enabled
|
2021-07-25 23:54:03 +00:00
|
|
|
if os.getenv("ACCOUNTS_ENABLED") ~= "1" then return end
|
2021-06-04 11:23:07 +00:00
|
|
|
|
|
|
|
if ngx.status == ngx.HTTP_OK or ngx.status == ngx.HTTP_NOT_FOUND then
|
|
|
|
local http = require("socket.http")
|
|
|
|
local method = ngx.req.get_method() == ngx.HTTP_GET and "read" or "write"
|
|
|
|
local ok, statusCode, headers, statusText = http.request {
|
|
|
|
url = "http://accounts:3000/track/registry/" .. method,
|
|
|
|
method = "POST",
|
|
|
|
headers = ngx.req.get_headers()
|
|
|
|
}
|
|
|
|
if statusCode ~= ngx.HTTP_NO_CONTENT and statusCode ~= ngx.HTTP_UNAUTHORIZED then
|
|
|
|
ngx.log(ngx.ERR, "accounts endpoint /track/registry/" .. method .. " failed with error " .. statusCode)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|