Repository navigation
A token reads a base's ontology and a class's instances - #1265
Conversation
WaylandYang
left a comment
There was a problem hiding this comment.
Thank you. Both routes are GETs and go through the same require_reader_kb as document content, so the owner's role is the ceiling and a base outside kb_ids is a 404. The store reads underneath are bound to the base in the path: entity_instances filters on kb_id and type_id together, so a class id from another base returns an empty page rather than that base's members, and merged entities stay out. The create, update and delete routes on the same paths stay session-only. Both tests run in CI and fail without the change.
As asked on #1264, the docs need to line up before merge:
- Please rebase on #1263 (and #1264 once it's in). Then add these two routes, with their reasons, to its decision 7 ("A token reads the graph") instead of adding another decision 7, and extend its revision line rather than adding a new one. One idea should be one decision, so a reader finds every token-readable route in one place.
- Please add the ontology reads to the
SessionOrTokencomment inauth.rs(line 179 ondev). That comment is where a reader of the code learns which routes a token can reach. - Please take #1262 off the 0014 status line. It goes there with the last of the read PRs, the same as in #1263.
One suggestion while you rebase: token_read_tests from #1263 already has a person type with two entities in the base and a second base for the 404 case. Adding these two GETs there would be about ten lines instead of a fourth copy of the fixture, and the instances check would see a real member rather than total == 0.
|
Thanks. Once #1263 (and #1264) are in I'll rebase this, fold the two ontology reads with their reasons into decision 7 and extend its revision line, add them to the |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
4709b19 to
cfeb70e
Compare
|
Thank you @WaylandYang, both for the careful review and for the fixture suggestion, which made this a lot smaller. I've rebased onto
On the suggestion: the two GETs now sit in It is ready for another look whenever suits you. |
|
A gentle ping whenever you have a moment, no rush. This is rebased on |
Sync upstream dev into re-dev (2026-10-22, third): deeplethe#1354, deeplethe#1251, deeplethe#1327, deeplethe#1248, deeplethe#1353, deeplethe#1265
Part of #1262.
What happened
A backend that mirrors into a base needs the base's ontology to turn a class key into a type id, and then the members of that class. Both reads took a session JWT, so a personal token got 401.
What changed
GET /kbs/{id}/ontologyandGET /kbs/{id}/ontology/entity-types/{type_id}/entitiestakeSessionOrTokenand callrequire_reader_kb(0052): the owner needs Viewer, any token scope may read, and a token whosekb_idsexclude the base gets 404. Neither handler changes what it returns, and the instances read keeps itsmissing_predicatefilter (#1269). The create, update and delete routes on the same paths stay session-only.Decision 7 in 0014 now counts eight graph reads, with a reason for each new one, and its revision line gains one sentence. The
SessionOrTokencomment inauth.rsanddocs/design/access-and-audit.mdname both reads.Tests
The two GETs join
read_pathsinapi::token_read_tests, so the instances read runs against the fixture'spersonclass with its two members. A viewer's read token gets 200 on every path, and a token limited to another base gets 404. Switching either route back to session-only makes both tests fail with 401.cargo test -p utopia-serveragainst Postgres withUTOPIA_TEST_REQUIRE_DB=1,cargo fmt --all -- --checkandcargo clippy -p utopia-server --all-targets -- -D warningsare clean.🤖 Generated with Claude Code