Changeset

5603:d2561c1d26f5

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.
author Kim Alvefur <zash@zash.se>
date Fri, 14 Jul 2023 15:16:06 +0200
parents 5602:eae5599bc0b4
children 5604:5ade45d93908
files mod_client_management/mod_client_management.lua
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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";