Mercurial > prosody-modules
annotate mod_turn_external/mod_turn_external.lua @ 5418:f2c7bb3af600
mod_http_oauth2: Add role selector to consent page
List includes all roles available to the user, if more than one.
Defaults to either the first role in the scope string or the users
primary role.
Earlier draft listed all roles, but having options that can't be
selected is bad UX and the entire list of all roles on the server could
be long, and perhaps even sensitive.
Allows e.g. picking a role with fewer permissions than what might
otherwise have been selected.
UX wise, doing this with more checkboxes or possibly radio buttons would
have been confusion and/or looked messier.
Fixes the previous situation where unselecting a role would default to
the primary role, which could be more permissions than requested.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 05 May 2023 01:23:13 +0200 |
parents | 2542fd80cd15 |
children |
rev | line source |
---|---|
4894
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local set = require "util.set"; |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local secret = module:get_option_string("turn_external_secret"); |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 local host = module:get_option_string("turn_external_host", module.host); |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 local user = module:get_option_string("turn_external_user"); |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 local port = module:get_option_number("turn_external_port", 3478); |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 local ttl = module:get_option_number("turn_external_ttl", 86400); |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 local tcp = module:get_option_boolean("turn_external_tcp", false); |
4895
2542fd80cd15
mod_turn_external: Fix type of config option (thanks mirux)
Kim Alvefur <zash@zash.se>
parents:
4894
diff
changeset
|
9 local tls_port = module:get_option_number("turn_external_tls_port"); |
4894
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 if not secret then error("mod_" .. module.name .. " requires that 'turn_external_secret' be set") end |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 local services = set.new({ "stun-udp"; "turn-udp" }); |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 if tcp then |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 services:add("stun-tcp"); |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 services:add("turn-tcp"); |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 end |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 if tls_port then |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 services:add("turns-tcp"); |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 end |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 module:depends "external_services"; |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 for _, type in ipairs({ "stun"; "turn"; "turns" }) do |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 for _, transport in ipairs({"udp"; "tcp"}) do |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 if services:contains(type .. "-" .. transport) then |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 module:add_item("external_service", { |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 type = type; |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 transport = transport; |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 host = host; |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 port = type == "turns" and tls_port or port; |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 username = type == "turn" and user or nil; |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 secret = type == "turn" and secret or nil; |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 ttl = type == "turn" and ttl or nil; |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 }) |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 end |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 end |
bfa2cca2bdd5
mod_turn_external: Import from prosody trunk @ ed23bbf3b946
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 end |