aproxy/scripts/webfinger_allowlist.lua
2022-12-06 00:36:15 -03:00

44 lines
1 KiB
Lua

function webfingerCallback(cfg)
local args, err = ngx.req.get_uri_args()
if err == "truncated" then
return false, 'uri args too long'
end
local resource = args['resource']
if resource ~= nil then
for _, account in ipairs(cfg.accounts) do
if resource == account then
return true
end
end
end
return false
end
return {
name='WebfingerAllowlist',
author='luna@l4.pm',
title='Webfinger Allowlist',
description=[[
Prevent unecessary DB load by discarding requests to users that we know
won't exist.
Useful for small instances.
]],
apiVersion=1,
callback=webfingerCallback,
callbacks = {
['/.well-known/webfinger'] = webfingerCallback
},
config={
['accounts'] = {
type='table',
value={
type='string',
description='ap id'
},
description = 'list of account ids (in email@domain form) to pass through to AP'
}
},
}