diff --git a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt index 64a15847..0914cc15 100644 --- a/src/Agent/AutopilotMonitor.Agent/buildcounter.txt +++ b/src/Agent/AutopilotMonitor.Agent/buildcounter.txt @@ -1 +1 @@ -863 +865 diff --git a/src/Backend/AutopilotMonitor.Functions/Functions/Metrics/GetImeVersionHistoryFunction.cs b/src/Backend/AutopilotMonitor.Functions/Functions/Metrics/GetImeVersionHistoryFunction.cs index 768906c4..a7ed2b5b 100644 --- a/src/Backend/AutopilotMonitor.Functions/Functions/Metrics/GetImeVersionHistoryFunction.cs +++ b/src/Backend/AutopilotMonitor.Functions/Functions/Metrics/GetImeVersionHistoryFunction.cs @@ -1,4 +1,5 @@ using System.Net; +using AutopilotMonitor.Functions.Helpers; using AutopilotMonitor.Shared.DataAccess; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; @@ -9,7 +10,8 @@ namespace AutopilotMonitor.Functions.Functions.Metrics /// /// Returns all known IME agent versions with first/last seen dates and session counts. /// Permanent archive that survives data retention — tracks Microsoft IME releases over time. - /// Access: MemberRead (any tenant member can see global IME version history). + /// Access: MemberRead (any tenant member can see version/dates/counts). + /// FirstSeenTenantId and FirstSeenSessionId are only visible to Global Admins. /// public class GetImeVersionHistoryFunction { @@ -28,10 +30,28 @@ namespace AutopilotMonitor.Functions.Functions.Metrics { try { + var requestCtx = req.GetRequestContext(); var versions = await _sessionRepo.GetImeVersionHistoryAsync(); var response = req.CreateResponse(HttpStatusCode.OK); - await response.WriteAsJsonAsync(versions); + + if (requestCtx.IsGlobalAdmin) + { + await response.WriteAsJsonAsync(versions); + } + else + { + // Strip sensitive cross-tenant data for non-Global Admins + var redacted = versions.Select(v => new + { + v.Version, + v.FirstSeenAt, + v.LastSeenAt, + v.SessionCount + }); + await response.WriteAsJsonAsync(redacted); + } + return response; } catch (Exception ex)