1
0
mirror of https://github.com/Tecnativa/docker-socket-proxy synced 2025-01-03 12:20:55 +00:00
docker-socket-proxy/verify.lua

13 lines
551 B
Lua
Raw Normal View History

2024-04-14 13:43:18 +00:00
core.register_fetches("verify_access", function(txn, api)
-- env(api) check is kept for backwards compatibility
local read_allowed = txn.f:env(api) == "1" or txn.f:env(api .. "_READ") == "1"
-- env(POST) check is kept for backwards compatibility
local write_allowed = txn.f:env(api .. "_WRITE") == "1" or txn.f:env("POST") == "1"
local method = txn.f:method()
local result = ((method == "GET" or method == "HEAD") and read_allowed)
or ((method ~= "GET" and method ~= "HEAD") and write_allowed)
return result
end)