fix(webui): keep the instance settings out of another org's reach

This commit is contained in:
sam committed 2026-10-27 02:44:33 +11:00
1 parent 5b3b88ed3d
commit 58629ea03a
5 files changed
+36 -14

No files matched your search

+8 -1
View File
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { Button } from "@/components/ui/button";
import { computed, nextTick, onMounted, ref, watch } from "vue";
import { useRoute } from "vue-router";
import { useRoute, useRouter } from "vue-router";
import AccountEntry from "@/accounts/AccountEntry.vue";
import { useAccountsStore } from "@/accounts/accounts";
@@ -18,9 +18,16 @@ const reauthenticate=new URLSearchParams(window.location.search).has("reauth");
const accounts=useAccountsStore();
const session = useSessionStore();
const route = useRoute();
const router = useRouter();
const workflowsPage = computed(() => route.path === "/workflows");
const hidden = computed(() => hiddenPaths(session.sections));
const main = ref<HTMLElement | null>(null);
// A page the caller may not open is not reachable by URL either: the nav drops
// it, so a bookmark or a chat link must not land on a form whose saves the
// control plane refuses.
watch([() => route.path, hidden], () => {
if (hidden.value.includes(route.path)) void router.replace("/");
});
watch(() => [route.path, accounts.instance], () => {
const scope = route.meta.org ? "Organisation" : route.meta.settings ? "Instance" : "";
document.title = [route.meta.label || "Page not found", scope, "Archie", accounts.instance].filter(Boolean).join(" | ");
+15 -6
View File
@@ -17,13 +17,19 @@ export type CapabilitySections = Record<string, boolean>;
*/
export interface SectionedRoute {
path: string;
meta?: { section?: string };
meta?: { section?: string; settings?: boolean; instance?: boolean };
}
// hiddenRoutes returns the paths whose section the server reported it cannot
// serve. An unreported section stays visible: a page that says "unavailable"
// is recoverable, a navigation entry that silently vanished is not, so an
// older server or a failed capabilities read shows everything.
// serve, or that the caller may not operate. An unreported section stays
// visible: a page that says "unavailable" is recoverable, a navigation entry
// that silently vanished is not, so an older server or a failed capabilities
// read shows everything.
//
// The Instance settings area belongs to the system org (`sections.settings`).
// Two of its pages are not the instance's: appearance is the caller's own
// preference and audit reads only the caller's org, so they opt out with
// `instance: false`.
export function hiddenRoutes(
sections: CapabilitySections | null | undefined,
table: SectionedRoute[],
@@ -32,8 +38,11 @@ export function hiddenRoutes(
return table
.filter(
(r) =>
typeof r.meta?.section === "string" &&
sections[r.meta.section] === false,
(typeof r.meta?.section === "string" &&
sections[r.meta.section] === false) ||
(r.meta?.settings === true &&
r.meta.instance !== false &&
sections.settings === false),
)
.map((r) => r.path);
}
+5 -1
View File
@@ -141,6 +141,9 @@ const routes = [
meta: {
navPath: "/settings",
settings: true,
// Not the instance's: a personal preference, open to any signed-in
// member of any org.
instance: false,
label: "Appearance",
},
},
@@ -394,9 +397,10 @@ const routes = [
meta: {
navPath: "/settings",
settings: true,
// Reads only the caller's own org, so any org may open it.
instance: false,
label: "Audit",
description: "Settings, access, identity and runtime events.",
section: "settings",
},
},
{ path: "/settings/history", redirect: (to: RouteLocationGeneric) => ({ path: "/settings/audit", query: to.query, hash: to.hash }), meta: { nav: false } },