Nginx passes Skynet-Api-Key and Authorization headers at all spots where it passes the Cookie header.

This commit is contained in:
Ivaylo Novakov 2022-03-10 18:11:37 +01:00
parent 061770a95a
commit 2db648b0ad
No known key found for this signature in database
GPG Key ID: 06B9354AB08BE9C6
5 changed files with 31 additions and 11 deletions

View File

@ -11,7 +11,11 @@ log_by_lua_block {
-- 10.10.10.70 points to accounts service (alias not available when using resty-http)
local res, err = httpc:request_uri("http://10.10.10.70:3000/track/download/" .. skylink .. "?" .. query, {
method = "POST",
headers = { ["Cookie"] = "skynet-jwt=" .. jwt },
headers = {
["Cookie"] = "skynet-jwt=" .. jwt,
["Authorization"] = ngx.header["Authorization"],
["Skynet-Api-Key"] = ngx.header["Skynet-Api-Key"],
},
})
if err or (res and res.status ~= ngx.HTTP_NO_CONTENT) then

View File

@ -14,7 +14,11 @@ log_by_lua_block {
-- 10.10.10.70 points to accounts service (alias not available when using resty-http)
local res, err = httpc:request_uri("http://10.10.10.70:3000/track/registry/" .. registry_action, {
method = "POST",
headers = { ["Cookie"] = "skynet-jwt=" .. jwt },
headers = {
["Cookie"] = "skynet-jwt=" .. jwt,
["Authorization"] = ngx.header["Authorization"],
["Skynet-Api-Key"] = ngx.header["Skynet-Api-Key"],
},
})
if err or (res and res.status ~= ngx.HTTP_NO_CONTENT) then

View File

@ -10,7 +10,11 @@ log_by_lua_block {
-- 10.10.10.70 points to accounts service (alias not available when using resty-http)
local res, err = httpc:request_uri("http://10.10.10.70:3000/track/upload/" .. skylink, {
method = "POST",
headers = { ["Cookie"] = "skynet-jwt=" .. jwt },
headers = {
["Cookie"] = "skynet-jwt=" .. jwt,
["Authorization"] = ngx.header["Authorization"],
["Skynet-Api-Key"] = ngx.header["Skynet-Api-Key"],
},
})
if err or (res and res.status ~= ngx.HTTP_NO_CONTENT) then

View File

@ -178,7 +178,11 @@ location /skynet/registry/subscription {
-- fetch account limits and set download bandwidth and registry delays accordingly
local res, err = httpc:request_uri("http://10.10.10.70:3000/user/limits", {
headers = { ["Cookie"] = "skynet-jwt=" .. ngx.var.skynet_jwt }
headers = {
["Cookie"] = "skynet-jwt=" .. ngx.var.skynet_jwt,
["Authorization"] = ngx.header["Authorization"],
["Skynet-Api-Key"] = ngx.header["Skynet-Api-Key"],
}
})
-- fail gracefully in case /user/limits failed

View File

@ -46,7 +46,11 @@ function _M.get_account_limits()
-- 10.10.10.70 points to accounts service (alias not available when using resty-http)
local res, err = httpc:request_uri("http://10.10.10.70:3000/user/limits", {
headers = { ["Cookie"] = "skynet-jwt=" .. ngx.var.skynet_jwt }
headers = {
["Cookie"] = "skynet-jwt=" .. ngx.var.skynet_jwt,
["Authorization"] = ngx.header["Authorization"],
["Skynet-Api-Key"] = ngx.header["Skynet-Api-Key"],
}
})
-- fail gracefully in case /user/limits failed