shadok-ai 0.17.12 → 0.17.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -1728,6 +1728,27 @@ function mtTokenGate(req, res) {
1728
1728
  }
1729
1729
  return true;
1730
1730
  }
1731
+ /**
1732
+ * The READ counterpart of `mtTokenGate`: multi-tenant + admin, but WITHOUT the
1733
+ * `requestFromBrowser` (Origin) check. A browser omits `Origin` on a same-origin
1734
+ * GET, so gating a READ on it 403s the cockpit's own status fetch — which is
1735
+ * exactly what hid the per-user sign-in list (the GET returned 403, so it never
1736
+ * rendered, while the POST writes that DO send Origin worked). The Origin check
1737
+ * is CSRF protection for WRITES (invariant 26); a read of login status (labels +
1738
+ * loggedIn booleans, never a token) has no such surface, so it must not require
1739
+ * one.
1740
+ */
1741
+ function mtReadGate(req, res) {
1742
+ if (DEPLOYMENT_MODE !== "multi-tenant") {
1743
+ res.status(400).json({ error: "not applicable: this instance is single-tenant" });
1744
+ return false;
1745
+ }
1746
+ if (currentAccount(req)?.role !== "admin") {
1747
+ res.status(403).json({ error: "admins only" });
1748
+ return false;
1749
+ }
1750
+ return true;
1751
+ }
1731
1752
  app.post("/mt-token/start", async (req, res) => {
1732
1753
  if (!mtTokenGate(req, res))
1733
1754
  return;
@@ -1780,7 +1801,10 @@ function loginUsers() {
1780
1801
  return out;
1781
1802
  }
1782
1803
  app.get("/agent-login", (req, res) => {
1783
- if (!mtTokenGate(req, res))
1804
+ // A READ: use the origin-less gate. A browser sends no `Origin` on a
1805
+ // same-origin GET, so `mtTokenGate` (which requires one) would 403 the
1806
+ // cockpit's own status fetch and the per-user sign-in list would never render.
1807
+ if (!mtReadGate(req, res))
1784
1808
  return;
1785
1809
  const mode = agentAuthForCwd(loadConfig(), process.cwd());
1786
1810
  const users = loginUsers().map(({ user, home, label }) => {