Mercurial > prosody-modules
annotate mod_watch_spam_reports/mod_watch_spam_reports.lua @ 5682:527c747711f3
mod_http_oauth2: Limit revocation to clients own tokens in strict mode
RFC 7009 section 2.1 states:
> The authorization server first validates the client credentials (in
> case of a confidential client) and then verifies whether the token was
> issued to the client making the revocation request. If this
> validation fails, the request is refused and the client is informed of
> the error by the authorization server as described below.
The first part was already covered (in strict mode). This adds the later
part using the hash of client_id recorded in 0860497152af
It still seems weird to me that revoking a leaked token should not be
allowed whoever might have discovered it, as that seems the responsible
thing to do.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 29 Oct 2023 11:30:49 +0100 |
parents | 97d34d520cfa |
children |
rev | line source |
---|---|
4051
91e2e510e17c
mod_watch_spam_reports: Show reporters bare JID instead of full JID
Martin Dosch <martin@mdosch.de>
parents:
4046
diff
changeset
|
1 local jid = require "util.jid"; |
4663
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
2 local set = require "util.set"; |
4046
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
3 local st = require "util.stanza"; |
4663
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
4 local usermanager = require "core.usermanager"; |
4046
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
5 local host = module.host; |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
6 |
4663
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
7 local admins; |
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
8 if usermanager.get_jids_with_role then |
5022
97d34d520cfa
mod_watch_spam_reports: Fix traceback due to misplaced parenthesis (thanks Menel)
Kim Alvefur <zash@zash.se>
parents:
4663
diff
changeset
|
9 admins = set.new(usermanager.get_jids_with_role("prosody:admin", host)); |
4663
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
10 else -- COMPAT w/pre-0.12 |
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
11 admins = module:get_option_inherited_set("admins"); |
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
12 end |
6e5572fc6840
mod_watch_spam_reports: Support for fetching admins from authz provider
Matthew Wild <mwild1@gmail.com>
parents:
4657
diff
changeset
|
13 |
4046
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
14 module:depends("spam_reporting") |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
15 |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
16 module:hook("spam_reporting/spam-report", function(event) |
4061
9745a623c7ed
mod_watch_spam_reports: Define variable prior to using it
Martin Dosch <martin@mdosch.de>
parents:
4054
diff
changeset
|
17 local reporter_bare_jid = jid.bare(event.stanza.attr.from) |
4657
78ef5d9e2361
mod_watch_spam_reports: Prepare for changing 'reason' to an optional value
Kim Alvefur <zash@zash.se>
parents:
4611
diff
changeset
|
18 local report = reporter_bare_jid.." reported spam from "..event.jid..": "..(event.reason or "no reason given") |
4046
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
19 for admin_jid in admins |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
20 do |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
21 module:send(st.message({from=host, |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
22 type="chat",to=admin_jid}, |
4061
9745a623c7ed
mod_watch_spam_reports: Define variable prior to using it
Martin Dosch <martin@mdosch.de>
parents:
4054
diff
changeset
|
23 report)); |
4046
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
24 end |
d518f97dad6f
mod_watch_spam_reports: Module to notify admins about incoming XEP-0377 spam reports
Martin Dosch <martin@mdosch.de>
parents:
diff
changeset
|
25 end) |
4611
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
26 |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
27 module:hook("spam_reporting/abuse-report", function(event) |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
28 local reporter_bare_jid = jid.bare(event.stanza.attr.from) |
4657
78ef5d9e2361
mod_watch_spam_reports: Prepare for changing 'reason' to an optional value
Kim Alvefur <zash@zash.se>
parents:
4611
diff
changeset
|
29 local report = reporter_bare_jid.." reported abuse from "..event.jid..": "..(event.reason or "no reason given") |
4611
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
30 for admin_jid in admins |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
31 do |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
32 module:send(st.message({from=host, |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
33 type="chat",to=admin_jid}, |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
34 report)); |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
35 end |
7a9e1c81c63e
mod_watch_spam_reports: Support spam_reporting/abuse-report
Martin Dosch <martin@mdosch.de>
parents:
4061
diff
changeset
|
36 end) |