Mercurial > prosody-modules
view mod_motd_sequential/mod_motd_sequential.lua @ 5461:06640647d193
mod_http_oauth2: Fix use of arbitrary ports in loopback redirect URIs
Per draft-ietf-oauth-v2-1-08#section-8.4.2
> The authorization server MUST allow any port to be specified at the
> time of the request for loopback IP redirect URIs, to accommodate
> clients that obtain an available ephemeral port from the operating
> system at the time of the request.
Uncertain if it should normalize the host part, but it also seems
harmless to treat IPv6 and IPv4 the same here.
One thing is that "localhost" is NOT RECOMMENDED because it can
sometimes be pointed to non-loopback interfaces via DNS or hosts file.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 17 May 2023 13:51:30 +0200 |
parents | 8412592f3011 |
children |
line wrap: on
line source
-- Prosody IM -- Copyright (C) 2008-2010 Matthew Wild -- Copyright (C) 2008-2010 Waqas Hussain -- Copyright (C) 2010 Jeff Mitchell -- -- This project is MIT/X11 licensed. Please see the -- COPYING file in the source package for more information. -- local core_route_stanza = prosody.core_route_stanza; local host = module:get_host(); local motd_jid = module:get_option("motd_jid") or host; local datamanager = require "util.datamanager"; local ipairs = ipairs; local motd_sequential_messages = module:get_option("motd_sequential_messages") or {}; local motd_messagesets = {}; local max = 1; for i, message in ipairs(motd_sequential_messages) do motd_messagesets[i] = message; max = i; end local st = require "util.stanza"; module:hook("resource-bind", function (event) local session = event.session; local alreadyseen_list = datamanager.load(session.username, session.host, "motd_sequential_seen") or { max = 0 }; local alreadyseen = alreadyseen_list["max"] + 1; local motd_stanza; for i = alreadyseen, max do motd_stanza = st.message({ to = session.username..'@'..session.host, from = motd_jid }, motd_messagesets[i]); core_route_stanza(hosts[host], motd_stanza); module:log("debug", "MOTD send to user %s@%s", session.username, session.host); end alreadyseen_list["max"] = max; datamanager.store(session.username, session.host, "motd_sequential_seen", alreadyseen_list); end);