Mercurial > prosody-modules
annotate mod_telnet_tlsinfo/mod_telnet_tlsinfo.lua @ 5193:2bb29ece216b
mod_http_oauth2: Implement stateless dynamic client registration
Replaces previous explicit registration that required either the
additional module mod_adhoc_oauth2_client or manually editing the
database. That method was enough to have something to test with, but
would not probably not scale easily.
Dynamic client registration allows creating clients on the fly, which
may be even easier in theory.
In order to not allow basically unauthenticated writes to the database,
we implement a stateless model here.
per_host_key := HMAC(config -> oauth2_registration_key, hostname)
client_id := JWT { client metadata } signed with per_host_key
client_secret := HMAC(per_host_key, client_id)
This should ensure everything we need to know is part of the client_id,
allowing redirects etc to be validated, and the client_secret can be
validated with only the client_id and the per_host_key.
A nonce injected into the client_id JWT should ensure nobody can submit
the same client metadata and retrieve the same client_secret
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 03 Mar 2023 21:14:19 +0100 |
parents | 832235cc1910 |
children |
rev | line source |
---|---|
1087
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 -- mod_telnet_tlsinfo.lua |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 module:set_global(); |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 module:depends("admin_telnet"); |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 local console_env = module:shared("/*/admin_telnet/env"); |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 local c2s_sessions = module:shared("/*/c2s/sessions"); |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 local s2s_sessions = module:shared("/*/s2s/sessions"); |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 local function print_tlsinfo(print, session) |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 if session.secure then |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 local sock = session.conn:socket() |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 for k,v in pairs(sock:info()) do |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 print(("%20s: %s"):format(k, tostring(v))) |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 end |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 else |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 print(("%20s: %s"):format("protocol", "TCP")) |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 end |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 end |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 |
1132
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
21 function console_env.c2s:showtls(pat) |
1087
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 local print = self.session.print; |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 for _, session in pairs(c2s_sessions) do |
1132
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
24 if not pat or session.full_jid and session.full_jid:find(pat, nil, true) then |
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
25 print(session.full_jid or "unauthenticated") |
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
26 print_tlsinfo(print, session); |
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
27 print"" |
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
28 end |
1087
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 end |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 end |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 |
1132
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
32 function console_env.s2s:showtls(pat) |
1087
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 local print = self.session.print; |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 for _, session in pairs(s2s_sessions) do |
1132
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
35 if not pat or session.from_host == pat or session.to_host == pat then |
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
36 if session.direction == "outgoing" then |
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
37 print(session.from_host, "->", session.to_host) |
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
38 else |
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
39 print(session.to_host, "<-", session.from_host) |
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
40 end |
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
41 print_tlsinfo(print, session); |
832235cc1910
mod_telnet_tlsinfo: Add a pattern argument similar to s2s:show(pattern) for limiting output
Kim Alvefur <zash@zash.se>
parents:
1087
diff
changeset
|
42 print"" |
1087
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 end |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
44 end |
447af80a16ad
mod_telnet_tlsinfo: Initial commit. Shows ciphers used and other TLS info
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
45 end |