45 lines
924 B
Lua
45 lines
924 B
Lua
|
local CONFIG_PATH = ".;/etc/aproxy"
|
||
|
|
||
|
-- function loadConfig()
|
||
|
-- -- TODO load config_path
|
||
|
-- return require("./config.lua")
|
||
|
-- end
|
||
|
--
|
||
|
-- local config = loadConfig()
|
||
|
|
||
|
function log(msg)
|
||
|
ngx.log(ngx.STDERR, tostring(msg))
|
||
|
end
|
||
|
|
||
|
local WANTED_SCRIPTS = {
|
||
|
'scripts.webfinger_allowlist'
|
||
|
}
|
||
|
|
||
|
local compiled_chain = {}
|
||
|
|
||
|
for _, module_name in pairs(WANTED_SCRIPTS) do
|
||
|
log('load module', module_name)
|
||
|
mod = require(module_name)
|
||
|
log('load module', mod)
|
||
|
table.insert(compiled_chain, mod)
|
||
|
end
|
||
|
|
||
|
local function onRequest()
|
||
|
log('AWOOOOGA')
|
||
|
|
||
|
for _,mod in ipairs(compiled_chain) do
|
||
|
log(mod)
|
||
|
local mod_config = {accounts = {"a@a.com"}}
|
||
|
local result, body = mod.callback(mod_config)
|
||
|
log(result)
|
||
|
log(body)
|
||
|
if not result then
|
||
|
ngx.status = 400
|
||
|
ngx.say(body or "request denied")
|
||
|
ngx.exit(400)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
return onRequest
|