# HG changeset patch # User Matthew Wild # Date 1679996589 -3600 # Node ID 34ed17ef1c1a34cd30aef43e6c9f112433cac51c # Parent d8e2b995f9759c21fd87253dbfbba04123f80a54 mod_tokenauth: Fire events on grant creation and revocation diff -r d8e2b995f975 -r 34ed17ef1c1a plugins/mod_tokenauth.lua --- a/plugins/mod_tokenauth.lua Tue Mar 28 11:27:05 2023 +0200 +++ b/plugins/mod_tokenauth.lua Tue Mar 28 10:43:09 2023 +0100 @@ -55,6 +55,13 @@ 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 @@ 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)