aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2023-03-29 17:15:33 +0100
committerMatthew Wild <mwild1@gmail.com>2023-03-29 17:15:33 +0100
commit24fa8c5d6031de8a3738cc7a7532a831f9fe0775 (patch)
treea29749aba234e0850228fec709934590ced96db8
parent2ed84fde94948bfc8203e75a2a5f19ce596ed82a (diff)
downloadprosody-24fa8c5d6031de8a3738cc7a7532a831f9fe0775.tar.gz
prosody-24fa8c5d6031de8a3738cc7a7532a831f9fe0775.zip
mod_tokenauth: Add API to inspect individual grants or all of a user's grants
-rw-r--r--plugins/mod_tokenauth.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/mod_tokenauth.lua b/plugins/mod_tokenauth.lua
index 7efdcc2d..c1fd37a6 100644
--- a/plugins/mod_tokenauth.lua
+++ b/plugins/mod_tokenauth.lua
@@ -214,6 +214,24 @@ local function _get_validated_token_info(token_id, token_user, token_host, token
return token_info;
end
+function get_grant_info(username, grant_id)
+ local grant = _get_validated_grant_info(username, grant_id);
+ if not grant then return nil; end
+
+ -- Caller is only interested in the grant, no need to expose token stuff to them
+ grant.tokens = nil;
+
+ return grant;
+end
+
+function get_user_grants(username)
+ local grants = token_store:get(username);
+ if not grants then return nil; end
+ for grant_id, grant in pairs(grants) do
+ grants[grant_id] = _get_validated_grant_info(username, grant);
+ end
+ return grants;
+end
function get_token_info(token)
local token_id, token_user, token_host, token_secret = parse_token(token);