mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-10-26 13:39:47 +00:00
cf279d70b4
ensureAdminSession, the session check behind RequireAdmin and the settings scope helpers, admitted anyone who could manage the organization named in the request. That was meant for the org-bound settings pages, but it applied to every admin route. On a multi-tenant install an organization owner could therefore rotate the instance administrator's API token and receive its secret, widen any token's scopes, add or replace SSO providers, change system settings, relay and log level, apply or roll back updates, restart the service, and read instance logs and diagnostics. ensureAdminSession now admits only instance administrators: the configured admin or an instance RBAC admin grant, whichever org the request names. Routes whose handlers act only on the request organization opt in explicitly through RequireOrgAdmin, ensureOrgAdminSession or ensureOrgSettingsWriteScope, which also admit that organization's owners and admins. Those routes cover agents, nodes, connections, availability, TrueNAS and VMware, agent profiles, install commands, deploy status, configuration transfer and the org-bound relay mobile token. Anything that does not opt in fails closed. Reporting stays instance administration, and the security status snapshot stops offering it to org managers, because report generation still reads the instance's default metrics store. Notifications, LAN discovery and the action-capability fallback also stay instance administration. The two credential routes no longer need their own check, so ensureInstanceAdminSession is folded into this rule.