aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2023-03-28 10:43:09 +0100
committerMatthew Wild <mwild1@gmail.com>2023-03-28 10:43:09 +0100
commitef5dfa900fbdc742237d3e69879401566fa82fd3 (patch)
treeb4eceb7c2cfa09c96b1139992dba3592953de2cc /plugins
parent0d2a9ef54abe35f2cce6ec2560873f08c69ae48d (diff)
downloadprosody-ef5dfa900fbdc742237d3e69879401566fa82fd3.tar.gz
prosody-ef5dfa900fbdc742237d3e69879401566fa82fd3.zip
mod_tokenauth: Fire events on grant creation and revocation
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_tokenauth.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/mod_tokenauth.lua b/plugins/mod_tokenauth.lua
index 94c740c0..5703f4a4 100644
--- a/plugins/mod_tokenauth.lua
+++ b/plugins/mod_tokenauth.lua
@@ -55,6 +55,13 @@ function create_grant(actor_jid, grant_jid, grant_ttl, grant_data)
return nil, err;
end
+ module:fire_event("token-grant-created", {
+ id = grant_id;
+ grant = grant;
+ username = grant_username;
+ host = grant_host;
+ });
+
return grant;
end
@@ -226,7 +233,12 @@ function revoke_token(token)
if token_host ~= module.host then
return nil, "invalid-host";
end
- return token_store:set_key(token_user, token_id, nil);
+ local ok, err = token_store:set_key(token_user, token_id, nil);
+ if not ok then
+ return nil, err;
+ end
+ module:fire_event("token-grant-revoked", { id = token_id, username = token_user, host = token_host });
+ return true;
end
function sasl_handler(auth_provider, purpose, extra)