Changeset

5717:8afa0fb8a73e

mod_client_management: Report on longest lived token when grant does not expire E.g. for mod_http_oauth2 where by default the grant itself is unlimited, while refresh tokens are issued with one week lifetime, but are renewed with each use.
author Kim Alvefur <zash@zash.se>
date Fri, 10 Nov 2023 00:26:17 +0100
parents 5716:6696075e26e2
children 5718:b4632d5f840b
files mod_client_management/mod_client_management.lua
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_client_management/mod_client_management.lua	Tue Nov 07 11:28:46 2023 +0000
+++ b/mod_client_management/mod_client_management.lua	Fri Nov 10 00:26:17 2023 +0100
@@ -471,10 +471,24 @@
 			};
 			{
 				title = "Expires";
-				key = "expires";
+				key = "active";
 				width = date_or_time_width;
 				align = "right";
-				mapper = date_or_time;
+				mapper = function(active, client)
+					local grant = active and active.grant;
+					local expires = client and client.expires;
+					local tokens = grant and grant.tokens;
+					if expires or not tokens then
+						return date_or_time(expires);
+					end
+
+					for _, token in pairs(tokens) do
+						if token.expires and (not expires or token.expires > expires) then
+							expires = token.expires;
+						end
+					end
+					return date_or_time(expires);
+				end;
 			};
 			{
 				title = "Authentication";