nginx: Add check_role function to worker init

This commit is contained in:
Giulio De Pasquale 2022-10-28 22:01:07 +02:00
parent 2a7af4e910
commit 4bb5af4b5a

View File

@ -47,6 +47,22 @@
# https://github.com/openresty/lua-resty-redis/issues/159 # https://github.com/openresty/lua-resty-redis/issues/159
resolver local=on ipv6=off; resolver local=on ipv6=off;
init_worker_by_lua_block {
function check_role (res, role)
if res.user.roles == nil then
return false
end
for _,v in pairs(res.user.roles) do
if string.lower(v) == role then
return true
end
end
return false
end
}
''; '';
appendConfig = '' appendConfig = ''