Software /
code /
prosody
Annotate
tools/form2table.lua @ 12659:c0eea4f6c739
usermanager: Add back temporary is_admin to warn about deprecated API usage
Goal: Introduce role-auth with minimal disruption
is_admin() is unsafe in a system with per-session permissions, so it has been
deprecated.
Roll-out approach:
1) First, log a warning when is_admin() is used. It should continue to
function normally, backed by the new role API. Nothing is really using
per-session authz yet, so there is minimal security concern.
The 'strict_deprecate_is_admin' global setting can be set to 'true' to
force a hard failure of is_admin() attempts (it will log an error and
always return false).
2) In some time (at least 1 week), but possibly longer depending on the number
of affected deployments: switch 'strict_deprecate_is_admin' to 'true' by
default. It can still be disabled for systems that need it.
3) Further in the future, before the next release, the option will be removed
and is_admin() will be permanently disabled.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 15 Aug 2022 15:25:07 +0100 |
parent | 11194:9d1ce6f28401 |
child | 13142:879a6a33c21b |
rev | line source |
---|---|
11194
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 -- Read an XML dataform and spit out a serialized Lua table of it |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local function from_stanza(stanza) |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 local layout = { |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 title = stanza:get_child_text("title"); |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 instructions = stanza:get_child_text("instructions"); |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 }; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 for tag in stanza:childtags("field") do |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 local field = { |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 name = tag.attr.var; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 type = tag.attr.type; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 label = tag.attr.label; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 desc = tag:get_child_text("desc"); |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 required = tag:get_child("required") and true or nil; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 value = tag:get_child_text("value"); |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 options = nil; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 }; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 if field.type == "list-single" or field.type == "list-multi" then |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 local options = {}; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 for option in tag:childtags("option") do |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 options[#options+1] = { label = option.attr.label, value = option:get_child_text("value") }; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 end |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 field.options = options; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 end |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 if field.type == "jid-multi" or field.type == "list-multi" or field.type == "text-multi" then |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 local values = {}; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 for value in tag:childtags("value") do |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 values[#values+1] = value:get_text(); |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 end |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 if field.type == "text-multi" then |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 values = table.concat(values, "\n"); |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 end |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 field.value = values; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 end |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 if field.type == "boolean" then |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 field.value = field.value == "true" or field.value == "1"; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 end |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 layout[#layout+1] = field; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
44 end |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
45 return layout; |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
46 end |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
47 |
9d1ce6f28401
tools/form2table: Convert XEP-0004 dataform from XML to util.dataforms Lua format
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
48 print("dataforms.new " .. require "util.serialization".serialize(from_stanza(require "util.xml".parse(io.read("*a"))), { unquoted = true })) |