# HG changeset patch # User Kim Alvefur # Date 1689340566 -7200 # Node ID d2561c1d26f578b997fd22cac85a8a2eaa9556d8 # Parent eae5599bc0b432ed649d1c729e7e9f1deefafd84 mod_client_management: Allow revoking a specific client version Could be useful in case of a security issue affecting a particular version. Even if in that case, the more likely use case is revoking all older versions except the fixed one(s), this can be done with a loop or improved later. diff -r eae5599bc0b4 -r d2561c1d26f5 mod_client_management/mod_client_management.lua --- a/mod_client_management/mod_client_management.lua Fri Jul 14 15:01:56 2023 +0200 +++ b/mod_client_management/mod_client_management.lua Fri Jul 14 15:16:06 2023 +0200 @@ -278,6 +278,17 @@ return active_clients; end +local function user_agent_tostring(user_agent) + if user_agent then + if user_agent.software then + if user_agent.software_version then + return user_agent.software .. "/" .. user_agent.software_version; + end + return user_agent.software; + end + end +end + function revoke_client_access(username, client_selector) if client_selector then local c_type, c_id = client_selector:match("^(%w+)/(.+)$"); @@ -314,7 +325,7 @@ elseif c_type == "software" then local active_clients = get_active_clients(username); for _, client in ipairs(active_clients) do - if client.user_agent and client.user_agent.software == c_id then + if client.user_agent and client.user_agent.software == c_id or user_agent_tostring(client.user_agent) then return revoke_client_access(username, client.id); end end @@ -432,15 +443,7 @@ title = "Software"; key = "user_agent"; width = "1p"; - mapper = function(user_agent) - if user_agent and user_agent.software then - if user_agent.software_version then - return user_agent.software .. "/" .. user_agent.software_version; - else - return user_agent.software; - end - end - end; + mapper = user_agent_tostring; }; { title = "Last seen";