Comparison

plugins/mod_tokenauth.lua @ 13010:3e454af3615d

mod_tokenauth: Add API to inspect individual grants or all of a user's grants
author Matthew Wild <mwild1@gmail.com>
date Wed, 29 Mar 2023 17:15:33 +0100
parent 13009:a70ff0c524c9
child 13024:7558fd152459
comparison
equal deleted inserted replaced
13009:a70ff0c524c9 13010:3e454af3615d
212 token_info.jid = grant.jid; 212 token_info.jid = grant.jid;
213 213
214 return token_info; 214 return token_info;
215 end 215 end
216 216
217 function get_grant_info(username, grant_id)
218 local grant = _get_validated_grant_info(username, grant_id);
219 if not grant then return nil; end
220
221 -- Caller is only interested in the grant, no need to expose token stuff to them
222 grant.tokens = nil;
223
224 return grant;
225 end
226
227 function get_user_grants(username)
228 local grants = token_store:get(username);
229 if not grants then return nil; end
230 for grant_id, grant in pairs(grants) do
231 grants[grant_id] = _get_validated_grant_info(username, grant);
232 end
233 return grants;
234 end
217 235
218 function get_token_info(token) 236 function get_token_info(token)
219 local token_id, token_user, token_host, token_secret = parse_token(token); 237 local token_id, token_user, token_host, token_secret = parse_token(token);
220 if not token_id then 238 if not token_id then
221 module:log("warn", "Failed to verify access token: %s", token_user); 239 module:log("warn", "Failed to verify access token: %s", token_user);