add draft codes
This commit is contained in:
parent
1bd95f289d
commit
766b1d2aff
4 changed files with 114 additions and 0 deletions
44
scripts/webfinger_allowlist.lua
Normal file
44
scripts/webfinger_allowlist.lua
Normal file
|
@ -0,0 +1,44 @@
|
|||
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'
|
||||
}
|
||||
},
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue