diff --git a/docs/decisions/0069-the-identity-provider-vouches-for-listed-domains.md b/docs/decisions/0069-the-identity-provider-vouches-for-listed-domains.md index 18b0468da..9c2a8dcc7 100644 --- a/docs/decisions/0069-the-identity-provider-vouches-for-listed-domains.md +++ b/docs/decisions/0069-the-identity-provider-vouches-for-listed-domains.md @@ -14,6 +14,8 @@ Migration 0056 rejected linking by email for a reason that still holds in genera 1. **`UTOPIA_OIDC_ALLOWED_DOMAINS` lists the domains the identity provider is authoritative for.** On a login or an exchange whose subject is not linked, a token whose `email` is in a listed domain and whose `email_verified` is true is mapped by email: to the active account with that address (case-insensitive), or to a new one. The subject is then linked to it, so later sign-ins go by subject as before. The list is empty by default, and an empty list keeps 0056's rule exactly. + *Revised 2026-11-18:* Microsoft Entra sends no `email_verified`. Its optional claim `xms_edov`, true when the owner of the email's domain is verified, counts the same way and is read as leniently (decision 9). Not yet run against a real Entra tenant. + **Revision 2026-10-22 (#1355).** The `email` claim arrives only when the authorization request asks for the `email` scope. The scopes are now `UTOPIA_OIDC_SCOPES` (default `openid profile email`), so a deployment that lists domains must keep `email` in them, or no address reaches this rule and nobody is linked or opened by domain; the server warns at startup when the list is set and `email` is missing. **Revision 2026-10-16 (#1258).** This assumed the active match was unique. Checking `users_email_active_idx` showed that it compares the stored spelling, while registration and administrator-created accounts preserve casing: two active accounts can differ only in email case. `account_for_sso` now refuses multiple active case-insensitive matches as `unlinked` before creating an account or writing an identity, rather than choosing one. The check covers the query snapshot; a unique index on `lower(email)`, normalization at registration and administrator creation, and a decision about existing duplicates remain separate work. diff --git a/web/src/pages/Ontology.tsx b/web/src/pages/Ontology.tsx index 96e9ec0a2..7f02ae829 100644 --- a/web/src/pages/Ontology.tsx +++ b/web/src/pages/Ontology.tsx @@ -771,6 +771,7 @@ export function Ontology() { existing={edit.existing} allTypes={entity_types} allRelations={relations} + allAttributes={relation_types.filter((r) => r.kind === "attribute")} initialDomain={edit.initialDomain} onClose={() => setEdit(null)} onSaved={(createdId) => { diff --git a/web/src/pages/ontologyDialogs.test.ts b/web/src/pages/ontologyDialogs.test.ts new file mode 100644 index 000000000..032867cca --- /dev/null +++ b/web/src/pages/ontologyDialogs.test.ts @@ -0,0 +1,32 @@ +import { createElement, type ReactNode } from "react"; +import { renderToStaticMarkup } from "react-dom/server"; +import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; +import { describe, expect, it, vi } from "vitest"; +import type { RelationTypeView } from "../api"; +import { PropertyDialog } from "./ontologyDialogs"; + +// Radix 的 Portal 在服务端渲染里什么都不出,弹窗的壳换成直接出正文 +vi.mock("../ui", async (original) => ({ + ...(await original()), + FormDialog: ({ children }: { children: ReactNode }) => children, +})); + +// 只填弹窗用得上的字段,没填的它按缺省处理(`existing?.x ?? …`) +const def = (id: string, kind: RelationTypeView["kind"], label: string) => + ({ id, key: id, label, kind, usage: 0 }) as RelationTypeView; + +describe("PropertyDialog", () => { + it("offers the knowledge base's attributes as edge attributes", () => { + // 已选的显示成标签,标签的名字从候选里取:候选里没有这个属性,标签就出不来 + const relation = { ...def("moves_to", "relation", "Moves to"), qualifiers: ["reason"] }; + const html = renderToStaticMarkup(createElement(QueryClientProvider, { + client: new QueryClient(), + children: createElement(PropertyDialog, { + kbId: "kb", existing: relation, allTypes: [], allRelations: [relation], + allAttributes: [def("reason", "attribute", "Reason")], initialDomain: null, + onClose: vi.fn(), onSaved: vi.fn(), onDeleted: vi.fn(), onError: vi.fn(), + }), + })); + expect(html).toContain("Reason"); + }); +}); diff --git a/web/src/pages/ontologyDialogs.tsx b/web/src/pages/ontologyDialogs.tsx index c88830984..9dc2226fa 100644 --- a/web/src/pages/ontologyDialogs.tsx +++ b/web/src/pages/ontologyDialogs.tsx @@ -292,6 +292,7 @@ export function PropertyDialog({ existing, allTypes, allRelations, + allAttributes, initialDomain, onClose, onSaved, @@ -304,6 +305,9 @@ export function PropertyDialog({ /** 本库的关系(不含属性)。逆与子属性的下拉从这里取——**属性不在其中**, * 它的宾语是字面值,反过来无从谈起 */ allRelations: RelationTypeView[]; + /** 本库的属性定义,「边上的属性」的候选。单独传进来:从前这个下拉在 + * allRelations 里筛 kind=attribute,而那里恰恰没有属性,于是永远是空的(#1519) */ + allAttributes: RelationTypeView[]; /** 从一个类出发新建关系时,domain 预填成那个类——**只影响初始值**, * 不是约束:下面照旧是个可编辑的 MultiSearchSelect,填错了随手改 */ initialDomain: string | null; @@ -477,8 +481,8 @@ export function PropertyDialog({
{S.ontology.qualifiers}
r.kind === "attribute" && r.id !== existing?.id) + options={allAttributes + .filter((r) => r.id !== existing?.id) .map((r) => ({ value: r.id, label: r.label, indent: 0 }))} onToggle={(id) => toggleIn(setQualifiers, id)} placeholder={S.ontology.searchTypes}